Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update LowerColorado with bmi and flowveldepth function implemented #697

Closed
wants to merge 5 commits into from

Conversation

AminTorabi-NOAA
Copy link
Contributor

A code added in LowerColorado_TX_v4 for running the bmi. It uses the "test_AnA_V4_HYFeature" yaml file.

Additions

  • make sure in test_AnA_V4_HYFeature.yaml file lastobs_output_folder commented out ( : #lastobs/)
  • The flowveldepth functions added to model_DAforcing file.
  • LOG also added instead of print (using log_level_set function)
  • waterbodies_df was giving error in reconstructing the dataframe that some column are missing. I add the 3 columns of 'lon', 'lat', 'crs' and after reconstructing the dataframe drped them.
  • flowveldepth function added
  • run_all_configs_with_BMI_V2.py file is updated on the base_path address to be independent of my directory.
  • output_parameters added in the troute_model file

Removals

Changes

Testing

  1. Tested on LowerColorado_TX_v4 and it works.

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Windows
  • Linux
  • Browser

Accessibility

  • Keyboard friendly
  • Screen reader friendly

Other

  • Is useable without CSS
  • Is useable without JS
  • Flexible from small to large screens
  • No linting errors or warnings
  • JavaScript tests are passing

Copy link
Contributor

@shorvath-noaa shorvath-noaa left a comment

Choose a reason for hiding this comment

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

Nice work. I've left a few comments to be addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename this file to something like "run_with_BMI.py"? 'all_configs' is misleading as this only runs one configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 1 to 9
import sys
import os
import glob
import numpy as np
import pandas as pd
import geopandas as gpd
import pickle
from datetime import datetime, timedelta
import time
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this file is not using glob, gpd, datetime.datetime, or pickle. Can you remove these imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe undo the changes to this file? Unless we are updating the organization of parameters or the parameters themselves, I think we should leave this as is. Users can adjust the inputs themselves to fit their needs.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AminTorabi-NOAA actually, ignore this comment. Changing the output parameters to being on in the yaml file is good I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like all of the output .csv files have the same column names, regardless of the .csv file timestamp. For example, 202304020000.flowveldepth.csv column names are (correctly):
,q_202304020000,v_202304020000,d_202304020000,ndg_202304020000

But 202304020100.flowveldepth.csv column names are (incorrectly):
,q_202304020000,v_202304020000,d_202304020000,ndg_202304020000

Can you make sure these are being updated accordingly with the model time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, Thanks. Done

q0 = values.get('q0')
waterbody_df = values.get('waterbody_df')
lastobs_df = values.get('lastobs_df')
if len(q0) != 0 and len(waterbody_df) != 0 and len(lastobs_df) != 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Were we going to change this line? q0 should never be empty, right? And I believe _write_lite_restart checks if waterbody_df is empty before trying to write that file. lastobs_df should not impact whether _write_lite_restart is called so should not be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in a way that when write_lite_restart is 1 it go through _write_lite_restart function

if output_parameters.get('stream_output',{}).get('qvd_nudge'):
#write flowveldepth file
pass
# if output_parameters.get('stream_output',{}) is not None and output_parameters.get('stream_output',{}).get('qvd_nudge'):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you delete this commented out line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@shorvath-noaa shorvath-noaa left a comment

Choose a reason for hiding this comment

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

In addition to the specific comments, I got the following error when I tried to run run_with_BMI.py:

***************test AnA Run***************
Initialize DA Module...
Traceback (most recent call last):
  File "/home/sean.horvath/projects/t-route/test/LowerColorado_TX_v4/run_with_BMI.py", line 132, in <module>
    run_troute('test AnA')
  File "/home/sean.horvath/projects/t-route/test/LowerColorado_TX_v4/run_with_BMI.py", line 38, in run_troute
    DAforcing.initialize(bmi_cfg_file = base_path + config_dict[config]['yaml'])
  File "/home/sean.horvath/projects/t-route/src/bmi_DAforcing.py", line 117, in initialize
    self._model = DAforcing_model(bmi_cfg_file) 
  File "/home/sean.horvath/projects/t-route/src/model_DAforcing.py", line 84, in __init__
    self._usgs_df.
  File "/home/sean.horvath/miniconda-template/miniconda3/lib/python3.9/site-packages/pandas/core/frame.py", line 10535, in resample
    return super().resample(
  File "/home/sean.horvath/miniconda-template/miniconda3/lib/python3.9/site-packages/pandas/core/generic.py", line 8312, in resample
    return get_resampler(
  File "/home/sean.horvath/miniconda-template/miniconda3/lib/python3.9/site-packages/pandas/core/resample.py", line 1423, in get_resampler
    return tg._get_resampler(obj, kind=kind)
  File "/home/sean.horvath/miniconda-template/miniconda3/lib/python3.9/site-packages/pandas/core/resample.py", line 1599, in _get_resampler
    raise TypeError(
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'

Comment on lines +320 to +322
q0 = values.get('q0')
waterbody_df = values.get('waterbody_df')
lastobs_df = values.get('lastobs_df')
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like these are no longer used here, right? If that's the case can you delete them?

self._t0,
output_parameters['lite_restart']
)
values['write_lite_restart'] = 0
lastobs_output_folder = da_parameters.get('streamflow_da',{}).get('lastobs_output_folder', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add writing lastobs to the if write_lite_restart == 1: block? technically lastobs is a different kind of file, but it's only used to restart our DA module from a previous run, so it essentially acts as a restart file.


import bmi_troute
import bmi_DAforcing
import model_DAforcing
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need model_DAforcing to be loaded. This is used within bmi_DAforcing. Can you delete this?

AminTorabi-NOAA added a commit that referenced this pull request Dec 5, 2023
* writing nc file with different frequency

* Addressing the comments on config and output columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants