Giter Site home page Giter Site logo

nrel / ssrs Goto Github PK

View Code? Open in Web Editor NEW
10.0 9.0 4.0 93.52 MB

A stochastic agent-based model for predicting raptor movements during updraft-subsidized directional flights

Home Page: https://www.osti.gov/doecode/biblio/63192

License: BSD 3-Clause "New" or "Revised" License

Python 1.26% Jupyter Notebook 53.87% HTML 44.87%
behavior-modeling wind-wildlife-interactions raptor-conservation golden-eagles agent-based-modeling movement-ecology orographic-updrafts thermal-updrafts complex-terrain srtm

ssrs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssrs's Issues

Cleanup inputs

  • sim-movement and movement_model appear redundant
  • need to fix output sections, e.g., random walk parameters currently get lumped under "terrain"
  • add heuristics_ or hssrs_ prefix to H-SSRS-specific parameters
  • recommend renaming wtk_source options with "EAGLE" to "NRELHPC" for generality / clarity
  • add parameters for improved orographic updraft model, e.g., https://github.com/rthedin/SSRS/blob/feature/w0i_option/ssrs/config.py#L65-L70

https://github.com/NREL/SSRS/blob/dev/ssrs/config.py#L11-L82

Issue when checking saved terrain data

When in the Terrain class we check if the data exists in the bound specified by the user, it does not consider the pad which may have been changed from when the original data was downloaded..

Pressure levels for heights AGL between 100 and 250 m in HRRR

Working my way through PR #16, I noticed some problems on the HRRR interface.

When getting data from HRRR using wind_velocity_direction_at_altitude, at any height AGL height_above_ground above 100 m, we fall into the following else to get the appropriate pressure level:

SSRS/ssrs/hrrr/hrrr.py

Lines 350 to 363 in a9114c7

if height_above_ground_m > 0.0 and height_above_ground_m < 45.0:
grib_field = f'{varname}:10 m above ground:anl'
u_data_var = 'u10'
v_data_var = 'v10'
elif height_above_ground_m >= 45.0 and height_above_ground_m < 100.0:
grib_field = f'{varname}:80 m above ground:anl'
u_data_var = 'u'
v_data_var = 'v'
else:
nearest_pressures = self.nearest_pressures(ground_level_m)
closest_pressure_above = nearest_pressures['closest_pressure_above']
grib_field = f'{varname}:{closest_pressure_above} mb'
u_data_var = 'u'
v_data_var = 'v'

where ground_level_m is used as an argument to nearest_pressures. However, oftentimes the call to wind_velocity_direction_at_altitude does not include ground_level_m, but rather height_above_ground_m. The ground_level_m is zero by default:
ground_level_m=0.0,

According to the nearest_pressures function's docstring, h is the height above sea level:

SSRS/ssrs/hrrr/hrrr.py

Lines 92 to 93 in a9114c7

h: float
Height above sea level in meters

so I'm not sure if it is appropriate to use height_above_ground_m

What should we use here? Not specifying ground_level_m does not work because of the default 0 (and would not even be appropriate). Should we first get the ground level and then combine it with the height AGL?

Right now, in the latest commit from PR #16, I replaced line 359 above with

nearest_pressures = self.nearest_pressures(height_above_ground_m)

However, I do understand that this is not really appropriate.

What would be appropriate path forward here?

Fix dependencies for HRRR

SSRS Simulator cannot be initialized with from .hrrr import HRRR lines in code. The error may be reproduced with the following single line:

from ssrs.hrrr.hrrr import HRRR

which results in

RuntimeError: Cannot find the ecCodes library

Diving deeper, this can actually be traced back to:

import gribapi

which is called by the eccodes library.

Some refactoring suggestions

I have some suggestions that I think it will improve code maintenance and debugging. None of this is exactly needed at this point, but if time becomes available, it would be nice to have.

  1. Exception handling. When the code checks if a file already exists in order to load it (instead of downloading or computing it again), it is done in a try/except way. The exceptions are also caught generically, on a catch-all umbrella (e.g. except Exception as _).

    SSRS/ssrs/simulator.py

    Lines 161 to 165 in 1cda662

    try:
    slope = self.get_terrain_layer('Slope')
    except Exception as _:
    elev = self.get_terrain_elevation()
    slope = compute_slope_degrees(elev, self.resolution)

    I think we should first check if the file exists, then read it if it does. Only then, we can handle exceptions if something goes wrong. We should not fall into an exception if the file does not exist, since that will happen the first time running it. These functions should return some False/True, instead of carrying over a generic exception. In some other instances, computations are performed within a try/except block and I think that should really be removed. When something goes bad, the actual exception is never given to the user.

  2. We should really consider moving grid data to an xarray format. The rasterio operations can probably be handled by rioxarray . Problems with orientation of aspect and wind direction conventions are handled ad-hoc. For example, this should be removed:

    wdir_sx = (np.mean(wdirn)+90)%360 # wdir for sx due to weird convention

    w0 = wspeedAtRefHeight * np.sin(np.deg2rad(slope)) * np.cos(np.deg2rad(((-np.mean(wdirn)+90)%360)-aspect))

  3. The simulator class has too many methods that should not be there. For example, all the plotting routines should be moved to another file/class.

  4. kwargs keywords should be added to plotting functions, which are then passed to the actual pcolormesh calls.

Rectify differences between master/dev/alt_study

Simulator.plot_updrafts() throws an error

FileNotFoundError: [Errno 2] No such file or directory: '.../output/alt_test/data/uniform/s8d225th2_thermal.npy'

when simulating with fluid-flow model, without thermals.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.