Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
acbe61c
initial commit, set up new route in app and add new WCPS functions + …
Joshdpaul Oct 21, 2025
c17a5b9
sketch all routes
Joshdpaul Oct 21, 2025
195e54e
begin validation routines
Joshdpaul Oct 21, 2025
ccb3ff9
add async fetch count_days function
Joshdpaul Oct 22, 2025
cd866e0
working count_days route
Joshdpaul Oct 22, 2025
46b6248
finish fetching and post-processing functions
Joshdpaul Oct 22, 2025
f0c8762
replace errors with templates
Joshdpaul Oct 22, 2025
062e484
add more notes
Joshdpaul Oct 22, 2025
e083a77
fix typo
Joshdpaul Oct 22, 2025
665472d
change coverage IDs to fetch from 6model avg
Joshdpaul Oct 23, 2025
764f261
add bbox validation and function documentation
Joshdpaul Nov 5, 2025
eeaf452
add point to route url
Joshdpaul Nov 5, 2025
8e95345
set up area fetching functions
Joshdpaul Nov 5, 2025
24f4d7f
bring in zonal stats functions
Joshdpaul Nov 5, 2025
47a87cd
finish area query for count days
Joshdpaul Nov 5, 2025
df9c7eb
finish area queries for stat and rank endpoints
Joshdpaul Nov 6, 2025
2435b8f
add stat note
Joshdpaul Nov 6, 2025
4552f90
start documentation
Joshdpaul Nov 6, 2025
54575a9
more doc
Joshdpaul Nov 6, 2025
621dfde
fix rank rounding
Joshdpaul Nov 6, 2025
20becbf
remove "projected" key in results and replace with scenario; add exam…
Joshdpaul Nov 7, 2025
be260b4
add area query documentation
Joshdpaul Nov 7, 2025
fd06a70
finish doc
Joshdpaul Nov 7, 2025
a8d94b4
Merge branch 'main' into dynamic_indicators_2
Joshdpaul Nov 7, 2025
b2be9cb
Add validation for 'units' parameter in application.py
Joshdpaul Nov 7, 2025
cba06b1
remove "units" and "n" request params from marshmallow validation
Joshdpaul Nov 11, 2025
5120e66
rm print statement
Joshdpaul Nov 11, 2025
303a9a9
improve documentation
Joshdpaul Nov 11, 2025
a3c52cd
fix wrf link
Joshdpaul Nov 11, 2025
28968e3
move validation functions
Joshdpaul Nov 11, 2025
557d1db
refactor validation routines
Joshdpaul Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_service_categories():
("CMIP6", "/cmip6"),
("CMIP6, Downscaled", "/cmip6_downscaled"),
("Climate Indicators", "/indicators"),
("Climate Indicators, Dynamic", "/dynamic_indicators"),
("Climate Protection from Spruce Beetles", "/beetles"),
("Degree Days", "/degree_days"),
("Digital Elevation Models (DEMs)", "/elevation"),
Expand Down
93 changes: 93 additions & 0 deletions generate_requests.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions look simple but there is so much secret-Rasdaman sauce here, awesome work Josh

Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,96 @@ def generate_wcps_describe_coverage_str(cov_id):
"""
query_str = f'for $c in ({cov_id}) return describe($c, "application/json", "outputType=GeneralGridCoverage")'
return quote(query_str)


def construct_get_annual_mmm_stat_wcps_query_string(
coverage,
operator,
start_year,
end_year,
x_coord,
y_coord,
format="application/json",
):
"""
Construct a WCPS query string to compute annual min, mean, or max statistics over a time range.
Note that using an empty string in the operator will return all annual values without aggregation.

Args:
coverage (str): The coverage identifier.
operator (str): The statistical operation to perform ('min', 'max', 'mean', or '' to return all values).
start_year (int): The starting year of the time range.
end_year (int): The ending year of the time range.
Comment thread
Joshdpaul marked this conversation as resolved.
x_coord (float or str): The x-coordinate for the point query.
y_coord (float or str): The y-coordinate for the point query.
format (str): The desired output format (default is "application/json").
Returns:
query_string (str): The constructed WCPS query string.
"""
# convert inputs to strings if not already
x_coord = str(x_coord)
y_coord = str(y_coord)

query_string = quote(
(
f"for $cov in ({coverage}) "
f'let $start_year := "{start_year}", '
f'$end_year := "{end_year}", '
f"$x_coord := {x_coord}, "
f"$y_coord := {y_coord} "
f"return encode( "
f"coverage result "
f"over $pt t($start_year : $end_year) "
f"values {operator} ( $cov[x($x_coord), y($y_coord), ansi($pt : $pt)] ) "
f', "{format}")'
)
)

return query_string


def construct_count_annual_days_above_or_below_threshold_wcps_query_string(
coverage,
operator,
threshold,
start_year,
end_year,
x_coord,
y_coord,
format="application/json",
):
"""
Construct a WCPS query string to count annual days above or below a specified threshold over a time range.
Args:
coverage (str): The coverage identifier.
operator (str): The comparison operator ('>' for above threshold, '<' for below threshold).
threshold (float): The threshold value for comparison.
start_year (int): The starting year of the time range.
end_year (int): The ending year of the time range.
x_coord (float or str): The x-coordinate for the point query.
y_coord (float or str): The y-coordinate for the point query.
format (str): The desired output format (default is "application/json").
Returns:
query_string (str): The constructed WCPS query string.
"""
# convert inputs to strings if not already
threshold = str(threshold)
x_coord = str(x_coord)
y_coord = str(y_coord)

query_string = quote(
(
f"for $cov in ({coverage}) "
f"let $threshold := {threshold}, "
f'$start_year := "{start_year}", '
f'$end_year := "{end_year}", '
f"$x_coord := {x_coord}, "
f"$y_coord := {y_coord} "
f"return encode( "
f"coverage result "
f"over $pt t($start_year : $end_year) "
f"values ( sum($cov[x($x_coord), y($y_coord), ansi($pt : $pt)] {operator} $threshold) ) "
f', "{format}")'
)
)
return query_string
1 change: 1 addition & 0 deletions routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ def enforce_site_offline():
from .cmip6_downscaled import *
from .places import *
from .era5wrf import *
from .dynamic_indicators import *
from .fire_weather import *
Loading
Loading