@@ -82,7 +82,7 @@ def write_ts(fpath,df,meta):
8282
8383des_unit_map = {"µS/cm" :"microS/cm" ,
8484 "µS/cm" :"microS/cm" ,
85- "μS/cm" :"microS/cm" ,
85+ "μS/cm at 25°C " :"microS/cm" ,
8686 "°C" :"deg_c" ,
8787 "°F" :"deg_f" ,"CFS" :"ft^3/s" ,
8888 "ft (MSL)" :"feet" ,"inches" :"inches" ,
@@ -130,11 +130,7 @@ def inventory(program_name, program_id):
130130
131131 results_df = pd .read_csv (open_url_no_ssl_cert_check (url ), sep = '|' ,dtype = {"interval_id" :int ,"aggregate_id" :int ,"station_active" :str },
132132 parse_dates = ["start_date" ,"end_date" ])
133- #print("yo")
134- for (id ,row ) in results_df .loc [results_df .station_id >= 90 ,:].iterrows ():
135- if "chl" in row .analyte_name .lower ():
136- print ("\n " )
137- print (row )
133+
138134 results_df = results_df .loc [results_df .interval_id != 4 ,:] # Not "Visit"
139135 results_df = results_df .loc [results_df .aggregate_id <= 2 ,:] # Not labeled "inst" or "Avg"
140136 #results_df = results_df.loc[results_df.station_active=="Y",:] # Active
@@ -218,23 +214,26 @@ def des_download(stations,dest_dir,start,end=None,param=None,overwrite=False):
218214 'aggregate_name' ,'interval_name' ,
219215 'start_date' ,'end_date' ] ] #
220216
221- # Add subloc column that is translated to "air", "upper" or "lower". If there is only a single subloc (depth) it is marked "default"
217+
218+ # Add subloc column that is translated to "air", "upper" or "lower".
219+ # If there is only a single subloc (depth=1) it is marked "default"
222220 rids ["subloc" ] = rids ["probe_depth" ].apply (_depth_trans ) #"default" # dummy for transform
223221 rids ["nrep" ] = rids .groupby (['station_id' ,'analyte_name' ])["subloc" ].transform ('count' )
224222 rids ["nrepdepth" ] = rids .groupby (['station_id' ,'analyte_name' ,'subloc' ])["subloc" ].transform ('count' )
223+
225224
226- if subloc == ' default' :
225+ if subloc in ( 'all' , ' default') :
227226 # Assume default requests makes sense if all the rid entries are the same
228227 # otherwise we need a direct hit
229- # todo: a better way to handle this would be to link the subloc table and look and see if the station
228+ # todo: a better way to handle this would be to
229+ # link the subloc table and look and see if the station
230230 # has sublocations defined and only use 'default' if it isn't defined.
231231 # Here we hope the client application has done this.
232232 rids .loc [rids .nrep == rids .nrepdepth ,"subloc" ] = "default"
233233 #if not is_unique(rids.subloc):
234234 # raise ValueError(f"Default location requested for a station with multiple sublocations for variable {param}")
235- rids = rids .loc [rids .subloc == subloc ,:]
236-
237- #rids.loc[rids.nrep > rids.nrepdepth,"subloc"] = rids.loc[rids.nrep > rids.nrepdepth,"probe_depth"].str.replace("depth =","").replace("depth=","")
235+ elif subloc != 'all' :
236+ rids = rids .loc [rids .subloc == subloc ,:]
238237
239238
240239 if len (rids ) == 0 :
@@ -276,11 +275,12 @@ def des_download(stations,dest_dir,start,end=None,param=None,overwrite=False):
276275 else :
277276 yearname = f"{ fstart .year } _{ fend .year } "
278277
279-
280- if subloc == "default" : # omit from name
278+ sub = rid .subloc
279+
280+ if sub == "default" : # omit from name
281281 outfname = f"des_{ station } _{ agency_id } _{ paramname } _{ yearname } .csv"
282282 else :
283- outfname = f"des_{ station } @{ subloc } _{ agency_id } _{ paramname } _{ yearname } .csv"
283+ outfname = f"des_{ station } @{ sub } _{ agency_id } _{ paramname } _{ yearname } .csv"
284284 outfname = outfname .lower ()
285285 outfname = outfname .lower ()
286286 path = os .path .join (dest_dir ,outfname )
@@ -348,7 +348,10 @@ def main():
348348 slookup = dstore_config .config_file ("station_dbase" )
349349 vlookup = dstore_config .config_file ("variable_mappings" )
350350 df = process_station_list (stationfile ,param = param ,station_lookup = slookup ,
351- agency_id_col = "agency_id" ,param_lookup = vlookup ,source = 'dwr_des' )
351+ agency_id_col = "agency_id" ,
352+ param_lookup = vlookup ,
353+ source = 'dwr_des' ,
354+ subloc = 'all' )
352355 des_download (df ,destdir ,stime ,etime ,overwrite = overwrite )
353356
354357
0 commit comments