FAAM-146 / decades-ppandas

1 stars 0 forks source link

Variable coordinate attribute set in writer #7

Closed davesproson closed 3 years ago

davesproson commented 3 years ago

The coordinates variable attribute cannot be set until a module with GPS output has been run. Currently this is done when writing to netCDF, so that the coordinates attribute is never actually set on a variable. This should probably be done as a processing finalization task...

writers.py:

183         # Set coordinates attribute on variables, if they've been specified
184         if self.dataset.lat and self.dataset.lon:
185             setattr(ncvar, 'coordinates', '{} {}'.format(
186                 self.dataset.lat, self.dataset.lon
187             ))
188 
davesproson commented 3 years ago

New solution is to add a coordinates attribute whenever a variable is added as an output to a DecadesDataset. This is kind-of ok, as the coordinates attribute only really makes sense when the variable is part of a dataset. It's achieved with a deferred call to the coords attribute on the dataset. Will probably close this issue with commit, despite not really being a decent solution.