Ashar25 / RainyDay

0 stars 1 forks source link

Arrays need flipping #25

Closed danielbwright closed 1 year ago

danielbwright commented 1 year ago

We need to carefully verify the orientation (specifically, the north-south orientation) of all relevant arrays (e.g., catrain, catmask, tranposition probabilites) are consistent with each other. Currently, I believe catrain is not consistent with prior usage and other arrays. The easiest fix is likely to flip catrain once it is converted to numpy array, and then make sure things are flipped back before being written to netcdf.

Ashar25 commented 1 year ago

This is something which I was worried about while changing the findsubbox and readnetcdf. We can check this once we are able to make diagnostic plots compatible with new version of RainyDay.

danielbwright commented 1 year ago

This needs a little bit more verification but I think it is almost finished.

danielbwright commented 1 year ago

I was surprised to see the flipping of north-south in writecatalog_ash(): data_vars = dict( rain = (("time","latitude", "longitude"),catrain[:, ::-1, :],{'units': rainrate_units, 'long_name': rainrate_name}), gridmask= (("latitude", "longitude"), gridmask[::-1, :],{'units': 'dimensionless', 'long_name': gmask_name}), domainmask = (("latitude", "longitude"),dmask[::-1, :],{'units': 'dimensionless', 'long_name': domainmask_name}), latitude = (("latitude"), latrange[::-1].data, {'units': latitudes_units, 'long_name': latitudes_name}),

I didn't expect to see these, because the behavior of the rest of the code seemed correct despite this. Further testing is needed. Perhaps this actually doesn't matter because, maybe, when xarray reads them back in, it handles it because it is "coordinate aware".

danielbwright commented 1 year ago

Ashar, please perform the following test:

  1. Write two storm catalog files: (1) using the code where the lines above (e.g. rain, gridmask, etc.) are "flipped" using the '[::-1]' that you used in writecatalog_ash(). (2) using the code, but omitting the "[::-1]".
  2. Read both files back in using xarray and check if the resulting values are different or identical.
Ashar25 commented 1 year ago

Dan, sorry for the last comment. I think this is working fine with both the conditions. So, we can remove this [::-1], probably.