Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for variables based on standard_name attribute #103

Open
mjwoods opened this issue Dec 3, 2022 · 1 comment
Open

Search for variables based on standard_name attribute #103

mjwoods opened this issue Dec 3, 2022 · 1 comment

Comments

@mjwoods
Copy link
Owner

mjwoods commented Dec 3, 2022

As suggested by @lhmarsden in #102 , var.get.nc would be enhanced by adding an optional argument to search for variables based on the standard_name attribute (instead of the variable name). This would simplify the task of reading datasets created by different people, because standard_name is standardised and consistent, unlike ordinary variable names.

@pvanlaake
Copy link

pvanlaake commented Jun 9, 2024

This is going to be a bit more complicated than it may appear at first. Variables (and dimensions) have a unique name in a NetCDF file; the same is not guaranteed for the "standard_name" attribute.

Taking @lhmarsden 's remote file from #143, and using the dev version of the ncdfCF package (https://github.com/pvanlaake/ncdfCF), we get the following:

> devtools::install_github("pvanlaake/ncdfCF")
> library(ncdfCF)

> netcdf_file <- "https://opendap1.nodc.no/opendap/physics/point/cruise/nansen_legacy-single_profile/NMDC_Nansen-Legacy_PR_CT_58US_2021708/CTD_station_P1_NLEG01-1_-_Nansen_Legacy_Cruise_-_2021_Joint_Cruise_2-1.nc"
> x <- open_ncdf(netdcf_file)
> objects_by_standard_name(x, "sea_water_temperature")
[1] "TEMP"   "TEMP-2"

This issue is potentially bigger in DSG-formatted files: there may be many time-series or trajectories using the same physical property in a single file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants