by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 07 18:30
    coveralls commented #510
  • Aug 07 18:12
    coveralls commented #510
  • Aug 07 18:10
    coveralls commented #510
  • Aug 07 18:10
    coveralls commented #510
  • Aug 07 18:10
    coveralls commented #510
  • Aug 07 18:09
    aulemahal commented #510
  • Aug 07 18:08
    aulemahal commented #510
  • Aug 07 17:57
    aulemahal synchronize #510
  • Aug 07 17:57

    aulemahal on multi-indicator

    Make the changes more backward … (compare)

  • Aug 07 00:57
    coveralls commented #510
  • Aug 07 00:46
    aulemahal review_requested #510
  • Aug 07 00:46
    aulemahal commented #510
  • Aug 07 00:44
    aulemahal edited #510
  • Aug 07 00:41
    coveralls commented #510
  • Aug 07 00:39
    coveralls commented #510
  • Aug 07 00:38
    coveralls commented #510
  • Aug 07 00:38
    coveralls commented #510
  • Aug 07 00:26
    aulemahal synchronize #510
  • Aug 07 00:26

    aulemahal on multi-indicator

    Merge MultiIndicator to Indicat… (compare)

  • Aug 06 20:47
    coveralls commented #518
detomas83
@detomas83
Hello, I´m using xclim to average NCDF files (daily temperature) into yearly mean by using the atmos.tg_mean function. The problem is that the function does not work for leap years. Any help?
David Huard
@huard
Could you post a full example, including the source file ?
detomas83
@detomas83
When u use it in a loop to proccess all the climate projections, for instance:
for file in data_files:
ds = xr.open_dataset(os.path.join(dir_in, file))
ds_2 = xc.atmos.tg_mean(ds.temp)
ds_2.to_netcdf(os.path.join(dir_out, file_out + '.nc'))
the only files I got wrongly are the leap years
detomas83
@detomas83
by the way: import xclim as xc
import xarray as xr
How can I upload some nc files in here so for that u can try?
2016 is a leap year
I just wanted to get the yearly mean values for each nc file, which are daily projections
detomas83
@detomas83
I did solve it by using the xarray instance ds['temp'].mean(dim='time')
But I wanted to use your xclim libraries to get some other indices as well
David Huard
@huard
You get NaNs in the 2016 output because xclim expects 366 days in 2016. If it's model data with always 365 days, you need to specify that in the time encoding using the calendar attribute. If you want to disregard those checks, you can always use xclim.indices.tg_mean, but you'll get no warning if there are missing days.
We had thought at some point to have a version letting you decide which fraction of missing data is acceptable (ie. 2%). This is in the todo list.
detomas83
@detomas83
Thanks, I didn´t realize about it. How can I specify that in the time encoding using the calendar attribute?
detomas83
@detomas83
I would like to use your library for other indices
Trevor James Smith
@Zeitsperre
@detomas83 Which kinds of indices are you most interested in? If you have a few in mind and can point to articles/methods/approaches to calculate them, I encourage you to open an issue with that information.
David Huard
@huard
Look into ds_2.time.encoding. You'll see that the calendar is "standard", which means it expects 366 days on leap years.
detomas83
@detomas83
@huard all right, and how can I change that "standard" to the 365 calendar my data has? How should I write it?
David Huard
@huard
I suppose you would do something like ds.time.encoding.calendar="365_day", save the file, then reopen it.
detomas83
@detomas83
Just by adding ds.encoding['calendar']='365_day' it seems to work, no need to save and reopen again.
Thank you both for the support
David Huard
@huard
Great ! Simpler than I thought. You're welcome !