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
Check that time is not already a coordinate in CF writer #1987
Conversation
Some details on the data in ipdb> new_data
<xarray.DataArray 'cma' (y: 10062, x: 2048)>
dask.array<concatenate, shape=(10062, 2048), dtype=uint8, chunksize=(360, 1024), chunktype=numpy.ndarray>
Coordinates:
time (y) datetime64[ns] 2022-01-20T11:05:30 ... 2022-01-20T11:32:28.5...
crs object +proj=latlong +datum=WGS84 +ellps=WGS84 +type=crs
Dimensions without coordinates: y, x
Attributes:
valid_range: [0 1]
ancillary_variables: cma_pal
units: 1
_FillValue: 255
standard_name: cloud_binary_mask
flag_values: [ 0 1 255]
flag_meanings: cloudfree cloudy no_data
sensor: {'seviri'}
long_name: SAFNWC PPS CMA Cloud Mask
platform_name: MetopB
coordinates: lon lat
start_time: 2022-01-20 11:05:00.100000
end_time: 2022-01-20 11:32:56.900000
reader: nwcsaf-pps_nc
modifiers: () So the time is already in time_array = new_data.coords["time"]
del new_data.coords["time"]
new_data = new_data.expand_dims({'time': time_array}) This results in an obviously incorrect result: ipdb> new_data
<xarray.DataArray 'cma' (time: 10062, y: 10062, x: 2048)>
dask.array<broadcast_to, shape=(10062, 10062, 2048), dtype=uint8, chunksize=(10062, 360, 1024), chunktype=numpy.ndarray>
Coordinates:
* time (time) datetime64[ns] 2022-01-20T11:05:30 ... 2022-01-20T11:32:2...
crs object +proj=latlong +datum=WGS84 +ellps=WGS84 +type=crs
Dimensions without coordinates: y, x
Attributes:
valid_range: [0 1]
ancillary_variables: cma_pal
units: 1
_FillValue: 255
standard_name: cloud_binary_mask
flag_values: [ 0 1 255]
flag_meanings: cloudfree cloudy no_data
sensor: {'seviri'}
long_name: SAFNWC PPS CMA Cloud Mask
platform_name: MetopB
coordinates: lon lat
start_time: 2022-01-20 11:05:00.100000
end_time: 2022-01-20 11:32:56.900000
reader: nwcsaf-pps_nc
modifiers: () With my current modification one of the tests fail due to a missing |
Maybe we can just set the start_time as time? like this: |
I think this is more-or-less a proper fix. What I don't understand is that I need to use |
Codecov Report
@@ Coverage Diff @@
## main #1987 +/- ##
==========================================
+ Coverage 93.54% 93.56% +0.01%
==========================================
Files 279 281 +2
Lines 41322 41447 +125
==========================================
+ Hits 38654 38779 +125
Misses 2668 2668
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for taking care of this! Just two minor comments.
The changes in multiscene and slstr_l1b come from rebasing the main branch I guess?
@zxdawn That was about a Multiscene timeseries, but the problem here also occurs with a normal Scene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix for CF writer for cases like swath data where scan line times can be already set as a coordinate for the along-track dimension. In these cases the time dimension shouldn't be added.
Below is what happens with the current
main
branch, which should have been in a separate issue.I was trying to save multiple NWC SAF PPS granules to a single NetCDF file:
Using the current
main
branch, this fails with: