Giter VIP home page Giter VIP logo

hiwat_model_viewer's Introduction

HIWAT Model Viewer

This is a web UI used to display and animate output images created by a HIWAT Model run

Django: 4.x License: MIT SERVIR: Global

Setup and Installation

The installation described here will make use of conda to ensure there are no package conflicts with existing or future applications on the machine. It is highly recommended using a dedicated environment for this application to avoid any issues.

Recommended

Conda (To manage packages within the applications own environment)

Environment

  • Create the env
conda env create -f environment.yml

Add a file named data.json in the base directory. This file will hold a json object containing ALLOWED_HOSTS, LOG_PATH, and SECRET_KEY. The format will be:

{
  "ALLOWED_HOSTS": ["localhost", "your_domain.com", "127.0.0.1"],
  "LOG_PATH": "path_to_where_you_want_logs_written",
  "SECRET_KEY": "REPLACE WITH A SECRET KEY USING LETTERS, NUMBERS, AND SPECIAL CHARACTERS"
}
  • enter the environment
conda activate hmv
  • Create database tables and superuser
follow prompts to create superuser
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatic

At this point you should be able to start the application. From the root directory you can run the following command

python manage.py runserver

Of course running the application in this manner is only for development. We recommend installing this application on a server and serving it through nginx using gunicorn (conda install gunicorn) for production. To do this you will need to have both installed on your server. There are enough resources explaining in depth how to install them, so we will avoid duplicating this information. We recommend adding a service to start the application by creating a .service file located at /etc/systemd/system. We named ours hmv.service The service file will contain the following, please substitute the correct paths as mentioned below.

Server installation

Create Application Service

As mentioned above create the following file at /etc/systemd/system/ and name it hmv.service

[Unit]
Description=hmv daemon
After=network.target

[Service]
User=nginx
Group=nginx
SocketUser=nginx
WorkingDirectory={REPLACE WITH PATH TO APPLICATION ROOT}/hiwat
accesslog = "/var/log/hmv/hmv_gunicorn.log"
errorlog = "/var/log/hmv/hmv_gunicornerror.log"
ExecStart={REPLACE WITH FULL PATH TO gunicorn IN YOUR CONDA ENV}/bin/gunicorn --timeout 60 --workers 5 --pythonpath '{REPLACE WITH PATH TO APPLICATION ROOT},{REPLACE WITH FULL PATH TO YOUR CONDA ENV}/lib/python3.10/site-packages' --bind unix:{REPLACE WITH LOCATION YOU WANT THE SOCK}/hmv_prod.sock wsgi:application

[Install]
WantedBy=multi-user.target

Create nginx site

Create a file in /etc/nginx/conf.d/ named hmv_prod.conf

upstream hmv_prod {
  server unix:{REPLACE WITH LOCATION YOU WANT THE SOCK}/hmv_prod.sock 
  fail_timeout=0;
}

server {
    listen 443;
    server_name {REPLACE WITH YOUR DOMAIN};
    add_header Access-Control-Allow-Origin *;

    ssl on;
    ssl_certificate {REPLACE WITH FULL PATH TO CERT FILE};
    ssl_certificate_key {REPLACE WITH FULL PATH TO CERT KEY};

    # Some Settings that worked along the way
    client_max_body_size 8000M;
    client_body_buffer_size 8000M;
    client_body_timeout 120;

    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_send_timeout 300;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 90s;
    fastcgi_send_timeout 90s;
    fastcgi_read_timeout 90s;


    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        autoindex on;
        alias {REPLACE WITH FULL PATH TO APPS}/staticfiles/;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://unix:{REPLACE WITH LOCATION YOU WANT THE SOCK}/hmv_prod.sock ;
    }


}

# Reroute any non https traffic to https
server {
    listen 80;
    server_name {REPLACE WITH YOUR DOMAIN};
    rewrite ^(.*) https://$server_name$1 permanent;
}

Create Alias commands to make starting the application simple

Create a file at /etc/profile.d/ named hmv_alias.sh and add the following:

# Global Alias
alias d='conda deactivate'
alias so='sudo chown -R www-data /servir_apps'
alias nsr='sudo service nginx restart'
alias nss='sudo service nginx stop'


# SAMS Alias
alias hmv='cd /servir_apps/hiwat_model_viewer'
alias acthmv='conda activate hmv'
alias uohmv='sudo chown -R ${USER} /servir_apps/hiwat_model_viewer'
alias sohmv='sudo chown -R www-data /servir_apps/hiwat_model_viewer'
alias hmvstart='sudo service hmv restart; sudo service nginx restart; so'
alias hmvstop='sudo service hmv stop'
alias hmvrestart='hmvstop; hmvstart'

Now activate the alias file by running

source /etc/profile.d/hmv_alias.sh

Now you should be able to run hmvstart to run the production application.

Contact

Authors

License and Distribution

Hiwat Model Viewer is distributed by SERVIR under the terms of the MIT License. See LICENSE in this directory for more information.

Privacy & Terms of Use

Hiwat Model Viewer abides to all of SERVIR's privacy and terms of use as described at https://servirglobal.net/Privacy-Terms-of-Use.

hiwat_model_viewer's People

Contributors

billyz313 avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar SERVIR avatar Lance avatar Kel Markert avatar Amides Figueroa avatar

hiwat_model_viewer's Issues

Summary plots not loading for new forecast hour convention

In Ensemble page, the Summaries are not loading correctly for the more recent forecasts initialized at 1200, going out to 54 hours total. The new Summaries are being generated ending at forecast hours 30 (day-1) and 54 (day-2) instead of ending at forecast hours 24 and 48 as in the previous 2 years of experiments. Perhaps the 24 and 48 were hard-coded into the HMV?

Add info page

Please add an info page as the last item of the menu, with a placeholder for text describing the app and the usual logo/credits and disclaimers.

May 3-5, 2019 grayed out on calendar

These 3 dates are grayed out from being able to select using the calendar icon, but all graphics folder are available on SOCRATES at /mnt/hiwat/hkh/image_files.

Reverts back to most recent date when toggling between Ensemble and Deterministic

Previously, the HMV would let me load up an archived date, and initially display the Ensemble page. Then I could toggle to Deterministic to load the fields for the same archive date. Now, whenever I toggle between Ensemble or Deterministic while viewing an archived date, it reverts back to the present (or most recently available) date, thereby requiring an extra step to go back into the calendar to load the archived date of interest.

Look into Pre-loading image

When I load a new product, I quickly hold down the forecast hour scroll, but it’s very choppy and not smoothly displaying all the hourly images as I manually scroll through the hours. The SPoRT-Hiwat web page didn’t have this problem and was able to smoothly show all images when I manually scroll through with mouse.

Animation controls have larger view in Chrome than in Firefox

The animation control buttons, scroll bar, and labels have a slightly larger default view in Chrome than in Firefox. As a result, some of the chrome animation controls carry over onto a new line below. For example, in the Ensemble/Deterministic toggle, the deterministic label is on the next line below the toggle in Chrome, but appears more cleanly beside the toggle when viewed in Firefox. The same goes for the calendar icon, which is below the "Initialized: " label.

Still reverting back to current date when toggling Ens to Det

I just tested the following:

  1. Loaded up 2 May 2019 forecast via calendar icon,
  2. Toggled to Determinisitc page,
  3. Instead of loading Det page for 2 May 2019, it flipped back to today (29 Apr 2020).
  4. I then had to re-load 2 May 2019 while on Det page in order to get Det graphics for 2 May 2019.

-Jon

Change default product

Set default variable as Probabilities > Total Lightning Flashes > ensprob-lfa-thresh0.07-20km

Get current menu

Update views.py > getjson to check file structure for latest modified .xml to create menu

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.