pytroll / pyresample

Geospatial image resampling in Python
http://pyresample.readthedocs.org
GNU Lesser General Public License v3.0
348 stars 94 forks source link

dump DynamicAreaDefinition to YAML #569

Open gerritholl opened 9 months ago

gerritholl commented 9 months ago

I would like to be able to dump the YAML code for a DynamicAreaDefinition, just like how this is already possible for an AreaDefinition.

Code Sample, a minimal, complete, and verifiable piece of code

# Your code here
from pyresample.area_config import load_area_from_string

ardef_fixed = """nq0002km:
  description: nq0002km
  projection:
    EPSG: 4087
  shape:
    height: 10000
    width: 10000
  area_extent:
    lower_left_xy:
    - -10016827.23100899
    - -10016827.23100899
    upper_right_xy:
    - 10016828.344203897
    - 10016827.23100899
"""

ardef_dyn = """dyn_2km:
  description: dyn_2km
  projection:
    EPSG: 4087
  resolution: 2000
"""

ar1 = load_area_from_string(ardef_fixed)
ar2 = load_area_from_string(ardef_dyn)

print(ar1)
print(ar2)

print(ar1.dump())
print(ar2.dump())

Problem description

Currently, ar1.dump() works, but ar2.dump() does not work.

Expected Output

I expect to reproduce (more or less) the strings for ardef_fixed and ardef_dyn.

Actual Result, Traceback if applicable

Traceback (most recent call last):
  File "/data/gholl/checkouts/protocode/load-dynamic-area.py", line 33, in <module>
    print(ar2.dump())
          ^^^^^^^^
AttributeError: 'DynamicAreaDefinition' object has no attribute 'dump'

Versions of Python, package at hand and relevant dependencies

pyresample main