contrailcirrus / pycontrails

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

Sporadic longitude wrapping bug for contrail contrail overlap correction #242

Closed depion closed 1 month ago

depion commented 1 month ago

Description

I did CoCiP trajectory calculations for a global fleet, running into the following exceptions: python_exception.txt

Basically, the error is caused in this line: https://github.com/contrailcirrus/pycontrails/blob/main/pycontrails/models/cocip/radiative_forcing.py#L1106C5-L1106C70

The reason seems to be that for specific settings (flights, meteorology), the spatial_bbox and subsequently the lon_coords https://github.com/contrailcirrus/pycontrails/blob/main/pycontrails/models/cocip/radiative_forcing.py#L1095 https://github.com/contrailcirrus/pycontrails/blob/main/pycontrails/models/cocip/radiative_forcing.py#L1104C5-L1104C16 are by chance such that the flag wrap_longitude is True https://github.com/contrailcirrus/pycontrails/blob/main/pycontrails/models/cocip/radiative_forcing.py#L1105

Details

Steps to Reproduce

  1. ...
  2. ...

Additional Notes

I guess the solution would be to set copy=True or copy=wrap_longitude when creating the MetDataArray.

thabbott commented 1 month ago

This seems like a duplicate of #219--do you agree? If so I'll close this issue (though this is a good reminder to figure out how to squash this bug.)

depion commented 1 month ago

Yes, this is is a duplicate, you are right. Can be closed.