contrailcirrus / pycontrails

Python library for modeling contrails and other aviation climate impacts
https://py.contrails.org/
Apache License 2.0
59 stars 17 forks source link

Creating MetDataArray with wrap_longitude=True in _contrail_optical_depth_above_contrail_layer() #219

Open widmka opened 4 months ago

widmka commented 4 months ago

Description I am running into ValueError: Set 'copy=True' when using 'wrap_longitude=True' at https://github.com/contrailcirrus/pycontrails/blob/67b0c8425c3fb4078b8001bbdd9844f2048463d3/pycontrails/models/cocip/radiative_forcing.py#L1106 ,since copy=False... Is this intended and does it indicate a problem with my input? Or could I set copy=wrap_longitude as a quick fix?

Details

thabbott commented 4 months ago

This seems like a problem with our code, not with your input. We have some logic on the previous line to figure out whether wrap_longitude should be True or False, but only one of those values is accepted by the MetDataArray constructor....

I'm not sure exactly how you're using pycontrails, but if you're creating a MetDataset and then using it to run CoCiP you should be able to avoid this issue by setting wrap_longitude=True when you create the MetDataset. That way the longitude will already be wrapped by the time CoCiP gets to this line of code. (That won't help, since da is created from CoCiP output and not necessarily on the same grid as your met data.) Yes, I think setting copy=wrap_longitude as a quick fix will work, though it's possible you might see some performance degradation. I'll work on a patch on our end too, though. Thanks for bringing the issue to our attention!