Changeset 2783 in lmdz_wrf for trunk/tools
- Timestamp:
- Jan 14, 2020, 2:24:25 PM (5 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic.py
r2750 r2783 474 474 475 475 elif oper == 'stations_values': 476 Nvals = 2476 Nvals = 3 477 477 vals = opts.values.split(cS) 478 478 if vals[0] == 'h': … … 486 486 print gen.stations_values.__doc__ 487 487 quit(-1) 488 result = gen.stations_values(vals[0], vals[1] )488 result = gen.stations_values(vals[0], vals[1], vals[2]) 489 489 print gen.numVector_String(result,':') 490 490 -
trunk/tools/generic_tools.py
r2782 r2783 17370 17370 return newlist 17371 17371 17372 def stations_values(stcrit,stval, Nexpctst='all',Notfound=True):17372 def stations_values(stcrit,stval,kfind='strict',Nexpctst='all',Notfound=True): 17373 17373 """ Function to provide information from a given station from one of its values 17374 17374 from ASCII file 'OBStations.csv' 17375 stations_values([stcrit],[stval],[ Nexpctst],[Notfound])17375 stations_values([stcrit],[stval],[kfind],[Nexpctst],[Notfound]) 17376 17376 [stcrit]: name of the criteria from OBStations.csv 17377 17377 one of: 'station_name', 'WMOid', 'longitude', 'lon_deg', 'lon_min', … … 17395 17395 [add2]: additional value 2 17396 17396 [stval]: value of [stcrit] to be matched 17397 [kfind]: type of finding (only valid for string values) 17398 'strict': the value to find must be exactly meet 17399 'partial': the value to find can be partialy meet (present within) 17397 17400 [Nexpctst]: expected quantity of stations to retrieve ('all', default) 17398 17401 'all': all matching entries. It will return a dictionary … … 17405 17408 >>> stations_values('WMOid','87582','all') 17406 17409 {0: ['AEROPARQUE BUENOS AIRES', 87582, 34.566667, 34, 34, 0.0, 58.416667, 58, 17407 17408 17410 25, 0.0, 6.0, u'CAPITAL FEDERAL', u'Argentina', 17411 u'Aeroparque Airport Buenos Aires', ' ', ' ']} 17409 17412 >>> stations_values('WMOid','87582','one') 17410 17413 ['AEROPARQUE BUENOS AIRES', 87582, 34.566667, 34, 34, 0.0, 58.416667, 58, 17411 25, 0.0, 6.0, u'CAPITAL FEDERAL', u'Argentina', 17412 u'Aeroparque Airport Buenos Aires', ' ', ' '] 17414 25, 0.0, 6.0, u'CAPITAL FEDERAL', u'Argentina', 17415 u'Aeroparque Airport Buenos Aires', ' ', ' '] 17416 >>> stations_values('station_name','Carlini','partial','all') 17417 {0: ['BASE Carlini', -99999, -58.6677777778, -58, 40, 4.0, -62.2383333333, -62, 17418 14, 18.0, 10.0, u' Antartic', u' Argentina', u' Base ant\xe1rtica Carlini', 17419 u'-', u'-']} 17413 17420 """ 17414 17421 import subprocess as sub 17415 17422 fname='stations_values' 17423 17424 availkfind = ['strict', 'partial'] 17416 17425 17417 17426 criteriavail = ['station_name', 'WMOid', 'longitude', 'lon_deg', 'lon_min', \ … … 17470 17479 if type(stvalues[icrit]) == type('S') or type(stvalues[icrit]) == \ 17471 17480 type(unicode('S')): 17472 if begend_spaces(stvalues[icrit]) == begend_spaces(stv): 17473 stations[Nst] = stvalues 17474 Nst = Nst + 1 17481 cleanstval = begend_spaces(stvalues[icrit]) 17482 cleanval = begend_spaces(stv) 17483 if kfind == 'strict': 17484 # Strict finding 17485 if cleanstval == cleanval: 17486 stations[Nst] = stvalues 17487 Nst = Nst + 1 17488 elif kfind == 'partial': 17489 # Relaxed finding 17490 if cleanstval.find(cleanval) != -1: 17491 stations[Nst] = stvalues 17492 Nst = Nst + 1 17493 else: 17494 print errormsg 17495 print ' ' + fname + ": kind of finding '" + kfind + \ 17496 "' not avaialble !!" 17497 print ' available ones:', availkfind 17498 quit(-1) 17499 17475 17500 else: 17476 17501 if stvalues[icrit] == stv:
Note: See TracChangeset
for help on using the changeset viewer.