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

[python #QTK-781041]: (No Subject)



Hello! Thanks for reaching out.

To accomplish what you've described here, check out xarray's GroupBy and 
timeseries functionality:

  http://xarray.pydata.org/en/stable/user-guide/groupby.html
  
http://xarray.pydata.org/en/stable/user-guide/time-series.html#resampling-and-grouped-operations

For example, I was able to create monthly/yearly means of your data with the 
following,

  import xarray
  ds = xarray.open_dataset('pp2014.nc')

  ds.groupby('time.month').mean()

which gave me the monthly mean value at each latitude/longitude. Or,

  ds.groupby('time.year').mean(...)

which gave me the annual mean value for the entire domain (where the `...` 
tells `mean()` to take the mean across all dimensions.)

I hope this helps! If this isn't what you're looking for or you run into any 
other issues, don't hesitate to reach back out. Thanks!


All the best,

Drew


> I am writing
> to you today with the hope to find hints to my problem. I have attached
> one of my netcdf file. The data contains hourly mean of each month and
> I need to calculate the mean for the whole month and also the year with
> xarray in python. Even trying my best, I cannot get the desired output.



Ticket Details
===================
Ticket ID: QTK-781041
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.