hypertidy / ncmeta

Tidy NetCDF metadata
https://hypertidy.github.io/ncmeta/
11 stars 5 forks source link

NetCDF Projection Conversions #17

Closed dblodgett-usgs closed 5 years ago

dblodgett-usgs commented 5 years ago

This fixes #14

I am terrible at naming, so please look at function names and suggest what might be more in line with the package vision. Happy to refactor or find a better home for these as you see fit.

mdsumner commented 5 years ago

I was expecting to see a "nc_grid_mapping" function that was variable specific, because there can be more than one to a file/source. This "nc_grid_mapping_atts" doesn't pick up the names in a source I have , specifically

nc_grid_mapping_atts(f)
# A tibble: 4 x 2
  name                        value    
  <chr>                       <list>   
1 grid_mapping_name           <chr [1]>
2 semi_major_axis             <dbl [1]>
3 inverse_flattening          <dbl [1]>
4 longitude_of_prime_meridian <dbl [1]>
Warning message:
In nc_grid_mapping_atts.data.frame(nc_atts(x)) :
  No variables with a grid mapping found.
 Defaulting to WGS84 Lon/Lat

but "geolat_c/geolon_c" and "geolat_t/geolon_t" for

 float roughness_amp[xt_ocean,yt_ocean]   
            long_name: roughness amplitude for breaking internal wave mixing scheme
            units: metre
            valid_range: -10
             valid_range: 1e+09
            missing_value: -1.00000002004088e+20
            _FillValue: -1.00000002004088e+20
            cell_methods: time: point
            coordinates: geolon_t geolat_t
        float bmf_u[xu_ocean,yu_ocean,time]   
            long_name: Bottom u-stress via bottom drag
            units: N/m^2
            valid_range: -1
             valid_range: 100
            missing_value: -1.00000002004088e+20
            _FillValue: -1.00000002004088e+20
            cell_methods: time: mean
            time_avg_info: average_T1,average_T2,average_DT
            coordinates: geolon_c geolat_c

but still I have to explore this some more. I'll try to find a shareable file that has this behaviour (this one is 9Gb...)

dblodgett-usgs commented 5 years ago

That's because there's no grid_mapping attribute or variable.

I've never seen a file that uses multiple grid_mappings, but it looks like that is the intention of cf. http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch05s06.html

I'll work that in to this. So nc_grid_mapping_atts will optionally take a variable name. In the case that you don't pass a variable name it may return multiple grid_mappings.

mdsumner commented 5 years ago

Oh sheesh, sorry - showing my ignorance. I was thinking this was the coordinates attribute, and little more. I'll have a closer look, thanks!

mdsumner commented 5 years ago

I don't have a problem with the names as they are!