NTNU-SmallSat-Lab / hypso-satpy

1 stars 0 forks source link

ValueError("Datasets to be saved in one file (or one group) must have identical projection coordinates." ValueError: Datasets to be saved in one file (or one group) must have identical projection coordinates.Please group them by area or save them in separate file #30

Closed CameronLP closed 8 months ago

CameronLP commented 8 months ago

ValueError("Datasets to be saved in one file (or one group) must have identical projection coordinates." ValueError: Datasets to be saved in one file (or one group) must have identical projection coordinates.Please group them by area or save them in separate file

Error is displayed when a resampled scene is saved to .nc:

datasets = scene.available_dataset_names() resampled_scene = scene.resample(area_def, resampler='bilinear', fill_value=np.NaN)

CameronLP commented 8 months ago

This error appears to be related to the 'latitude' and 'longitude' coordinate datasets being left out of the resampling process. In 'resampled_scene', datasets such as 'band_80' are resampled to the new resolution specified in area_def (for testing this has been 500x500) but the two coordinate datasets, 'latitude' and 'longitude', remain at the original capture dimensions (such as 956x684). During the write to NetCDF, the cf_writer module encounters the coordinate datasets with different dimensions and fails, returning the ValueError message.

I am sending a message to the pyresample developers asking about the resampling of coordinate datasets such as 'latitude' and 'longitude'. This might be related to how SatPy treats swath data vs. gridded data.

As a work around for now, the list of datasets passed to the cf_writer should NOT include 'latitude' and 'longitude' datasets, only the 'band_xx' datasets. New 'latitude' and 'longitude' arrays of the correct dimensions (500x500) are generated and added to the NetCDF by the cf_writer.