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

ACCF horizontal resolution parameter #260

Closed jsmretschnig closed 2 weeks ago

jsmretschnig commented 3 weeks ago

Description

CLIMaCCF has a horizontal_resolution parameter which allows to reduce the horizontal resolution to i 0.25 x i 0.25 with i being [1,2,3,...]. That means that aCCFs can be computed with lower resolution than their meteorological input data. However, pycontrails always matches the config parameter with the met data (see https://github.com/contrailcirrus/pycontrails/blob/aa3256c109b860bd386690b993ad461af9fac421/pycontrails/models/accf.py#L234-L245).

Details

Steps to Reproduce

ERA5 reanalysis data is given in 0.25 x 0.25. But I want to compute aCCFs in 0.5 x 0.5.

  1. I configure the pycontrails interface as follows: accf = ACCF(pl, sl, params={"horizontal_resolution": 0.5})
  2. The above mentioned lines of code reset the horizontal resolution parameter to 0.25
  3. I get aCCFs in 0.25 x 0.25

Alternatively: If I remove the above mentioned lines in the code, there is no matching any longer, and I get this: aCCF_merged_in_climaccf_replicate_0 5

The values are correct, but the mapping doesn't apply any longer.

Additional Notes

Informed @Abolfazl-Simorgh as well.

zebengberg commented 2 weeks ago

@jsmretschnig You can control the horizontal resolution of the output by specifying the resolution of the source parameter. For example, you could use something along these lines:

source = MetDataset.from_coords(longitude=[2, 3, 4], latitude=[1, 2, 3], level=[220, 250], time="2024-10-10")
accf = ACCF(pl, sl)
out = accf.eval(source)

I also changed ACCF.eval in the way you're suggesting -- see 2e09aefb3c2a7eebe850b99628e32ebb38c8e417