@@ -31,15 +31,13 @@ class JRADownloader(URLDownloader):
3131 1.25 : 'll125'
3232 }
3333
34- home = "https://thredds.rda .ucar.edu/thredds/fileServer/files/g/d640000 /"
34+ home = "https://tds.gdex .ucar.edu/thredds/"
3535
36-
3736 available_agg_methods = ['mean' , 'max' , 'min' , 'sum' ]
38-
3937 available_products : dict = {
4038 "jra-3q" : {
41- "url_blank" : home + "{dataset}/{month.start:%Y%m}/jra3q.{dataset}.{var_code}.{var_name}-{grid_code}.{month.start:%Y%m%d}00_{month.end:%Y%m%d}{end_time}.nc" ,
42- "data_list" : "https://thredds.rda.ucar.edu/thredds/ catalog/files/g/d640000/{dataset}/catalog.html"
39+ "url_blank" : home + "dodsC/files/g/d640000/ {dataset}/{month.start:%Y%m}/jra3q.{dataset}.{var_code}.{var_name}-{grid_code}.{month.start:%Y%m%d}00_{month.end:%Y%m%d}{end_time}.nc" ,
40+ "data_list" : home + " catalog/files/g/d640000/{dataset}/catalog.html"
4341 }
4442 }
4543
@@ -62,6 +60,8 @@ class JRADownloader(URLDownloader):
6260 }
6361 }
6462
63+ cached_data = None
64+
6565 def __init__ (self , product : str ) -> None :
6666 self .set_product (product )
6767 super ().__init__ (self .url_blank , protocol = 'http' )
@@ -143,11 +143,10 @@ def _get_data_ts(self,
143143
144144 this_var = self .variables [self .variable ]
145145 this_month = ts .Month (timestep .year , timestep .month )
146- tmp_file_nc = f'temp_{ self .product } { this_month .year } { this_month .month } .nc'
147146
148- # check if the file is not already downloaded in the tmp_path
149- tmp_destination = os . path . join ( tmp_path , tmp_file_nc )
150- if not os . path . exists ( tmp_destination ) :
147+ if self . cached_data is not None and this_month in self . cached_data :
148+ raw_data = self . cached_data [ this_month ]
149+ else :
151150 tags = {
152151 'dataset' : this_var ['dataset' ],
153152 'var_code' : this_var ['var_code' ],
@@ -156,18 +155,13 @@ def _get_data_ts(self,
156155 'month' : this_month ,
157156 'end_time' : this_var ['end_time' ]
158157 }
159- # download the file
160- self .download (tmp_destination , min_size = 2000 , missing_action = 'warning' , ** tags )
161-
162- # once we download a month, we can delete the previous month
163- prev_month = this_month - 1
164- prev_file = f'temp_{ self .product } { prev_month .year } { prev_month .month } .nc'
165- prev_file = os .path .join (tmp_path , prev_file )
166- if os .path .exists (prev_file ):
167- os .remove (prev_file )
158+
159+ # open the monthly file
160+ url = self .format_url (** tags )
161+ raw_data = xr .open_dataset (url , engine = 'netcdf4' )
162+ self .cached_data = {this_month : raw_data }
168163
169- # open the file
170- raw_data = xr .open_dataset (tmp_destination , engine = 'netcdf4' )
164+ # select the variable
171165 vardata = raw_data [f"{ this_var ['var_name' ]} -{ self .grid_codes [self .resolution ]} " ]
172166
173167 # only select the relevant time range
0 commit comments