climate_indices icon indicating copy to clipboard operation
climate_indices copied to clipboard

Null values exist in some regions of the North

Open yheng0821 opened this issue 10 months ago • 1 comments

Describe the bug

When I use the average temperature to calculate potential evapotranspiration, there are nulls in some areas in the north, even though the average temperature does not have a null in that location

To Reproduce

temperature:https://crudata.uea.ac.uk/cru/data/hrg/cru_ts_4.07/cruts.2304141047.v4.07/tmp/cru_ts4.07.2011.2020.tmp.dat.nc.gz Since the data dimension of the CRU is (time, lat, lon), I performed the following operation:

import numpy as np
import xarray as xr
import netCDF4 as nc
import matplotlib.pyplot as plt

# Original files downloaded from the website
file = xr.open_dataset('cru_ts4.07.2011.2020.tmp.dat.nc.nc')

# Convert the data dimensions to ('lat', 'lon', 'time') and set the units to celsius (original units are degrees Celsius)
file['tmp'].attrs['units'] = 'celsius'
file['tmp'] = file['tmp'].transpose('lat', 'lon', 'time')
file.to_netcdf('tmp_lat_lon_time.nc')

# visualization
tmp = xr.open_dataset('tmp_lat_lon_time.nc')['tmp']
plt.imshow(tmp[::-1, :, 10])

image Currently it looks like there are no exception nulls in the red box

Next, we begin to calculate the pet

process_climate_indices --index pet --periodicity monthly --netcdf_temp tmp_lat_lon_time.nc --var_name_temp tmp --output_file_base out/ --multiprocessing all_but_one

When the calculation is complete, read the pet file and again randomly visualize the values for one day

# visualization of the pet
pet = xr.open_dataset('out/_pet_thornthwaite.nc')['pet_thornthwaite']
plt.imshow(pet[::-1, :, 10])

image

Null values in the same places.

Desktop (please complete the following information):

  • OS: Win1064
  • climate-indices:2.0.0
  • numpy: 1.25.2
  • xarray:2013.1.0
  • matplotlib:3.8.3
  • netCDF4:1.6.5

I notice the CRU lats are [-89.75 -89.25 -88.75 -88.25 ... 88.75 89.25 89.75],lons are [-179.8 -179.2 -178.8 -178.2 ... 178.8 179.2 179.8].I don't understand why there are null values here, could it have something to do with the way pet is calculated?

yheng0821 avatar Apr 04 '24 07:04 yheng0821