|
45 | 45 | # ICEPYX ATL06
|
46 | 46 | #
|
47 | 47 | def atl06p(ipx_region, parm, asset=icesat2.DEFAULT_ASSET):
|
| 48 | + """ |
| 49 | + create a sliderule atl06p query from an icepyx region |
| 50 | + """ |
48 | 51 |
|
49 | 52 | try:
|
50 | 53 | version = ipx_region.product_version
|
51 | 54 | resources = ipx_region.avail_granules(ids=True)[0]
|
52 | 55 | except:
|
53 | 56 | logger.critical("must supply an icepyx query as region")
|
54 | 57 | return icesat2.__emptyframe()
|
| 58 | + # try to get the subsetting region |
| 59 | + if ipx_region.extent_type in ('bbox','polygon'): |
| 60 | + parm.update('poly', to_region(ipx_region)) |
55 | 61 |
|
56 | 62 | return icesat2.atl06p(parm, asset, version=version, resources=resources)
|
57 | 63 |
|
58 | 64 | #
|
59 | 65 | # ICEPYX ATL03
|
60 | 66 | #
|
61 | 67 | def atl03sp(ipx_region, parm, asset=icesat2.DEFAULT_ASSET):
|
| 68 | + """ |
| 69 | + create a sliderule atl03sp query from an icepyx region |
| 70 | + """ |
62 | 71 |
|
63 | 72 | try:
|
64 | 73 | version = ipx_region.product_version
|
65 | 74 | resources = ipx_region.avail_granules(ids=True)[0]
|
66 | 75 | except:
|
67 | 76 | logger.critical("must supply an icepyx query as region")
|
68 | 77 | return icesat2.__emptyframe()
|
| 78 | + # try to get the subsetting region |
| 79 | + if ipx_region.extent_type in ('bbox','polygon'): |
| 80 | + parm.update('poly', to_region(ipx_region)) |
69 | 81 |
|
70 | 82 | return icesat2.atl03sp(parm, asset, version=version, resources=resources)
|
| 83 | + |
| 84 | +def to_region(ipx_region): |
| 85 | + """ |
| 86 | + extract subsetting extents from an icepyx region |
| 87 | + """ |
| 88 | + if (ipx_region.extent_type == 'bbox'): |
| 89 | + bbox = ipx_region.spatial_extent[1] |
| 90 | + poly = [dict(lon=bbox[1], lat=bbox[2]), |
| 91 | + dict(lon=bbox[3], lat=bbox[2]), |
| 92 | + dict(lon=bbox[3], lat=bbox[4]), |
| 93 | + dict(lon=bbox[1], lat=bbox[4]), |
| 94 | + dict(lon=bbox[1], lat=bbox[2])] |
| 95 | + elif (ipx_region.extent_type == 'polygon'): |
| 96 | + poly = [dict(lon=ln,lat=lt) for ln,lt in zip(*ipx_region.spatial_extent[1])] |
| 97 | + return poly |
0 commit comments