ghiggi / gpm_api

Global Precipitation Measurement Mission (GPM) python package to download and analyze data with xarray
https://gpm-api.readthedocs.io
MIT License
46 stars 4 forks source link

How to filter this data with respect to a geopandas dataframe #31

Closed kaushikCanada closed 4 months ago

kaushikCanada commented 5 months ago

I have a shapefile and i need all the EARLY data for the previous 2 days. how do u use this library to do that? i am new to this data so please bear with me.

ghiggi commented 5 months ago

Hey ! Are you speaking about the IMERG Early Run product? in that case you can use the software to download such product over the time period of interest, open it into an xarray Dataset and then perform the geospatial subsetting operations of interest.

import gpm_api
import datetime

product = "IMERG-ER"
product_type = "NRT"
version = 7

start_time = datetime.datetime(2020,7, 22, 0, 1, 11)
end_time = datetime.datetime(2020,7, 22, 0, 23, 5)

gpm_api.download(product=product,
                 product_type=product_type,
                 version=version,
                 n_threads=2,
                 start_time=start_time,
                 end_time=end_time)

  ds = gpm_api.open_dataset(product=product,
                          product_type=product_type,
                          version=version
                          start_time=start_time,
                          end_time=end_time)             

I suggest you to open the shapefile with shapely and then extract the polygon bounds to define an extent to crop the ds. Have a look at this tutorial https://github.com/ghiggi/gpm_api/blob/main/tutorials/tutorial_02_IMERG.ipynb for more info.

kaushikCanada commented 5 months ago

Thank you so much for this input. I shall try it and let you know. Btw amazing library!

On Tue, Jan 30, 2024 at 12:32 PM Gionata Ghiggi @.***> wrote:

Hey ! Are you speaking about the IMERG Early Run product? in that case you can use the software to download such product over the time period of interest, open it into an xarray Dataset and then perform the geospatial subsetting operations of interest.

import gpm_api import datetime

product = "IMERG-ER" product_type = "NRT" version = 7

start_time = datetime.datetime(2020,7, 22, 0, 1, 11) end_time = datetime.datetime(2020,7, 22, 0, 23, 5)

gpm_api.download(product=product, product_type=product_type, version=version, n_threads=2, start_time=start_time, end_time=end_time)

ds = gpm_api.open_dataset(product=product, product_type=product_type, version=version start_time=start_time, end_time=end_time)

I suggest you to open the shapefile with shapely and then extract the polygon bounds to define an extent to crop the ds. Have a look at this tutorial https://github.com/ghiggi/gpm_api/blob/main/tutorials/tutorial_02_IMERG.ipynb for more info.

— Reply to this email directly, view it on GitHub https://github.com/ghiggi/gpm_api/issues/31#issuecomment-1917550556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCDQCNIWEGX27V34D4DQI3YREVCNAVCNFSM6AAAAABCLNVAQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJXGU2TANJVGY . You are receiving this because you authored the thread.Message ID: @.***>