Skip to content

Instantly share code, notes, and snippets.

@u9g
Last active January 26, 2024 14:10
Show Gist options
  • Save u9g/0c962c76f97e17698b7fc2396eff96e6 to your computer and use it in GitHub Desktop.
Save u9g/0c962c76f97e17698b7fc2396eff96e6 to your computer and use it in GitHub Desktop.
# Find data points where temp (2m temp) is >= 90 deg F (32.2 deg C)
Root {
location_id @filter(op: "=", value: "CNTR03")
Datapoints(interval_value: 2, interval_unit: "minute") {
# filters
temperature_fahrenheit @filter(op: ">=", value: 90)
# outputs
time @output
}
}
# Find data points where wind speed (2m and/or 10m) is > 10mph (4.47 m/s)
Root {
location_id @filter(op: "=", value: "CNTR03")
Datapoints(interval_value: 2, interval_unit: "minute") {
# filters
wind_speed_mph @filter(op: ">", value: 10)
# outputs
time @output
}
}
# Find data points where wind gust speed (2m and/or 10m) is > 30 mph (13.41 m/s)
Root {
location_id @filter(op: "=", value: "CNTR03")
Datapoints(interval_value: 2, interval_unit: "minute") {
# filters
wind_gust_speed_mph @filter(op: ">", value: 10)
# outputs
time @output
}
}
# Calculate daily average temperature (2m temp) from 1-minute temperature data
# what does 2m temp mean in this context?
Root {
location_id @filter(op: "=", value: "CNTR03")
Calculated(interval_value: 1, interval_unit: "minute") {
# outputs
avg_temperature_fahrenheit(interval_value: 1, interval_unit: "day") @output
}
}
# Calculate daily maximum temperature (2m temp) from 1-minute temperature data
Root {
location_id @filter(op: "=", value: "CNTR03")
Calculated(interval_value: 1, interval_unit: "minute") {
# outputs
max_temperature_fahrenheit(interval_value: 1, interval_unit: "day") @output
}
}
# Calculate various degree day calculations (heating, cooling, growing degree days) using daily average temperature data
#
# How should this look datawise?
# Calculate monthly maximum temperature (2m temp) from 1-minute temperature data
Root {
location_id @filter(op: "=", value: "CNTR03")
Calculated(interval_value: 1, interval_unit: "minute") {
# outputs
# We could just make 1 the default interval_value and allow omitting it
max_temperature_fahrenheit(interval_value: 1, interval_unit: "month") @output
}
}
# Calculate monthly precipitation sum from 1-minute rainfall data
Root {
location_id @filter(op: "=", value: "CNTR03")
Calculated(interval_value: 1, interval_unit: "minute") {
# outputs
# we could also omit this and just sum over
sum_precipitation(interval_value: 1, interval_unit: "month") @output
}
}
# Calculate annual statistics for all monthly statistics listed above
# just change interval_unit to year?
# Count number of data points where temp (2m temp) is >= 90 deg F (32.2 deg C) over a specified (user-defined? - a day, several days, month, year, etc.) period of time
Root {
location_id @filter(op: "=", value: "CNTR03")
Datapoints(interval_value: 2, interval_unit: "minute") @fold
@transform(op: "count")
@output(name: "count")
{
# filters
temperature_fahrenheit @filter(op: ">=", value: 90)
# outputs
time @output
}
}
# Count number of days where daily rainfall is >= 1.00" (25.4 mm or 2.54 cm) over a specified (user-defined? - several days, month, etc.) period of time
# todo: how to filter how many days?
Root {
location_id @filter(op: "=", value: "CNTR03")
Datapoints(interval_value: 1, interval_unit: "day") @fold
@transform(op: "count")
@output(name: "count")
{
# filters
rainfall_inches @filter(op: ">=", value: 1)
# outputs
time @output
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment