[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #HRU-164778]: Query about compositing on a feature



Hi,

Yes I think I understand. I've written up a brief script to read in data and 
subset around the max IVT value. You'll have to define a bounding box to subset 
the data around the max value. You can then add all of these subsets together. 
Caveat - not sure what happens if your IVT max is too close to the edge of the 
spatial dataset, such that the bounding box could not be placed fully around 
it. The example I wrote is a 5-degree box but that should be easy to change.

import xarray as xr

ivt = xr.open_dataset('IVT_eg.nc')
lh = xr.open_dataset('LH_eg.nc')

lat_max = ivt.IVT.where(ivt.IVT == ivt.IVT.max(), 
drop=True).squeeze().coords['lat']
lon_max = ivt.IVT.where(ivt.IVT == ivt.IVT.max(), 
drop=True).squeeze().coords['lon']

# 5-degree bounding box for LH around IVT max
lh_subset = lh.sel(lat=slice(lat_max-5, lat_max+5), lon=slice(lon_max-5, 
lon_max+5))

Once you've subsetted and added all of your storms together, you should have 
one gridded dataset that can be easily plotted with matplotlib/cartopy.
Hope that helps!
Zach

> Hi,
> I have the data on the same grid but not centered on the same feature, so I
> guess it is compositing the data that I am stuck with.
> For example, I have 2 gridded latent heat datasets (91x89 lat lon) that I
> want to composite, but centered on their respective maximum IVT value (also
> 91x89).
> Does that make sense?
> Is this something that you can help with?
> An example of the gridded data for one case is attached.
> 
> Thanks a lot,
> 
> 
> address@hidden> wrote:
> 
> > Hi!
> >
> > Do you have your data composited already onto a common grid? Or are you
> > looking for help with compositing the data and then plotting?
> >
> > Best,
> > Zach
> >
> > > Hi,
> > > You have been so helpful with all of my previous queries regarding your
> > > online code and I was wondering if you could please help me with
> > something
> > > else?
> > > I am trying to create composite maps centered on a feature, e.g.
> > > storm-centered sea level pressure using several storms. I have not been
> > > able to find the right way to do so yet and wondered if you have any
> > > suggestions?
> > > I have looked for tools in cartopy and matplotlib and have tried using
> > > sunpy (
> > > https://docs.sunpy.org/en/stable/code_ref/map.html#creating-map-objects
> > ).
> > > Any advice would be much appreciated.
> > >
> > > Thanks a lot,
> > >
> > >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: HRU-164778
> > Department: Support Python
> > Priority: Low
> > Status: Closed
> > ===================
> > NOTE: All email exchanges with Unidata User Support are recorded in the
> > Unidata inquiry tracking system and then made publicly available through
> > the web.  If you do not want to have your interactions made available in
> > this way, you must let us know in each email you send to us.
> >


Ticket Details
===================
Ticket ID: HRU-164778
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.