Skip to content

Commit

Permalink
First production commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Szkodzinski committed Oct 20, 2020
1 parent cb4c461 commit 2da0bbd
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 82 deletions.
84 changes: 84 additions & 0 deletions datasources/downloadCSV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import shutil
from contextlib import closing
import urllib.request as request
import numpy as np
import glob as glob
import os
import requests
from bs4 import BeautifulSoup
import re

# Download CSV for all satellites and regions.
# CSVs will go in /home/<user>/.sharppy/datasources
def downloadCSV():
# Download Alaska, Caribbean and CONUS CSVs for NOAA-20.
with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/j01/csv/j01_alaska.csv')) as r:
with open('j01_alaska.csv', 'wb') as f:
shutil.copyfileobj(r, f)

with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/j01/csv/j01_caribbean.csv')) as r:
with open('j01_caribbean.csv', 'wb') as f:
shutil.copyfileobj(r, f)

with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/j01/csv/j01_conus.csv')) as r:
with open('j01_conus.csv', 'wb') as f:
shutil.copyfileobj(r, f)


# Download Alaska, Caribbean and CONUS CSVs for Suomi-NPP.
with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/npp/csv/npp_alaska.csv')) as r:
with open('npp_alaska.csv', 'wb') as f:
shutil.copyfileobj(r, f)

with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/npp/csv/npp_caribbean.csv')) as r:
with open('npp_caribbean.csv', 'wb') as f:
shutil.copyfileobj(r, f)

with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/npp/csv/npp_conus.csv')) as r:
with open('npp_conus.csv', 'wb') as f:
shutil.copyfileobj(r, f)


# # Download Alaska, Caribbean and CONUS CSVs for Metop-A.
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m01/csv/m01_alaska.csv')) as r:
# with open('m01_alaska.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m01/csv/m01_caribbean.csv')) as r:
# with open('m01_caribbean.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m01/csv/m01_conus.csv')) as r:
# with open('m01_conus.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
#
# # Download Alaska, Caribbean and CONUS CSVs for Metop-B.
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m02/csv/m02_alaska.csv')) as r:
# with open('m02_alaska.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m02/csv/m02_caribbean.csv')) as r:
# with open('m02_caribbean.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m02/csv/m02_conus.csv')) as r:
# with open('m02_conus.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
#
# # Download Alaska, Caribbean and CONUS CSVs for Metop-C.
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m03/csv/m03_alaska.csv')) as r:
# with open('m03_alaska.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m03/csv/m03_caribbean.csv')) as r:
# with open('m03_caribbean.csv', 'wb') as f:
# shutil.copyfileobj(r, f)
#
# with closing(request.urlopen(f'https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m03/csv/m03_conus.csv')) as r:
# with open('m03_conus.csv', 'wb') as f:
# shutil.copyfileobj(r, f)

## MAIN ##
downloadCSV()
93 changes: 91 additions & 2 deletions datasources/standard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<outlet name="PSU" url="ftp://ftp.meteo.psu.edu/pub/bufkit/GFS/{cycle}/gfs3_{srcid}.buf" format="bufkit" >
<time first="0" range="120" delta="1" offset="0" delay="4" cycle="6" archive="24" start="-" end="-"/>
<points csv="gfs.csv" />
</outlet>
</outlet>
<outlet name="IEM" url="http://mtarchive.geol.iastate.edu/{year}/{month}/{day}/bufkit/{cycle}/gfs/gfs3_{srcid}.buf" format="bufkit" >
<time first="0" range="120" delta="1" offset="0" delay="4" cycle="6" archive="24" start="2010/12/30" end="now"/>
<points csv="gfs.csv" />
Expand Down Expand Up @@ -96,4 +96,93 @@
<points csv="sharp.csv" />
</outlet>
</datasource>
</sourcelist>
<datasource name="Nucaps NOAA 20 Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/j01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="j01_alaska.csv" />
</outlet>
</datasource>
<datasource name="Nucaps NOAA 20 Caribbean" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/j01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="j01_caribbean.csv" />
</outlet>
</datasource>
<datasource name="Nucaps NOAA 20 Conus" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/j01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="j01_conus.csv" />
</outlet>
</datasource>
<datasource name="Nucaps Suomi-NPP Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/npp/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="npp_alaska.csv" />
</outlet>
</datasource>
<datasource name="Nucaps Suomi-NPP Caribbean" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/npp/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="npp_caribbean.csv" />
</outlet>
</datasource>
<datasource name="Nucaps Suomi-NPP Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/npp/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="npp_conus.csv" />
</outlet>
</datasource>
<!--datasource name="Nucaps Metop A Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m01_alaska.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop A Caribbean" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m01_caribbean.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop A Conus" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m01/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m01_conus.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop B Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m02/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m02_alaska.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop B Caribbean" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m02/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m02_caribbean.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop B Conus" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m02/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m02_conus.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop C Alaska" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/alaska/sharppy/m03/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m03_alaska.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop C Caribbean" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/caribbean/sharppy/m03/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m03_caribbean.csv" />
</outlet>
</datasource-->
<!--datasource name="Nucaps Metop C Conus" ensemble="false" observed="true">
<outlet name="STC" url="https://geo.nsstc.nasa.gov/SPoRT/jpss-pg/nucaps/gridded/conus/sharppy/m03/txt/{srcid}.txt" format="spc" >
<time first="0" range="48" delta="1" offset="6" delay="4" cycle="12" archive="24" start="-" end="-"/>
<points csv="m03_conus.csv" />
</outlet>
</datasource-->
82 changes: 61 additions & 21 deletions runsharp/full_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,6 @@ def __init__(self, config, **kwargs):
self.has_connection = any(urls.values())
self.strictQC = True

# JTS
self.ctf_low = None
self.ctf_high = None
self.ctp_low = None
self.ctp_high = None

# initialize the UI
self.__initUI()

Expand Down Expand Up @@ -452,8 +446,21 @@ def update_list(self):
self.select_flag = False

# JTS - Remove the forecast times under the "Select Forecast Time" section for NUCAPS.
if self.model == "Nucaps NOAA 20" or self.model == "Nucaps Suomi-NPP" or self.model == "Nucaps Aqua" \
or self.model == "Nucaps Metop A" or self.model == "Nucaps Metop B" or self.model == "Nucaps Metop C":
if self.model == "Nucaps NOAA 20 Alaska" \
or self.model == "Nucaps NOAA 20 Caribbean" \
or self.model == "Nucaps NOAA 20 Conus" \
or self.model == "Nucaps Suomi-NPP Alaska" \
or self.model == "Nucaps Suomi-NPP Caribbean" \
or self.model == "Nucaps Suomi-NPP Conus" \
or self.model == "Nucaps Metop A Alaska" \
or self.model == "Nucaps Metop A Caribbean" \
or self.model == "Nucaps Metop A Conus" \
or self.model == "Nucaps Metop B Alaska" \
or self.model == "Nucaps Metop B Caribbean" \
or self.model == "Nucaps Metop B Conus" \
or self.model == "Nucaps Metop C Alaska" \
or self.model == "Nucaps Metop C Caribbean" \
or self.model == "Nucaps Metop C Conus":
self.date_label.setDisabled(True)
self.all_profs.setDisabled(True)
self.profile_list.clear()
Expand Down Expand Up @@ -560,8 +567,21 @@ def update(times):
self.run_dropdown.setEnabled(False)

# JTS - Remove the model/obs cycle times from the run dropdown menu for NUCAPS.
if self.model == "Nucaps NOAA 20" or self.model == "Nucaps Suomi-NPP" or self.model == "Nucaps Aqua" \
or self.model == "Nucaps Metop A" or self.model == "Nucaps Metop B" or self.model == "Nucaps Metop C":
if self.model == "Nucaps NOAA 20 Alaska" \
or self.model == "Nucaps NOAA 20 Caribbean" \
or self.model == "Nucaps NOAA 20 Conus" \
or self.model == "Nucaps Suomi-NPP Alaska" \
or self.model == "Nucaps Suomi-NPP Caribbean" \
or self.model == "Nucaps Suomi-NPP Conus" \
or self.model == "Nucaps Metop A Alaska" \
or self.model == "Nucaps Metop A Caribbean" \
or self.model == "Nucaps Metop A Conus" \
or self.model == "Nucaps Metop B Alaska" \
or self.model == "Nucaps Metop B Caribbean" \
or self.model == "Nucaps Metop B Conus" \
or self.model == "Nucaps Metop C Alaska" \
or self.model == "Nucaps Metop C Caribbean" \
or self.model == "Nucaps Metop C Conus":
self.run_dropdown.clear()
self.run_dropdown.setDisabled(True)

Expand Down Expand Up @@ -702,6 +722,35 @@ def skewApp(self, filename=None, ntry=0):
:return:
"""

# JTS - Retrieve the cloud top pressure and fraction values from the CSV.
if self.model == "Nucaps NOAA 20 Alaska" \
or self.model == "Nucaps NOAA 20 Caribbean" \
or self.model == "Nucaps NOAA 20 Conus" \
or self.model == "Nucaps Suomi-NPP Alaska" \
or self.model == "Nucaps Suomi-NPP Caribbean" \
or self.model == "Nucaps Suomi-NPP Conus" \
or self.model == "Nucaps Metop A Alaska" \
or self.model == "Nucaps Metop A Caribbean" \
or self.model == "Nucaps Metop A Conus" \
or self.model == "Nucaps Metop B Alaska" \
or self.model == "Nucaps Metop B Caribbean" \
or self.model == "Nucaps Metop B Conus" \
or self.model == "Nucaps Metop C Alaska" \
or self.model == "Nucaps Metop C Caribbean" \
or self.model == "Nucaps Metop C Conus":
self.ctf_low = self.loc['ctf_low']
self.ctf_high = self.loc['ctf_high']
self.ctp_low = self.loc['ctp_low']
self.ctp_high = self.loc['ctp_high']
else:
# Ignore these csv headers if non-NUCAPS data source
self.ctf_low = None
self.ctf_high = None
self.ctp_low = None
self.ctp_high = None

# print(f'ctf_low: {self.ctf_low}, ctf_high: {self.ctf_high}, ctp_low: {self.ctp_low}, ctp_high: {self.ctp_high}')

logging.debug("Calling full_gui.skewApp")

failure = False
Expand Down Expand Up @@ -791,6 +840,8 @@ def skewApp(self, filename=None, ntry=0):

raise exc

return self.ctf_low, self.ctf_high, self.ctp_low, self.ctp_high

def skewAppClosed(self):
"""
Handles the user closing the SPC window.
Expand All @@ -803,17 +854,6 @@ def focusSkewApp(self):
self.skew.setFocus()
self.skew.raise_()

try:
# JTS - Retrieve the cloud top pressure and fraction values from the CSV.
self.ctf_low = self.loc['ctf_low']
self.ctf_high = self.loc['ctf_high']
self.ctp_low = self.loc['ctp_low']
self.ctp_high = self.loc['ctp_high']
except:
# Ignore these csv headers if non-NUCAPS data source
pass
return self.ctf_low, self.ctf_high, self.ctp_low, self.ctp_high

def keyPressEvent(self, e):
if e.key() == 61 or e.key() == 45:
self.view.keyPressEvent(e)
Expand Down
Loading

0 comments on commit 2da0bbd

Please sign in to comment.