TUW-GEO / ascat

Read and visualize data from the Advanced Scatterometer (ASCAT) on-board the series of Metop satellites
https://ascat.readthedocs.io/
MIT License
23 stars 16 forks source link

Filter swath fnames by location in get_filenames #59

Closed claytharrison closed 7 months ago

claytharrison commented 7 months ago

Also makes SwathFileCollection.get_filenames() a public method rather than private, so the collection can be used to get just filenames without reading any more data than is necessary to filter them. This also gets used when reading data for a date range and saves some time, especially for longer time ranges on small study areas.

import ascat.read_native.ragged_array_ts as rat
swath_source = "/path/to/swaths"
swath_collection = rat.SwathFileCollection.from_product_id(swath_source, "H121_v1.0")

bounds = (45, 50, 10, 20)
dates = (datetime(2020, 12, 1), datetime(2020, 12, 31))
bbox_fnames = swath_collection.get_filenames(dates[0], dates[1], bbox=bounds)

cells = [0, 9, 13]
cell_fnames = swath_collection.get_filenames(cell=cells)

gpis = [0, 1, 2]
gpi_fnames = swath_collection.get_filenames(location_id=gpis)

coords = (47, 15) #(lat, lon)
coord_fnames = swath_collection.get_filenames(coords=coords)

circle = Point(*coords).buffer(3)
geom_fnames = swath_collection.get_filenames(geom=circle)