2

I am following this answer to calculate number of hot days in a year (temperature exceeding 35degC) from daily tmax data.

I am using tmax from CHELSA from 2000-2016, and I have crop it based on my bounding-box requirement.

Here are the steps I have done (example using 2001 data - 1 month 1 nc file):

  • Merge monthly data to annual: cdo mergetime chelsa_daily_2001*.nc chelsa_annual_2001.nc
  • Calculate hot days: cdo gec,308.15 chelsa_annual_2001.nc chelsa_hotdays_2001.nc The Chelsa's temperature is in Kelvin, so threshold for hot days is 308.15
  • Sum number of days in a year: cdo yearsum chelsa_hotdays_2001.nc chelsa_hotdays_yearsum_2001.nc

And below is the result and unfortunately not what I expected. img1 img2

Why the number of days is not in integer? Did I missed something in the script?

UPDATE1 (following response from Adrian)

I have installed ncview via homebrew but unfortunately can't open. Got following error:

Note: could not open file /Users/xxx/.ncviewrc for reading
Error: Can't open display:

I try to open the nc output using QGIS, and the result still in float.

qgis

UPDATE2

Ok, I managed to check it using ncdump, and here's the first line that contains the value. Bit confuse, because I tried using 1 year data and the total is more than 365. How did it happen?

ncdump

user97103
  • 235
  • 1
  • 7

1 Answers1

1

I strongly suspect panoply is performing some kind of spatial interpolation on the data on import.

Please take a look at the raw field directly using ncdump like this

ncdump chelsa_hotdays_yearsum_2001.nc | less

(I pipe to less so you can stroll down through the data). Or alternatively you can open the file in ncview and move the cursor over the data and you will see the field values displayed in the dialog box.

ncview chelsa_hotdays_yearsum_2001.nc
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • Thank you Adrian, I try to install ncview but failed. And try open using qgis and the result still in float. See updated question. Do you think the script I wrote is correct? – user97103 Dec 05 '21 at 18:50
  • well the script looks okay, if you run it like that, then chelsa_hotdays_2001.nc must contain only 1 and 0 and the last file integer numbers of days. The QGIS plot doesn't tell you anything, it is simply dividing the range into a set of floating point colors. You need to "see" the raw values somehow, either with ncdump, or you could also read it into python or R for example. It would help if you update your question to let us which system you are on, then we can advise on the install. Or if you are in windows, we can give a 3 line script to print out the contents... But I am sure it is fine – ClimateUnboxed Dec 05 '21 at 21:03
  • I am using macOS 10.5 and managed to use `ncdump chelsa_hotdays_yearsum_2001.nc | less` and did scrolling until the first line that contain a value. You are correct the result is in integers but surprisingly the total more than 365 while I am only use 1 year data. See updated question. – user97103 Dec 06 '21 at 01:06