nationalparkservice / EnvironmentalSetting_Toolkit

Tools supporting the NPS IMD Environmental Setting protocol
Other
3 stars 2 forks source link

Error when findStation() error on station subtype #60

Open llnelson opened 3 years ago

llnelson commented 3 years ago

Test case: bbox request using SEKI returns 4 stations (uids: 425, 2540, 2682, 2439) with 4 or more SIDs. This causes the following error.

Example vanilla request: http://data.rcc-acis.org/StnMeta?bbox=-119.3223,36.02358,-117.8969,37.50525&meta=uid,name,state,climdiv,county,ll,elev,valid_daterange,sids&elems=mint,maxt,avgt,obst,pcpn,snow,snwd,gdd,cdd,hdd&edate=2021-04-01


if (!acisLookup$stationIdType$subtypes[acisLookup$stationIdType$code == : argument is of length zero 
getStationSubtype(unlist(strsplit(sid1[i], " "))[2], substr(sid1[i], 1, 3)) 

In findStation(), see lines starting at 120
llnelson commented 3 years ago

Orginally, thought issue was due to length on SID set. Nope. Caused by a station subtype of '19' which is not included in the ACISLookups.json file in the inst folder.

Error is triggered by this station for SEKI - note the value "3051 19" where 19 is the un-accounted for subtype.

{"valid_daterange": [["2018-08-04", "2021-03-01"], ["2018-08-04", "2021-03-01"], ["2018-08-04", "2021-03-01"], ["2018-06-26", "2021-03-01"], ["2018-08-11", "2020-12-28"], [], [], ["2018-08-04", "2021-03-01"], ["2018-08-04", "2021-03-01"], ["2018-08-04", "2021-03-01"]], "uid": 85815, "ll": [-118.7223, 36.05085], "sids": ["3051 19"], "county": "06107", "state": "CA", "elev": 2429.0, "climdiv": "CA05", "name": "Tule River"}]}

Cannot find documentation of what 19 signifies so will update the ACISLookups.json file to add a record as 'Unknown'.