by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:58
    Zeitsperre commented #479
  • Jul 15 21:24

    aulemahal on adapt-and-impose-xr0.16

    (compare)

  • Jul 15 21:24

    aulemahal on master

    upd history Force xr 0.16 - use infer_freq … Merge branch 'master' into adap… and 5 more (compare)

  • Jul 15 21:24
    aulemahal closed #504
  • Jul 15 21:13
    coveralls commented #504
  • Jul 15 20:56
    coveralls commented #504
  • Jul 15 20:48
    coveralls commented #504
  • Jul 15 20:47
    coveralls commented #504
  • Jul 15 20:46
    coveralls commented #504
  • Jul 15 20:46
    aulemahal closed #479
  • Jul 15 20:46
    aulemahal commented #479
  • Jul 15 20:35
    aulemahal synchronize #504
  • Jul 15 20:35

    aulemahal on adapt-and-impose-xr0.16

    fix docstring (compare)

  • Jul 15 19:19
    coveralls commented #504
  • Jul 15 19:02
    coveralls commented #504
  • Jul 15 18:54
    coveralls commented #504
  • Jul 15 18:53
    coveralls commented #504
  • Jul 15 18:53
    coveralls commented #504
  • Jul 15 18:43
    coveralls commented #500
  • Jul 15 18:30
    aulemahal synchronize #504
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 !