cedadev / nappy

NASA Ames Processing in PYthon (NAPPy) - a Python library for reading, writing and converting NASA Ames files.
BSD 3-Clause "New" or "Revised" License
9 stars 13 forks source link

Error when processing name of variable in HadUK-Grid data #38

Closed agstephens closed 3 years ago

agstephens commented 3 years ago

Inputs:

/mini-ceda-archive/....../archive/badc/ukmo-hadobs/data/insitu/MOHC/HadOBS/HadUK-Grid/v1.0.3.0/1km/snowLying/mon/v20210712/snowLying_hadukgrid_uk_1km_mon_197101-197112.nc

 File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/pywps/app/Process.py", line 248, in _run_process
    self.handler(wps_request, wps_response)  # the user must update the wps_response.
  File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/flamingo/processes/_wps_subset_base.py", line 210, in _handler
    output_uris = write_to_csvs(results, self.workdir)
  File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/flamingo/utils/output_utils.py", line 37, in write_to_csvs
    xr_to_na.convert()
  File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/nappy/nc_interface/xarray_to_na.py", line 89, in convert
    variables = self._convertSingletonVars(self.xr_variables)
  File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/nappy/nc_interface/xarray_to_na.py", line 147, in _convertSingletonVars
    id = xarray_utils.getBestName(var_metadata).replace(" ", "_"),
  File "/usr/local/anaconda/envs/flamingo/lib/python3.7/site-packages/nappy/nc_interface/xarray_utils.py", line 49, in getBestName
    raise Exception(f"Cannot find a valid name for variable: {var}.")
Exception: Cannot find a valid name for variable: {'grid_mapping_name': 'transverse_mercator', 'longitude_of_prime_meridian': 0.0, 'semi_major_axis': 6377563.396, 'semi_minor_axis': 6356256.909, 'longitude_of_central_meridian': -2.0, 'latitude_of_projection_origin': 49.0, 'false_easting': 400000.0, 'false_northing': -100000.0, 'scale_factor_at_central_meridian': 0.9996012717}.
agstephens commented 3 years ago

This led to the discovery that auxiliary variables and singleton variables were not properly converted. We have fixed in "aux-var-fix" branch, and PR.

agstephens commented 3 years ago

See PR: #39