Closed jameshiebert closed 6 years ago
So we check lat/lon and substitute nan
if they come back NULL, but we don't do the same for elevation. Highly likely that this is the problem.
@corviday Would you be able to take on verification that this is the problem and writing a fix for the issue? And keep @faronium in the loop? If my assessment is correct, it should be a one-liner.
FRBC network stations have NULL
elevations, supporting @jameshiebert 's assessment of the issue.
crmp=> SELECT meta_network.network_name, meta_station.station_id, meta_history.station_name, meta_history.lon, meta_history.lat, meta_history.elev
FROM crmp.meta_history, crmp.meta_network, crmp.meta_station
WHERE meta_history.station_id = meta_station.station_id AND meta_network.network_id = meta_station.network_id AND meta_network.network_id = 16;
network_name | station_id | station_name | lon | lat | elev
--------------+------------+------------------------------------+-----------+----------+------
FRBC | 3124 | BERRYMAN POINT CLIMATE | -125.6706 | 49.14833 |
FRBC | 3122 | MARION CREEK NEAR UCLUELET | -125.3175 | 49.20583 |
FRBC | 3112 | ELAHO RIVER NEAR THE MOUTH | -123.4361 | 50.11944 |
FRBC | 3126 | CLANNINICK CREEK AT HEADWATERS | -127.3956 | 50.10222 |
FRBC | 3131 | PUGH CREEK NEAR NAHWITTI LAKE | -127.8831 | 50.735 |
FRBC | 3118 | COTTONWOOD CREEK HEADWATERS | -124.25 | 48.93389 |
FRBC | 3117 | HARRIS CREEK NEAR LAKE COWICHAN | -124.2261 | 48.71833 |
FRBC | 3125 | CYPRE RIVER NEAR GOLD RIVER | -125.8683 | 49.36972 |
FRBC | 3123 | SAND RIVER CLIMATE | -125.4932 | 49.14794 |
FRBC | 3128 | BENSON RIVER ABOVE BENSON LAKE | -127.25 | 50.38 |
FRBC | 3115 | MCALLISTER CREEK AT THOMPSON SOUND | -126.0096 | 50.79689 |
FRBC | 3127 | MCKELVIE CREEK ABOVE INTAKE | -126.6333 | 49.93333 |
FRBC | 3129 | ZEBALLOS RIVER HEADWATERS | -126.83 | 50.14 |
FRBC | 3132 | SIMPSON CREEK NEAR KOPRINO HARBOUR | -127.8431 | 50.51194 |
FRBC | 3120 | PORT RENFREW CLIMATE | -124.4205 | 48.55502 |
FRBC | 3119 | WALBRAN CREEK IN CANYON | -124.6 | 48.64 |
FRBC | 3113 | ICY CREEK NEAR THE MOUTH | -125.6715 | 51.22761 |
FRBC | 3114 | KIPPAN CREEK NEAR THE MOUTH | -126.3584 | 51.06831 |
FRBC | 3116 | RENFREW CREEK NEAR PORT RENFREW | -124.2919 | 48.63694 |
FRBC | 3130 | KLASKISH RIVER | -127.6833 | 50.30833 |
FRBC | 3133 | CAMP CREEK NEAR THE MOUTH | -120.7364 | 52.78389 |
FRBC | 3121 | TOFINO CREEK NEAR THE MOUTH | -125.5806 | 49.24944 |
(22 rows)
There are about a hundred other stations on various networks with defined longitude and latitude but NULL
elevation.
Turns out that this fix actually fails on PostgreSQL databases:
env/local/lib/python2.7/site-packages/pydap/handlers/pcic/__init__.py:109: in create_ini
lat, lon = (sesh.scalar(geom.y), sesh.scalar(geom.x)) if geom else (float('nan'), float('nan'))
env/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py:538: in __bool__
raise TypeError("Boolean value of this clause is not defined")
E TypeError: Boolean value of this clause is not defined
We should convert the tests in the package to use testing.postgresql
and get the fix right.
This request: http://tools.pacificclimate.org/dataportal/data/pcds/agg/?from-date=1870%2F01%2F01&to-date=2017%2F07%2F31&input-polygon=&input-var=&network-name=FRBC&input-freq=&data-format=ascii&cliptodate=cliptodate&download-timeseries=Timeseries
leads to this unhandled exception:
Is it possible that stations without location (either x/y or elevation) metadata are being selected and not guarded against?