Skip to content

Commit

Permalink
Merge branch 'hotfix/1.33.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadain committed Oct 20, 2022
2 parents 3539001 + 97a33e8 commit 01d47b8
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 50 deletions.
2 changes: 1 addition & 1 deletion deployment/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ postgresql_support_repository_channel: "main"
postgresql_support_libpq_version: "13.*.pgdg20.04+1"
postgresql_support_psycopg2_version: "2.8.*"
postgis_version: "3"
postgis_package_version: "3.2*pgdg20.04+1"
postgis_package_version: "3.3*pgdg20.04+1"

daemontools_version: "1:0.76-7"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install Firefox for UI tests
apt: pkg="firefox=9*" state=present
apt: pkg="firefox" state=present

- name: Install Xvfb for JavaScript tests
apt: pkg="xvfb=2:1.20.*" state=present
16 changes: 8 additions & 8 deletions src/mmw/apps/geoprocessing_api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@
)

nlcd_override_allowed_values = '", "'.join([
'nlcd-2019-30m-epsg5070-512-byte',
'nlcd-2016-30m-epsg5070-512-byte',
'nlcd-2011-30m-epsg5070-512-byte',
'nlcd-2006-30m-epsg5070-512-byte',
'nlcd-2001-30m-epsg5070-512-byte',
'nlcd-2019-30m-epsg5070-512-uint8raw',
'nlcd-2016-30m-epsg5070-512-uint8raw',
'nlcd-2011-30m-epsg5070-512-uint8raw',
'nlcd-2006-30m-epsg5070-512-uint8raw',
'nlcd-2001-30m-epsg5070-512-uint8raw',
'nlcd-2011-30m-epsg5070-512-int8',
])
LAYER_OVERRIDES = Schema(
Expand All @@ -209,12 +209,12 @@
properties={
'__LAND__': Schema(
type=TYPE_STRING,
example='nlcd-2019-30m-epsg5070-512-byte',
example='nlcd-2019-30m-epsg5070-512-uint8raw',
description='The NLCD layer to use. Valid options are: '
f'"{nlcd_override_allowed_values}". All "-byte" '
f'"{nlcd_override_allowed_values}". All "-uint8raw" '
'layers are from the NLCD19 product. The "-int8" '
'layer is from the NLCD11 product. The default value '
'is NLCD19 2019 "nlcd-2019-30m-epsg5070-512-byte".',
'is NLCD19 2019 "nlcd-2019-30m-epsg5070-512-uint8raw".'
),
'__STREAMS__': Schema(
type=TYPE_STRING,
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/geoprocessing_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def start_analyze_land(request, nlcd_year, format=None):

nlcd, year = nlcd_year.split('_')
if nlcd == '2019' and year in ['2019', '2016', '2011', '2006', '2001']:
layer_overrides['__LAND__'] = f'nlcd-{year}-30m-epsg5070-512-byte'
layer_overrides['__LAND__'] = f'nlcd-{year}-30m-epsg5070-512-uint8raw'

return start_celery_job([
geoprocessing.run.s('nlcd_ara', geop_input, wkaoi,
Expand Down
1 change: 1 addition & 0 deletions src/mmw/apps/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def get_client_settings(request):
'stream_layers': create_layer_config_with_urls('stream'),
'nhd_perimeter': settings.NHD_REGION2_PERIMETER,
'conus_perimeter': settings.CONUS_PERIMETER,
'drwi_simple_perimeter': settings.DRWI_SIMPLE_PERIMETER_JSON,
'draw_tools': settings.DRAW_TOOLS,
'map_controls': settings.MAP_CONTROLS,
'vizer_urls': settings.VIZER_URLS,
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/modeling/calcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_layer_value(layer, layer_overrides=dict):
If the default config is something like:
{
'__LAND__': 'nlcd-2019-30m-epsg5070-512-byte',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-uint8raw',
'__SOIL__': 'ssurgo-hydro-groups-30m-epsg5070-512-int8',
'__STREAMS__': 'nhd',
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.2.13 on 2022-10-17 13:47

from django.db import migrations


def clear_nlcd2019_gwlfe_results(apps, schema_editor):
"""
Clear the results for all scenarios belonging to GWLF-E projects made after
the release of 1.33.0, which had incorrectly aligned NLCD19 2019 on
2022-01-17:
https://github.com/WikiWatershed/model-my-watershed/releases/tag/1.33.0
These results will be recalculated with the correclty aligned NLCD19 values
when these projects are accessed again.
"""
Project = apps.get_model('modeling', 'Project')
Scenario = apps.get_model('modeling', 'Scenario')

Project.objects.filter(
model_package='gwlfe',
created_at__gte='2022-01-17',
).update(
gis_data=None,
mapshed_job_uuid=None,
subbasin_mapshed_job_uuid=None,
)

Scenario.objects.filter(
project__model_package='gwlfe',
project__created_at__gte='2022-01-17',
).update(
results='[]',
modification_hash='',
)


class Migration(migrations.Migration):

dependencies = [
('modeling', '0040_clear_nlcd2019_tr55_results'),
]

operations = [
migrations.RunPython(clear_nlcd2019_gwlfe_results),
]
4 changes: 4 additions & 0 deletions src/mmw/apps/modeling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def __unicode__(self):
def in_drb(self):
return self.area_of_interest.within(settings.DRB_SIMPLE_PERIMETER)

@property
def in_drwi(self):
return self.area_of_interest.within(settings.DRWI_SIMPLE_PERIMETER)


class WeatherType:

Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/modeling/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Meta:
'scenarios', 'model_package', 'created_at', 'modified_at',
'is_private', 'is_activity', 'gis_data', 'mapshed_job_uuid',
'subbasin_mapshed_job_uuid', 'wkaoi', 'user', 'hydroshare',
'in_drb', 'layer_overrides')
'in_drb', 'in_drwi', 'layer_overrides')

user = UserSerializer(default=serializers.CurrentUserDefault())
gis_data = JsonField(required=False, allow_null=True)
Expand Down
11 changes: 7 additions & 4 deletions src/mmw/apps/modeling/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ def project_weather(request, proj_id, category):
return Response({'errors': ['Invalid category specified.']},
status=status.HTTP_400_BAD_REQUEST)

# This applies to all current weather categories. If in the future there
# are categories to which it doesn't apply, this will have to be further
# qualified.
if not project.in_drb:
if category == 'NASA_NLDAS_2000_2019' and not project.in_drwi:
return Response({'errors': ['Only supported within'
' Delware River Watershed Initiative.']},
status=status.HTTP_400_BAD_REQUEST)

if category in ['RCP45_2080_2099', 'RCP85_2080_2099'] \
and not project.in_drb:
return Response({'errors': ['Only supported within'
' Delware River Basin.']},
status=status.HTTP_400_BAD_REQUEST)
Expand Down
22 changes: 13 additions & 9 deletions src/mmw/js/src/analyze/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var AnalyzeTaskModel = coreModels.TaskModel.extend({
token: settings.get('api_token'),
// Include this task in Catalog Search results (ie, BigCZ)
enabledForCatalogMode: false,
lazy: false, // Will not execute immediately if lazy is true
}, coreModels.TaskModel.prototype.defaults
),

Expand Down Expand Up @@ -167,11 +168,13 @@ var AnalyzeTaskGroupModel = Backbone.Model.extend({
/**
* Returns a promise that completes when Analysis has been fetched. If
* fetching is not required, returns an immediatley resolved promise.
* Skips lazy analyses, which should be triggered explicitly on the task.
*/
fetchAnalysisIfNeeded: function() {
var taskAnalysisFetches = this.get('tasks').map(function(t) {
return t.fetchAnalysisIfNeeded();
});
var taskAnalysisFetches =
this.get('tasks')
.filter(function(t) { return !t.get('lazy'); })
.map(function(t) { return t.fetchAnalysisIfNeeded(); });

return $.when.apply($, taskAnalysisFetches);
},
Expand Down Expand Up @@ -220,18 +223,19 @@ function createAnalyzeTaskGroupCollection(aoi, wkaoi) {
displayName: "Streams",
tasks: [
{
name: "streams_nhdhr",
displayName: "NHD High Resolution Streams",
name: "streams_nhd",
displayName: "NHD Medium Resolution Streams",
area_of_interest: aoi,
wkaoi: wkaoi,
taskName: "analyze/streams/nhdhr"
taskName: "analyze/streams/nhd",
},
{
name: "streams_nhd",
displayName: "NHD Medium Resolution Streams",
name: "streams_nhdhr",
displayName: "NHD High Resolution Streams",
area_of_interest: aoi,
wkaoi: wkaoi,
taskName: "analyze/streams/nhd"
taskName: "analyze/streams/nhdhr",
lazy: true,
},
]
},
Expand Down
1 change: 1 addition & 0 deletions src/mmw/js/src/analyze/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,7 @@ var TaskSelectorView = Marionette.ItemView.extend({
updateTask: function() {
var taskName = this.ui.selector.val();
this.model.setActiveTask(taskName);
this.model.get('activeTask').fetchAnalysisIfNeeded();
}
});

Expand Down
23 changes: 17 additions & 6 deletions src/mmw/js/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,27 @@ var utils = {
}
},

// Check if a geom is completely within DRB_SIMPLE_PERIMETER
isInDrb: _.memoize(function(geom) {
var layers = settings.get('stream_layers'),
drb = _.find(layers, {code: 'drb_streams_v2'}).perimeter,
coordCount = this.coordinates(geom).length,
intersection = intersect(geom, drb),
_containedIn: function(perimeter, geom) {
var coordCount = this.coordinates(geom).length,
intersection = intersect(geom, perimeter),
intersectionCount = intersection &&
this.coordinates(intersection.geometry).length;

return intersection && coordCount === intersectionCount;
},

isInDrb: _.memoize(function(geom) {
var DRB_SIMPLE_PERIMETER =
_.find(settings.get('stream_layers'),
{code: 'drb_streams_v2'}).perimeter;

return this._containedIn(DRB_SIMPLE_PERIMETER, geom);
}),

isInDrwi: _.memoize(function(geom) {
var DRWI_SIMPLE_PERIMETER = settings.get('drwi_simple_perimeter');

return this._containedIn(DRWI_SIMPLE_PERIMETER, geom);
}),

// Calculates a range from 0 to the upper bound
Expand Down
20 changes: 10 additions & 10 deletions src/mmw/js/src/modeling/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ module.exports = {
},
// In sync with apps.modeling.models.WeatherType.simulations
Simulations: [
// {
// group: 'Recent Weather',
// items: [
// {
// name: 'NASA_NLDAS_2000_2019',
// label: 'NASA NLDAS 2000-2019',
// },
// ],
// in_drb: true,
// },
{
group: 'Recent Weather',
items: [
{
name: 'NASA_NLDAS_2000_2019',
label: 'NASA NLDAS 2000-2019',
},
],
in_drwi: true,
},
{
group: 'Future Weather Simulations',
items: [
Expand Down
1 change: 1 addition & 0 deletions src/mmw/js/src/modeling/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ var ModelingController = {
model_package: modelPackage,
scenarios: new models.ScenariosCollection(),
in_drb: utils.isInDrb(App.map.get('areaOfInterest')),
in_drwi: utils.isInDrwi(App.map.get('areaOfInterest')),
});

App.currentProject = project;
Expand Down
1 change: 1 addition & 0 deletions src/mmw/js/src/modeling/gwlfe/weather/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var WindowModel = Backbone.Model.extend({
defaults: {
project_id: null, // Must be specified
in_drb: false,
in_drwi: false,
scenario_id: null, // Must be specified
weather_type: WeatherType.DEFAULT,
available_data: 'DEFAULT',
Expand Down
4 changes: 2 additions & 2 deletions src/mmw/js/src/modeling/gwlfe/weather/templates/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ <h2 class="weather-col-title">
<option value="DEFAULT" {{ 'selected' if available_data == 'DEFAULT' }}>USEPA National Climate 1960&ndash;1990</option>
</optgroup>
{% for s in Simulations %}
<optgroup label="{{ s.group }} {{ '(DRB Only)' if s.in_drb and not in_drb }}">
<optgroup label="{{ s.group }} {{ '(DRB Only)' if s.in_drb and not in_drb }} {{ '(DRWI Only)' if s.in_drwi and not in_drwi }}">
{% for i in s.items %}
<option value="{{ i.name }}" {{ 'selected' if available_data == i.name }} {{ 'disabled' if s.in_drb and not in_drb }}>{{ i.label }}</option>
<option value="{{ i.name }}" {{ 'selected' if available_data == i.name }} {{ 'disabled' if (s.in_drb and not in_drb) or (s.in_drwi and not in_drwi) }}>{{ i.label }}</option>
{% endfor %}
</optgroup>
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions src/mmw/js/src/modeling/gwlfe/weather/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function showWeatherDataModal(project, addModification) {
is_editable: utils.isEditable(scenario),
project_id: project.get('id'),
in_drb: project.get('in_drb'),
in_drwi: project.get('in_drwi'),
scenario_id: scenario.get('id'),
weather_type: weather_type,
available_data:
Expand Down
10 changes: 5 additions & 5 deletions src/mmw/js/src/modeling/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ module.exports = {
layerOverrideToDefaultLandCoverType: function(layer_overrides) {
var raster = layer_overrides && _.get(layer_overrides, "__LAND__"),
mapping = {
"nlcd-2019-30m-epsg5070-512-byte": "land_2019_2019",
"nlcd-2016-30m-epsg5070-512-byte": "land_2019_2016",
"nlcd-2011-30m-epsg5070-512-byte": "land_2019_2011",
"nlcd-2006-30m-epsg5070-512-byte": "land_2019_2006",
"nlcd-2001-30m-epsg5070-512-byte": "land_2019_2001",
"nlcd-2019-30m-epsg5070-512-uint8raw": "land_2019_2019",
"nlcd-2016-30m-epsg5070-512-uint8raw": "land_2019_2016",
"nlcd-2011-30m-epsg5070-512-uint8raw": "land_2019_2011",
"nlcd-2006-30m-epsg5070-512-uint8raw": "land_2019_2006",
"nlcd-2001-30m-epsg5070-512-uint8raw": "land_2019_2001",
"nlcd-2011-30m-epsg5070-512-int8": "land_2011_2011",
};

Expand Down
3 changes: 2 additions & 1 deletion src/mmw/mmw/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from mmw.settings.layer_settings import (
LAYER_GROUPS, VIZER_URLS, VIZER_IGNORE, VIZER_NAMES,
DRB_PERIMETER, DRB_SIMPLE_PERIMETER, STREAM_TABLES,
DRWI_SIMPLE_PERIMETER, DRWI_SIMPLE_PERIMETER_JSON,
NHD_REGION2_PERIMETER, CONUS_PERIMETER)
from mmw.settings.gwlfe_settings import (
GWLFE_DEFAULTS, GWLFE_CONFIG, SOIL_GROUP,
Expand Down Expand Up @@ -477,7 +478,7 @@ def get_env_setting(setting):
'__BFI__': 'bfi48grd-epsg5070',
'__GWN__': 'us-groundwater-nitrogen-30m-epsg5070-512',
'__KFACTOR__': 'us-ssugro-kfactor-30m-epsg5070-512',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-byte',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-uint8raw',
'__NED__': 'ned-nhdplus-30m-epsg5070-512',
'__PROTECTED_LANDS__': 'protected-lands-30m-epsg5070-512',
'__SLOPE__': 'us-percent-slope-30m-epsg5070-512',
Expand Down
1 change: 1 addition & 0 deletions src/mmw/mmw/settings/data/drwi_perimeter.json

Large diffs are not rendered by default.

Loading

0 comments on commit 01d47b8

Please sign in to comment.