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

Unit conversion of attributes #630

Open
rqwa opened this issue Sep 14, 2021 · 5 comments
Open

Unit conversion of attributes #630

rqwa opened this issue Sep 14, 2021 · 5 comments
Milestone

Comments

@rqwa
Copy link

rqwa commented Sep 14, 2021

By setting attributes with cmor.set_cur_dataset_attribute the passed argument is converted and written as a string. Is this an intended behavior and exists a possibility to keep the initial datatype?

@durack1
Copy link
Contributor

durack1 commented Sep 14, 2021

@rqwa do you have an example? A netcdf variable or global attribute is generally a string, if you have an alternative example that would elucidate the issue that you're raising

@taylor13 @mauzey1

@taylor13
Copy link
Collaborator

global attributes are sometimes integers (e.g., realization_index) or floating point numbers (e.g., branch_time_in_child). I think if it is not too difficult, some users would like to be able to use CMOR to define additional integer or float global attributes.

@rqwa
Copy link
Author

rqwa commented Sep 15, 2021

I am currently preparing satellite observations for obs4mips. As example you can use the HOAPS data, which contains the following floats as global attributes.

geospatial_lat_min = -80. ;
geospatial_lat_max = 80. ;
geospatial_lon_min = -180. ;
geospatial_lon_max = 180. ;

@durack1 durack1 added this to the 4.0/Future milestone Feb 27, 2024
@durack1
Copy link
Contributor

durack1 commented Feb 27, 2024

I am trying to recall whether netcdf 4.x global attributes can have types other than char arrays. Is there some documentation that someone is familiar with that defines exactly that? If type recasting is being done, then maybe for a CMOR4 we might want to reconsider this behaviour in light of the latest netcdf-c 4.9.x functionality?

Note to self https://docs.unidata.ucar.edu/netcdf-c/current/group__attributes.html

@taylor13
Copy link
Collaborator

Yes, they can. The CF conventions (within the netcdf constraints) has both numeric and string attributes, and the numeric values can be integers, single precision float, double precision float, and probably other types too. For the list and type of CF attributes, see:
https://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#attribute-appendix .

I agree that we want CMOR to write attributes of the correct type. I think it worked o.k. at least in the past. For example, I think the missing_value was written as proper type. And the branch_times should have been written double precision. And things like "realization_index" should have been integers.

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

3 participants