diff --git a/Gemfile.lock b/Gemfile.lock index d500c3d..771e3e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -285,7 +285,7 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.56.1) + rubocop (1.56.2) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -356,7 +356,7 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.4.2) - webmock (3.18.1) + webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 5f12718..5957910 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -606,7 +606,7 @@ div .success { .map-container { margin-bottom: 1em; - padding: 0 20px; + // padding: 0 20px; @media #{$small-only} { padding: 0; @@ -614,19 +614,20 @@ div .success { } .map-form { - padding: 10px; + padding: 10px 10px 5px 10px; border: 1px solid $form-border-color; border-radius: 5px; background: $map-form-bg-color; - flex: 1 1 auto; -} - -.form-row { - margin-bottom: 1em; + margin-bottom: 10px; } -.form-row:last-child { - margin-bottom: 0; +.map-form-row { + line-height: 20px; + margin-bottom: 5px; + display: flex; + flex-wrap: wrap; + flex-direction: row; + gap: 5px 15px; } .grey { diff --git a/app/controllers/subscribers_controller.rb b/app/controllers/subscribers_controller.rb index 29a0673..00672cd 100644 --- a/app/controllers/subscribers_controller.rb +++ b/app/controllers/subscribers_controller.rb @@ -21,7 +21,7 @@ class SubscribersController < ApplicationController def index # only show the index page when logged out - return redirect_to(action: :manage) unless @subscriber.nil? + redirect_to(action: :manage) unless @subscriber.nil? end def new @@ -151,7 +151,7 @@ def create # confirm email def confirm @subscriber = Subscriber.find(params[:id]) - return redirect_to action: :manage if @subscriber.is_confirmed? + redirect_to action: :manage if @subscriber.is_confirmed? end # handle link from confirmation email @@ -353,7 +353,7 @@ def disable_subscription private def require_session - return reject("You must be logged in to perform this action.") if session[:subscriber].nil? + reject("You must be logged in to perform this action.") if session[:subscriber].nil? end def fix_email diff --git a/app/controllers/weather_controller.rb b/app/controllers/weather_controller.rb index 2cbe64d..6f3b02a 100644 --- a/app/controllers/weather_controller.rb +++ b/app/controllers/weather_controller.rb @@ -11,12 +11,15 @@ def et parse_cumulative_params @units = params[:units].presence || "in" @unit_opts = ["in", "mm"] + @cum_stat_opts = ["sum", "avg", "min", "max"] + @stat = params[:stat].presence || @cum_stat_opts[0] @et_methods = ["classic", "adjusted"] @et_method = params[:et_method].presence || "classic" @wi_only = params[:wi_only] == "true" @map_opts = { date: @date, start_date: @start_date, + stat: @start_date ? @stat : nil, units: @units, extent: @wi_only ? "wi" : nil }.compact @@ -53,10 +56,13 @@ def insol parse_cumulative_params @units = params[:units].presence || "MJ" @unit_opts = ["MJ", "KWh"] + @cum_stat_opts = ["sum", "avg", "min", "max"] + @stat = params[:stat].presence || @cum_stat_opts[0] @wi_only = params[:wi_only] == "true" @map_opts = { date: @date, start_date: @start_date, + stat: @start_date ? @stat : nil, units: @units, extent: @wi_only ? "wi" : nil }.compact @@ -82,7 +88,8 @@ def weather @unit_opts = ["F", "C"] @units = params[:units].presence || @unit_opts[0] @stat_opts = ["avg", "min", "max"] - @stat = params[:stat].presence || @stat_opts[0] + @cum_stat_opts = @stat_opts + @stat = params[:stat].presence || (@start_date ? @cum_stat_opts[0] : @stat_opts[0]) @temp_selector = true @wi_only = params[:wi_only] == "true" @map_opts = { @@ -113,10 +120,13 @@ def precip parse_cumulative_params @units = params[:units].presence || "in" @unit_opts = ["mm", "in"] + @cum_stat_opts = ["sum", "avg", "max"] + @stat = params[:stat].presence || @cum_stat_opts[0] @wi_only = params[:wi_only] == "true" @map_opts = { date: @date, start_date: @start_date, + stat: @start_date ? @stat : nil, units: @units, extent: @wi_only ? "wi" : nil }.compact diff --git a/app/models/t403.rb b/app/models/t403.rb index 6119c63..2edb6a0 100644 --- a/app/models/t403.rb +++ b/app/models/t403.rb @@ -6,7 +6,7 @@ class T403 < ApplicationRecord def self.description "Pre-2000 Half-Hourly Weather and Soil" end - + def self.attr_human_readables [ ["date", "Date"], diff --git a/app/views/weather/_map_form__browse.html.erb b/app/views/weather/_map_form__browse.html.erb index bebda46..99ecb7c 100644 --- a/app/views/weather/_map_form__browse.html.erb +++ b/app/views/weather/_map_form__browse.html.erb @@ -1,50 +1,49 @@ -
- Browse single-day maps: -
-
+
+
+
<%= form_tag do %> - Change date: -   - <% if @date < Date.current - 2.days %> -   - <% end %> - <% if @date < Date.yesterday %> - - <% end %> - + Browse daily maps: + + + <%= hidden_field_tag :units, @units %> <% end %>
-
+ +
<%= form_tag do %> <%= hidden_field_tag :units, @units %> Or enter a specific date: <%= text_field_tag :date %> <%= submit_tag "Go" %> <% end %>
+
-
- <%= form_tag do %> - <%= hidden_field_tag :date, @date %> - <% if @unit_opts %> - - Units: - <% @unit_opts.each do |unit| %> -   - <% end %> - - <% end %> + <%= form_tag do %> +
+ <%= hidden_field_tag :date, @date %> + +
- <% if @stat_opts %> -

+

+ + <% if @unit_opts %> +
+ Units: + <% @unit_opts.each do |unit| %> +   + <% end %> +
+ <% end %> + + <% if @stat_opts %> +
Summary statistic: <% @stat_opts.each do |stat| %>   <% end %> -

- <% end %> - +
<% end %>
-
+ <% end %>
diff --git a/app/views/weather/_map_form__cumulative.html.erb b/app/views/weather/_map_form__cumulative.html.erb index ba7cd10..980a849 100644 --- a/app/views/weather/_map_form__cumulative.html.erb +++ b/app/views/weather/_map_form__cumulative.html.erb @@ -2,53 +2,60 @@ Generate cumulative map:
<%= form_tag do %> -
- - -
+ <%= hidden_field_tag :cumulative, true %> + +
+
+ + +
-
<% if @unit_opts %> - +
Units: <% @unit_opts.each do |unit| %>   <% end %> - +
+ <% end %> + +
+ +
+ + <% if @cum_stat_opts %> +
+ Summary statistic: + <% @cum_stat_opts.each do |stat| %> +   + <% end %> +
<% end %> -
- <% if @stat_opts %> -
- Summary statistic: - <% @stat_opts.each do |stat| %> -   - <% end %> +
+
+ <%= submit_tag "Get cumulative map", id: "submit", class: "submit" %>
- <% end %> - - <%= hidden_field_tag :cumulative, true %> - - <%= submit_tag "Get cumulative map", id: "submit", class: "submit" %> +
<% end %>
diff --git a/app/views/weather/_map_heading.html.erb b/app/views/weather/_map_heading.html.erb new file mode 100644 index 0000000..d0b9219 --- /dev/null +++ b/app/views/weather/_map_heading.html.erb @@ -0,0 +1,9 @@ +<% if @start_date %> +

+ Cumulative map for <%= @start_date.strftime("%b %-d, %Y") %> to <%= @date.strftime("%b %-d, %Y") %> (<%= pluralize((@start_date..@date).count, "day") %>) +

+<% else %> +

+ Daily map for <%= @date.strftime("%b %-d, %Y") %> (<%= pluralize((Date.current - @date).to_i, "day") %> ago) +

+<% end %> diff --git a/app/views/weather/et.html.erb b/app/views/weather/et.html.erb index e352371..c5d85c4 100644 --- a/app/views/weather/et.html.erb +++ b/app/views/weather/et.html.erb @@ -18,18 +18,13 @@

For more details on the science behind these products, see Diak et al, "Agricultural Management Decision Aids Driven by Real-Time Satellite Data", Bulletin of the American Meteorological Society 79 (1998): 1345-1355. <%= link_to "Link to article", "https://doi.org/10.1175/1520-0477(1998)079%3C1345:AMDADB%3E2.0.CO;2" %>. <%= link_to "Download PDF", "/Diak-et-al-1998.pdf", target: "_blank" %>.

Daily evapotranspiration maps in the default units are already rendered by our server and can be browsed quickly. Changing the units or using the cumulative map tool below will take around 10 seconds to render the image

-<% if @start_date %> -

Cumulative evapotranspiration map for <%= @start_date.strftime("%b %-d") %> to <%= @date.strftime("%b %-d") %> (<%= pluralize((@start_date..@date).count, "day") %>)

-<% else %> -

Evapotranspiration map for <%= @date.strftime("%b %-d") %> (<%= pluralize((Date.current - @date).to_i, "day") %> ago)

-<% end %> - +<%= render partial: "map_heading" %> +<%= render partial: "map_form__browse" %> <%= render_async url_for(action: :map_image), method: "POST", data: { endpoint: @endpoint, query: @map_opts, - caption: "Note: Single-day map color scale is based on min/max values for the entire year." }.to_json do %> <%= render layout: "partials/loading" do %>

Please wait, loading map may take up to 10 seconds...

@@ -41,18 +36,15 @@ <% end %> <% end %> -
- <%= render partial: "map_form__browse" %> - <%= render partial: "map_form__cumulative" %> -
+<%= render partial: "map_form__cumulative" %> -

Download evapotranspiration data grid for <%= @date.strftime("%b %-d, %Y") %>

+

Download evapotranspiration data grid for <%= @date.strftime("%b %-d, %Y") %>

  • <%= link_to "Download entire grid (standard calculation method)", action: :et, format: :csv, params: {date: @date} %>
  • <%= link_to "Download entire grid (new adjusted calculation method)", action: :et, format: :csv, params: {date: @date, et_method: "adjusted"} %>
-

Get evapotranspiration data for a single location

+

Get evapotranspiration data for a single location

Note: You can click on the map to set the latitude and longitude. The 'adjusted' ET calculation method uses new coefficients under investigation by Ankur Desai and Ammara Talib at the UW Atmospheric and Oceanic Sciences department. The adjusted method will result in slightly lower ET values that may reflect real-world conditions in Wisconsin better than the old method.
diff --git a/app/views/weather/insol.html.erb b/app/views/weather/insol.html.erb index c7ac838..8a4a1cf 100644 --- a/app/views/weather/insol.html.erb +++ b/app/views/weather/insol.html.erb @@ -18,18 +18,13 @@

The gridded insolation estimates shown below are imported daily from <%= link_to "UW Madison's Space Science Engineering Center", "https://ssec.wisc.edu" %> and provided on this page for easy access. Data is aggregated to a 0.1 decimal degree scale (roughly 8km E/W by 11km N/S in Wisconsin). We use this data, in combination with <%= link_to "gridded daily temperature datasets", action: :weather %>, to generate our <%= link_to "evapotranspiration estimates", action: :et %>.

Daily insolation maps in the default units are already rendered by our server and can be browsed quickly. Changing the units or using the cumulative map tool below will take around 10 seconds to render the image

-<% if @start_date %> -

Cumulative solar insolation map for <%= @start_date.strftime("%b %-d") %> to <%= @date.strftime("%b %-d") %> (<%= pluralize((@start_date..@date).count, "day") %>)

-<% else %> -

Solar insolation map for <%= @date.strftime("%b %-d") %> (<%= pluralize((Date.current - @date).to_i, "day") %> ago)

-<% end %> - +<%= render partial: "map_heading" %> +<%= render partial: "map_form__browse" %> <%= render_async url_for(action: :map_image), method: "POST", data: { endpoint: @endpoint, query: @map_opts, - caption: "Note: Single-day map color scale is based on min/max values for the entire year.", }.to_json do %> <%= render layout: "partials/loading" do %>

Please wait, loading map may take up to 10 seconds...

@@ -41,15 +36,12 @@ <% end %> <% end %> -
- <%= render partial: "map_form__browse" %> - <%= render partial: "map_form__cumulative" %> -
+<%= render partial: "map_form__cumulative" %> -

Download insolation data grid

+

Download insolation data grid

<%= link_to "Download the entire grid of data for #{@date.strftime("%b %-d")} in CSV format", action: :insol, format: :csv, params: { date: @date } %>.

-

Get insolation data for a single location

+

Get insolation data for a single location

Choose a location and date range then click "Get Data Series". Daily insolation data will be displayed in units of Mj and kWh. Note: You can click on the map to set the latitude and longitude to within half a degree.

<%= render partial: "partials/grid_selector", locals: { target: url_for(action: :insol_data) } %>
diff --git a/app/views/weather/precip.html.erb b/app/views/weather/precip.html.erb index e59a4cf..7a6c637 100644 --- a/app/views/weather/precip.html.erb +++ b/app/views/weather/precip.html.erb @@ -17,18 +17,13 @@

Use this page to access gridded precipitation data for the upper Midwest. This data is collected daily from NOAA datasets, which are generated from a combination of real-world observations and computer modeling. Data is aggregated to a 0.1 decimal degree scale (roughly 8km E/W by 11km N/S in Wisconsin). Precpitation can be highly localized, so these data may not completely match observations from rain gauges or weather stations, but should be relatively close. Consider checking <%= link_to "weather.gov", "https://www.weather.gov", target: "_blank" %> or <%= link_to "wunderground.com", "https://www.wunderground.com", target: "_blank" %> for weather/precipitation history or forecasts from an individual weather station.

Daily maps in the default units are already rendered by our server and can be browsed quickly. Changing units or using the cumulative map tool below will take around 10 seconds to render the image.

-<% if @start_date %> -

Cumulative precipitation map for <%= @start_date.strftime("%b %-d") %> to <%= @date.strftime("%b %-d") %> (<%= pluralize((@start_date..@date).count, "day") %>)

-<% else %> -

Precipitation map for <%= @date.strftime("%b %-d") %> (<%= pluralize((Date.current - @date).to_i, "day") %> ago)

-<% end %> - +<%= render partial: "map_heading" %> +<%= render partial: "map_form__browse" %> <%= render_async url_for(action: :map_image), method: "POST", data: { endpoint: @endpoint, query: @map_opts, - caption: "Note: Map color scale is based on min/max daily precipitation across region. Precipitation data is not available for Canada from our data source (NOAA)." }.to_json do %> <%= render layout: "partials/loading" do %>

Please wait, loading map may take up to 10 seconds...

@@ -40,15 +35,12 @@ <% end %> <% end %> -
- <%= render partial: "map_form__browse" %> - <%= render partial: "map_form__cumulative" %> -
+<%= render partial: "map_form__cumulative" %> -

Download data grid as csv

+

Download data grid as csv

<%= link_to "Download the entire grid of data for #{@date.strftime("%b %-d")} in CSV format", action: :precip, format: :csv, params: { date: @date } %>.

-

Get data for a single location

+

Get data for a single location

Choose a location and date range then click "Get Data Series". Daily and cumulative precipitation will be displayed in mm and inches. Note: you can click on the map or click the "Get my location" button to set the lat/long.

<%= render partial: "partials/grid_selector", locals: { target: url_for(action: :precip_data) } %>
diff --git a/app/views/weather/weather.html.erb b/app/views/weather/weather.html.erb index badc70f..78d0f17 100644 --- a/app/views/weather/weather.html.erb +++ b/app/views/weather/weather.html.erb @@ -17,8 +17,8 @@

This gridded weather data is imported daily from the <%= link_to "National Oceanic and Atmospheric Administration", "https://www.nco.ncep.noaa.gov/pmb/products/rtma/" %> and includes air temperatures and dew points. From these data we compute vapor pressure and relative humidity. The map below shows mean daily air temperature, but all weather parameters may be viewed by clicking on the map or selecting a specific Latitude/Longitude and clicking 'Get Data Series' in the box below. Use the buttons above the map to view a different date.

Daily maps in the default units are already rendered by our server and can be browsed quickly. Changing units or using the cumulative map tool below will take around 10 seconds to render the image.

-

Mean air temperature map for <%= @date.strftime("%b %-d") %> (<%= pluralize((Date.current - @date).to_i, "day") %> ago)

- +<%= render partial: "map_heading" %> +<%= render partial: "map_form__browse" %> <%= render_async url_for(action: :map_image), method: "POST", data: { @@ -32,7 +32,6 @@ <% end %>
- <%= render partial: "map_form__browse" %> <%= render partial: "map_form__cumulative" %>