there is my script :
import cdstoolbox as ct
@ct.application(title='Mini Project PILA',
description ='surface spesific humidity')
@ct.output.download()
def calculate_clim():
'''Hitung daily, monthly seasonal, dan annual climatology untuk surface spesific humidity'''
#Retrive atau permintaan akeses data ERA5 Single Levels of Surface spesific humidity
#Retrive data dilakukan setiap 3 bulan dalam satu variabel untuk memenuhi limit akses data
data1= ct.catalogue.retrieve(
'reanalysis-era5-pressure-levels-monthly-means',
{
'product_type':'reanalysis',
'variable': 'spesific_humidity',
'pressure_level': '1000',
'year': list(range(1979, 2020 + 1)),
'month': [
'01','02','03'
],
'day': [
'01', '02', '03', '04', '05', '06',
'07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24',
'25', '26', '27', '28', '29', '30',
'31'
],
'time': list(range(1,23+1)),
'area': [
10, 90, -15,
145,
],
'grid': [0.25, 0.25],
}
)
data2 = ct.catalogue.retrieve(
'reanalysis-era5-pressure-levels-monthly-means',
{
'product_type': 'reanalysis',
'variable': 'spesific_humidity',
'pressure_level': '1000',
'year': list(range(1979, 2020 + 1)),
'month': [
'04','05','06'
],
'day': [
'01', '02', '03', '04', '05', '06',
'07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24',
'25', '26', '27', '28', '29', '30',
'31'
],
'time': list(range(1,23+1)),
'area': [
10, 90, -15,
145,
],
'grid': [0.25, 0.25],
}
)
data3 = ct.catalogue.retrieve(
'reanalysis-era5-pressure-levels-monthly-means',
{
'product_type': 'reanalysis',
'variable': 'spesific_humidity',
'pressure_level': '1000',
'year': list(range(1979, 2020 + 1)),
'month': [
'07','08','09'
],
'day': [
'01', '02', '03', '04', '05', '06',
'07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24',
'25', '26', '27', '28', '29', '30',
'31'
],
'time': list(range(1,23+1)),
'area': [
10, 90, -15,
145,
],
'grid': [0.25, 0.25],
}
)
data4 = ct.catalogue.retrieve(
'reanalysis-era5-pressure-levels-monthly-means',
{
'product_type': 'reanalysis',
'variable': 'spesific_humidity',
'pressure_level': '1000',
'year': list(range(1979, 2020 + 1)),
'month': [
'10','11','12'
],
'day': [
'01', '02', '03', '04', '05', '06',
'07', '08', '09', '10', '11', '12',
'13', '14', '15', '16', '17', '18',
'19', '20', '21', '22', '23', '24',
'25', '26', '27', '28', '29', '30',
'31'
],
'time': list(range(1,23+1)),
'area': [
10, 90, -15,
145,
],
'grid': [0.25, 0.25],
}
)
#Menggabungkan data harian dalam satu array
concat = ct.cube.concat([data1, data2, data3, data4],
dim='time')
print (concat)
#Perata - rataan data harian selama 40 tahun
daily_clim = ct.climate.climatology_mean(
data = concat,
start = '1980',
stop = '2020',
frequency = 'dayofyear'
)
#Perata - rataan data bulanan selama 40 tahun
monthly_clim = ct.climate.climatology_mean(
data = daily_clim,
start = '1980',
stop = '2020',
frequency = 'month'
)
print (monthly_clim)
#Pemilihan data saat DJF selama 40 tahun
seasonal_sel_djf = ct.climate.season_select(
data=concat,
rule = 'month',
start = 12,
stop = 2
)
print("milih djf beres ")
#Perata - rataan data DJF selama 40 tahun
seasonal_clim_djf = ct.cube.average(
data = seasonal_sel_djf,
dim = 'time'
)
print (seasonal_clim_djf)
print ("djf clim berhasil")
#Pemilihan data saat MAM selama 40 tahun
seasonal_sel_mam = ct.climate.season_select(
data=concat,
rule = 'month',
start = 3,
stop = 5
)
print("milih mam beres")
#Perata - rataan data MAM selama 40 tahun
seasonal_clim_mam = ct.cube.average(
data = seasonal_sel_mam,
dim = 'time'
)
print (seasonal_clim_mam)
print ("mam clim sukses")
#Pemilihan data saat JJA selama 40 tahun
seasonal_sel_jja = ct.climate.season_select(
data=concat,
rule = 'month',
start = 6,
stop = 8
)
print("milih jja beres")
#Perata - rataan data JJA selama 40 tahun
seasonal_clim_jja = ct.cube.average(
data = seasonal_sel_jja,
dim = 'time'
)
print (seasonal_clim_jja)
print ("jja clim sukses")
#Pemilihan data saat SON selama 40 tahun
seasonal_sel_son = ct.climate.season_select(
data=concat,
rule = 'month',
start = 9,
stop = 11
)
print("milih son beres")
#Perata - rataan data SON selama 40 tahun
seasonal_clim_son = ct.cube.average(
data = seasonal_sel_son,
dim = 'time'
)
print (seasonal_clim_son)
print ("jja clim sukses")
annual_clim = ct.cube.average(
data = concat,
dim = 'time'
)
print (annual_clim)
return daily_clim
my console says:
Traceback (most recent call last): File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 55, in handle_request result = cached(context.method, proc, context, context.args, context.kwargs) File "/opt/cdstoolbox/cdscompute/cdscompute/caching.py", line 108, in cached result = proc(context, *context.args, **context.kwargs) File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 118, in __call__ return p(*args, **kwargs) File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 59, in __call__ return self.proc(context, *args, **kwargs) File "/home/cds/cdsservices/services/python_service.py", line 38, in execute raise exceptions.InternalError(logging + traceback, '') cdsclient.exceptions.InternalError: Traceback (most recent call last): File "/opt/cdstoolbox/jsonrequest/jsonrequest/requests.py", line 71, in jsonrequestcall resp = coding.encode(req.callable(*req.args, **req.kwargs), register=encoders, **context) File "/opt/cdstoolbox/cdstools/cdstools/season.py", line 377, in climatology_mean return _climatology(data, start=start, stop=stop, frequency=frequency)['{}_climatology_mean'.format(data.name)] File "/opt/cdstoolbox/cdstools/cdstools/season.py", line 129, in _climatology selection = util._groupby(data.sel(time=slice(start, stop)), group='time.' + frequency) File "/usr/local/lib/python3.6/site-packages/xarray/core/dataarray.py", line 1148, in sel **indexers_kwargs, File "/usr/local/lib/python3.6/site-packages/xarray/core/dataset.py", line 2106, in sel self, indexers=indexers, method=method, tolerance=tolerance File "/usr/local/lib/python3.6/site-packages/xarray/core/coordinates.py", line 398, in remap_label_indexers obj, v_indexers, method=method, tolerance=tolerance File "/usr/local/lib/python3.6/site-packages/xarray/core/indexing.py", line 275, in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) File "/usr/local/lib/python3.6/site-packages/xarray/core/indexing.py", line 135, in convert_label_indexer "cannot represent labeled-based slice indexer for dimension " KeyError: "cannot represent labeled-based slice indexer for dimension 'time' with a slice over integer positions; the index is unsorted or non-unique"
in the othe pages said that cant see any 'variable' or 'product_type' but dont understand ? can you help me ?