Is it possible to compute the mean temperature or the mean precipitation amount only for the growing season?
I have two netcdf files, one with the thermal_growing_season_length and the day_of_year_of_growing_season_start
and one with Daily Mean Near-Surface Air Temperature and Daily Precipitation amount.
Lg Manu
dimensions:
x = 575 ;
y = 297 ;
time = UNLIMITED ; // (30 currently)
variables:
double lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude coordinate" ;
lon:units = "degrees_east" ;
lon:_CoordinateAxisType = "Lon" ;
double lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude coordinate" ;
lat:units = "degrees_north" ;
lat:_CoordinateAxisType = "Lat" ;
double time(time) ;
time:standard_name = "time" ;
time:units = "minutes since 1955-01-01 00:00:00" ;
time:calendar = "standard" ;
float thermal_growing_season_length(time, y, x) ;
thermal_growing_season_length:long_name = "Counted are the number of days per calendar year between the first occurrence of at least 6 consecutive days where the daily mean temperature is above 5 degree Celsius and the first occurrence of at least 6 consecutive days after 1st of July where the daily mean temperature is below 5 degree Celsius. The time period should be defined by the bounds of the time coordinate." ;
thermal_growing_season_length:units = "No." ;
thermal_growing_season_length:coordinates = "lon lat" ;
thermal_growing_season_length:_FillValue = -999.f ;
thermal_growing_season_length:missing_value = -999.f ;
float day_of_year_of_growing_season_start(time, y, x) ;
day_of_year_of_growing_season_start:long_name = "Day of year of growing season start. The time period should be defined by the bounds of the time coordinate." ;
day_of_year_of_growing_season_start:units = "No." ;
day_of_year_of_growing_season_start:coordinates = "lon lat" ;
day_of_year_of_growing_season_start:_FillValue = -999.f ;
day_of_year_of_growing_season_start:missing_value = -999.f ;
Hi Manu,
It can be done with ncap2. However, I can't work the problem for you. The specifics are intricate and would consume too much of my time. You need to mask a variable by the contents of another variable with the same rank but different shape, and then perform an average along the time dimension so the masked values are excluded. I suggest you read the manual about ncwa, and then ncap2, and start building a workflow from the examples.
Good luck!
cz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked at the sample files, and I'm afraid I must say nearly the same thing that Charlie has said. Sorry.
Here is a slightly more detailed outline of what I would do:
1) The time variable in the GSL file is "minutes since 1955-01-01 00:00:00". Convert that to match the time in the climate data file ("days since 1961-01-01 12:00:00"). I'd do this with ncap2. Something like this:
ncap2 -s 'time=time*C1+C2' GSL.nc GSL2.nc
(C1 and C2 are constants you need to calculate).
2) Add the GSL data to climate data file, like this:
ncks -A GSL2.nc data.nc
3) Create a mask variable with the same dimensions as the climate data, and set it to 1 if in growing season, _FillValue otherwise. Multiply each climate var by the mask, then average the result. I'd do all this in ncap2. This is the hairy part that would take me some time to code & debug....
Good luck.
Last edit: John 2016-01-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to compute the mean temperature or the mean precipitation amount only for the growing season?
I have two netcdf files, one with the thermal_growing_season_length and the day_of_year_of_growing_season_start
and one with Daily Mean Near-Surface Air Temperature and Daily Precipitation amount.
Lg Manu
dimensions:
x = 575 ;
y = 297 ;
time = UNLIMITED ; // (30 currently)
variables:
double lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude coordinate" ;
lon:units = "degrees_east" ;
lon:_CoordinateAxisType = "Lon" ;
double lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude coordinate" ;
lat:units = "degrees_north" ;
lat:_CoordinateAxisType = "Lat" ;
double time(time) ;
time:standard_name = "time" ;
time:units = "minutes since 1955-01-01 00:00:00" ;
time:calendar = "standard" ;
float thermal_growing_season_length(time, y, x) ;
thermal_growing_season_length:long_name = "Counted are the number of days per calendar year between the first occurrence of at least 6 consecutive days where the daily mean temperature is above 5 degree Celsius and the first occurrence of at least 6 consecutive days after 1st of July where the daily mean temperature is below 5 degree Celsius. The time period should be defined by the bounds of the time coordinate." ;
thermal_growing_season_length:units = "No." ;
thermal_growing_season_length:coordinates = "lon lat" ;
thermal_growing_season_length:_FillValue = -999.f ;
thermal_growing_season_length:missing_value = -999.f ;
float day_of_year_of_growing_season_start(time, y, x) ;
day_of_year_of_growing_season_start:long_name = "Day of year of growing season start. The time period should be defined by the bounds of the time coordinate." ;
day_of_year_of_growing_season_start:units = "No." ;
day_of_year_of_growing_season_start:coordinates = "lon lat" ;
day_of_year_of_growing_season_start:_FillValue = -999.f ;
day_of_year_of_growing_season_start:missing_value = -999.f ;
dimensions:
x = 575 ;
y = 297 ;
time = UNLIMITED ; // (10958 currently)
variables:
double lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude coordinate" ;
lon:units = "degrees_east" ;
lon:_CoordinateAxisType = "Lon" ;
double lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude coordinate" ;
lat:units = "degrees_north" ;
lat:_CoordinateAxisType = "Lat" ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "time" ;
time:units = "days since 1961-01-01 12:00:00" ;
time:calendar = "standard" ;
float tas(time, y, x) ;
tas:standard_name = "air_temperature" ;
tas:long_name = "Daily Mean Near-Surface Air Temperature" ;
tas:units = "Celsius" ;
tas:coordinates = "lon lat" ;
tas:_FillValue = -999.f ;
tas:missing_value = -999.f ;
tas:cell_method = "time: mean" ;
float pr(time, y, x) ;
pr:standard_name = "precipitation_amount" ;
pr:long_name = "Daily Precipitation amount" ;
pr:units = "kg m-2" ;
pr:_FillValue = -999.f ;
pr:cell_method = "time: sum" ;
Hi Manu,
It can be done with ncap2. However, I can't work the problem for you. The specifics are intricate and would consume too much of my time. You need to mask a variable by the contents of another variable with the same rank but different shape, and then perform an average along the time dimension so the masked values are excluded. I suggest you read the manual about ncwa, and then ncap2, and start building a workflow from the examples.
Good luck!
cz
If you attach small samples of your two files, I may be able to help....
Clip out a 10x10 sample like this:
ncks -d lat,0,9 -d lon,0,9 in.nc out.nc
thank you ;-)
I looked at the sample files, and I'm afraid I must say nearly the same thing that Charlie has said. Sorry.
Here is a slightly more detailed outline of what I would do:
1) The time variable in the GSL file is "minutes since 1955-01-01 00:00:00". Convert that to match the time in the climate data file ("days since 1961-01-01 12:00:00"). I'd do this with ncap2. Something like this:
ncap2 -s 'time=time*C1+C2' GSL.nc GSL2.nc
(C1 and C2 are constants you need to calculate).
2) Add the GSL data to climate data file, like this:
ncks -A GSL2.nc data.nc
3) Create a mask variable with the same dimensions as the climate data, and set it to 1 if in growing season, _FillValue otherwise. Multiply each climate var by the mask, then average the result. I'd do all this in ncap2. This is the hairy part that would take me some time to code & debug....
Good luck.
Last edit: John 2016-01-24