Skip to content

Commit

Permalink
Transferred the cartopy_method branch recent minor changes, which are…
Browse files Browse the repository at this point in the history
… a part of the current PR, to this branch. These changes are mostly focused around the plotting and filename formats.
  • Loading branch information
tkach940 committed Jul 15, 2021
1 parent 4423207 commit c8669ea
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 70 deletions.
20 changes: 10 additions & 10 deletions Encoding.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Name,Code
OMPS_SO2_Lower_Troposphere,0
MODIS_Terra_AOD_Deep_Blue_Land,1
MODIS_Aqua_AOD_Deep_Blue_Land,2
MODIS_Terra_AOD_Deep_Blue_Combined,3
MODIS_Aqua_AOD_Deep_Blue_Combined,4
MODIS_Combined_MAIAC_L2G_AerosolOpticalDepth,5
MODIS_Combined_MAIAC_L2G_BidirectionalReflectance_Bands143,6
MODIS_Aqua_CorrectedReflectance_TrueColor,7
MODIS_Terra_CorrectedReflectance_TrueColor,8
VIIRS_SNPP_CorrectedReflectance_TrueColor,9
MODIS_Aqua_CorrectedReflectance_TrueColor,0
MODIS_Terra_CorrectedReflectance_TrueColor,1
VIIRS_SNPP_CorrectedReflectance_TrueColor,2
MODIS_Terra_AOD_Deep_Blue_Land,3
MODIS_Aqua_AOD_Deep_Blue_Land,4
MODIS_Terra_AOD_Deep_Blue_Combined,5
MODIS_Aqua_AOD_Deep_Blue_Combined,6
MODIS_Combined_MAIAC_L2G_AerosolOpticalDepth,7
MODIS_Combined_MAIAC_L2G_BidirectionalReflectance_Bands143,8
OMPS_SO2_Lower_Troposphere,9
MODIS_Aqua_Cloud_Top_Height_Day,10
MODIS_Terra_Cloud_Top_Height_Day,11
VIIRS_SNPP_Cloud_Top_Height_Day,12
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It can also be called as a function from within another Python program for expan
Dockerfiles and docker-compose files to set up an appropriate Python 2.7 or Python 3.6 container are included in the repo

3) Test run from the command line
`python oco2_modis_vistool.py`
`python oco_vistool.py`


4) Look for the output PNG and HDF5 in the code directory
Expand Down Expand Up @@ -77,7 +77,7 @@ It can also be called as a function from within another Python program for expan
http://matplotlib.org/examples/color/named_colors.html

**oco2_overlay_info** (dict, default: none):
The information for the OCO-2 variable to overlay on the MODIS RGB.
The information for the OCO-2 variable to overlay on the background image.
**{**
**file** (string):
This is *required* for a variable overlay.
Expand Down Expand Up @@ -131,16 +131,17 @@ It can also be called as a function from within another Python program for expan
**out_plot_dir** (string, default: the directory that you are running the code in):
The full output directory path for the output plot.

**out_plot_name** (string, default example: xco2_Amazon_20150701_all_quality_WL_0to20.png):
**out_plot_name** (string, default example: MODIS_Aqua_CorrectedReflectance_TrueColor_xco2_Amazon_20150701_B7302b_QF_good_WL_0to20.png):
The name of the output plot.

**out_data_dir** (string, default: the directory that you are running the code in):
The full output directory path for the output data file.

**out_data_name** (string, default example: xco2_Amazon_20150701_all_quality_WL_0to20.h5):
**out_data_name** (string, default example: xco2_Amazon_20150701_B7302b_QF_good_WL_0to20.h5):
The name of the output data file.


**out_background_name** (string, default example: MODIS_Aqua_CorrectedReflectance_TrueColor_Amazon_20150701.png):
The name of the output background file, created if no overlay data is present or make_background_image is enabled.
## Other Information

GIBS developer documentation: https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers
Expand All @@ -151,15 +152,16 @@ reason of this Python parser is to get the relation, layer name - layer specific
layers (as of June 2021) into a separate CSV file. This relation CSV file is used for plotting and styling the output image.
The parser used a copy of the wmts capabilities file which was downloaded into the code directory from: https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/wmts.cgi?SERVICE=WMTS&REQUEST=GetCapabilities


Minimum command line call:
`python oco2_modis_vistool.py`
`python oco_vistool.py`


Minimum function call:
```
from oco2_modis_vistool import do_modis_overlay_plot
from oco_vistool import do_overlay_plot
do_modis_overlay_plot([lat_of_upper_lefthand_corner, lon_of_upper_lefthand_corner],
do_overlay_plot([lat_of_upper_lefthand_corner, lon_of_upper_lefthand_corner],
[lat_of_lower_righthand_corner, lon_of_lower_righthand_corner],
date, lat_data, lon_data, variable_data)
```
Expand Down
5 changes: 4 additions & 1 deletion annotated_json_format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ out_data_name: set to a specific filename to control the output h5 data
filename. Skipping this field is equivalent to setting it to an empty
string, which means a default file name is constructed, matching the
default plot name.

out_background_name: set to a specific filename to control the output
background image filename, if make_background_image is enabled.
Skipping this field is equivalent to setting it to an empty string,
which means a default filename is constructed.
Overlay specification:

Required Fields
Expand Down
Binary file added oco2_LtCO2_160727_B99999r_sampledata.nc4
Binary file not shown.
10 changes: 5 additions & 5 deletions oco_goes-abi_vistool_config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"date": "2021-02-20",
"date": "2019-10-08",
"sensor":"GOES16_ABI_C",
"data_home":"/arcdata/goes/grb/goes16",
"geo_upper_left": [47.2, -90.8],
"geo_lower_right": [45.8, -88.3],
"data_home":"goes16_data_dir",
"geo_upper_left": [47.0, -92.5],
"geo_lower_right": [45.0, -89.0],
"region": "",
"oco2_overlay_info": {
"file": "oco3_LtCO2_210220_B10205Xr_210322061333s.nc4",
"file": "oco_L1bScSC_191008_B99999_sampledata.h5",
"variable": "SoundingMeasurements/rad_continuum_o2",
"variable_plot_lims":[0.8e20, 1.2e20],
"lat_name": "/FootprintGeometry/footprint_vertex_latitude",
Expand Down
91 changes: 64 additions & 27 deletions oco_vistool.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,20 @@ def _process_overlay_dict(input_dict):
sys.exit()

if len(ovr_d['footprint_lims']) == 2:
ovr_d['fp_file_tag'] = ("_FP_" + str(ovr_d['footprint_lims'][0]) +
"to" + str(ovr_d['footprint_lims'][1]))
if (ovr_d['footprint_lims'][0]==1) and (ovr_d['footprint_lims'][1]==8):
ovr_d['fp_file_tag'] = ""
else:
ovr_d['fp_file_tag'] = ("_FP_" + str(ovr_d['footprint_lims'][0]) +
"to" + str(ovr_d['footprint_lims'][1]))
else:
ovr_d['fp_file_tag'] = "_FP_"+str(ovr_d['footprint_lims'][0])

if re.search("CO2", os.path.basename(ovr_d['var_file'])):
ovr_d['sif_or_co2'] = "CO2"
ovr_d['qf_file_tag'] = "_"+ovr_d['lite_quality']+"_quality"
if ovr_d['lite_quality'] == 'all':
ovr_d['qf_file_tag'] = ""
else:
ovr_d['qf_file_tag'] = "_QF_"+ovr_d['lite_quality']
if ovr_d['warn']:
ovr_d['wl_file_tag'] = ("_WL_" + str(ovr_d['lite_warn_lims'][0]) +
"to"+str(ovr_d['lite_warn_lims'][1]))
Expand Down Expand Up @@ -486,6 +492,7 @@ def process_config_dict(input_dict):
cfg_d['out_plot_title'] = input_dict.get('plot_title', '')
cfg_d['out_plot_dir'] = input_dict.get('out_plot_dir', '')
cfg_d['out_plot_name'] = input_dict.get('out_plot_name', '')
cfg_d['out_background_name'] = input_dict.get('out_background_name', '')
cfg_d['out_data_dir'] = input_dict.get('out_data_dir', '')
cfg_d['out_data_name'] = input_dict.get('out_data_name', '')

Expand Down Expand Up @@ -1350,30 +1357,66 @@ def do_overlay_plot(
layer_url = layers_url[layers_url['Name'] == layer_name]['Url'].values[0]


# construct the auto-generated filename - it is easiest to do this
# once here (since it gets reused in multiple places)
if ovr_d:
output_file_root = ovr_d['var_name_only']
if cfg_d['region']:
output_file_root = output_file_root + "_" + cfg_d['region']
output_file_root = (output_file_root + "_" +
cfg_d['straight_up_date'] +
ovr_d['version_file_tag']+
ovr_d['qf_file_tag']+
ovr_d['wl_file_tag']+
ovr_d['fp_file_tag'])
# construct the auto-generated filenames. These are of the form:
# main overlay image:
# <background>_<oco variable>_<region>_<date>_<version>_<QF tag>_<WL tag>_<FP tag>.png
# overlay data:
# <oco variable>_<region>_<date>_<version>_<QF tag>_<WL tag>_<FP tag>.png
# The background only image will be:
# <background>_<region>_<date>.png
#
# if the user specified the output names directly (in the out_plot_name,
# out_data_name, and out_background_name), these directly override the
# auto-generated names.

# first make the <region>_<date> part, that is common to all.
if cfg_d['region']:
auto_name = cfg_d['region'] + "_"
else:
auto_name = ""
auto_name += cfg_d['straight_up_date']

auto_data_name = ovr_d['var_name_only'] + "_" + auto_name
auto_data_name += (ovr_d['version_file_tag']+
ovr_d['qf_file_tag']+
ovr_d['wl_file_tag']+
ovr_d['fp_file_tag']+
'.h5')
auto_plot_name = ovr_d['var_name_only'] + "_" + auto_name
auto_plot_name += (ovr_d['version_file_tag']+
ovr_d['qf_file_tag']+
ovr_d['wl_file_tag']+
ovr_d['fp_file_tag']+
'.png')
auto_background_name = auto_name + '.png'

if cfg_d['sensor'] == 'Worldview':
auto_plot_name = layer_name + "_" + auto_plot_name
auto_background_name = layer_name + "_" + auto_background_name
else:
output_file_root = cfg_d['straight_up_date']
auto_plot_name = cfg_d['sensor']+"_imagery_" + auto_plot_name
auto_background_name = cfg_d['sensor']+"_imagery_" + auto_background_name

if cfg_d['out_plot_name']:
out_plot_name = cfg_d['out_plot_name']
else:
out_plot_name = output_file_root + '.png'
out_plot_name = auto_plot_name

if cfg_d['out_data_name']:
out_data_name = cfg_d['out_data_name']
else:
out_data_name = output_file_root + '.h5'
out_data_name = auto_data_name

if cfg_d['out_background_name']:
out_background_name = cfg_d['out_background_name']
else:
out_background_name = auto_background_name


# construct filenames for the plot and optional h5 output file.
out_plot_fullpath = os.path.join(cfg_d['out_plot_dir'], out_plot_name)
out_data_fullpath = os.path.join(cfg_d['out_data_dir'], out_data_name)
out_background_fullpath = os.path.join(cfg_d['out_plot_dir'], out_background_name)

# if there is no overlay data present, or the 'background image'
# flag is set, then generate the image without overlay data.
Expand All @@ -1386,21 +1429,19 @@ def do_overlay_plot(
else:
make_background_image = True


if make_background_image:
out_plot_fullpath = os.path.join(
cfg_d['out_plot_dir'],
cfg_d['sensor']+"_imagery_" + out_plot_name)
if (cfg_d['sensor'] == 'Worldview'):
do_overlay_plot(
cfg_d['geo_upper_left'], cfg_d['geo_lower_right'],
cfg_d['datetime'], layer_name, np.array([]), np.array([]),
np.array([]), np.array([]), layer_url,
interest_pt=cfg_d['ground_site'], cmap='black',
out_plot=out_plot_fullpath, cities=cfg_d['city_labels'])
out_plot=out_background_fullpath, cities=cfg_d['city_labels'])
elif (cfg_d['sensor'].startswith('GOES') or cfg_d['sensor'].startswith('Himawari')):
import satpy_overlay_plots
satpy_overlay_plots.nonworldview_overlay_plot(
cfg_d, None, None, out_plot_name=out_plot_fullpath)
cfg_d, None, None, out_plot_name=out_background_fullpath)
else:
raise ValueError('Unknown sensor: '+cfg_d['sensor'])

Expand Down Expand Up @@ -1440,10 +1481,6 @@ def do_overlay_plot(
cbar_name = cbar_cap_strings+'\n('+odat['data_units']+')'
else:
cbar_name = ""

# construct filenames for the plot and optional h5 output file.
out_plot_fullpath = os.path.join(cfg_d['out_plot_dir'], out_plot_name)
out_data_fullpath = os.path.join(cfg_d['out_data_dir'], out_data_name)

if (cfg_d['sensor'] == 'Worldview'):
do_overlay_plot(cfg_d['geo_upper_left'], cfg_d['geo_lower_right'],
Expand Down
32 changes: 14 additions & 18 deletions oco_vistool_config.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{
"date": "2021-06-12",
"geo_upper_left": [36.75, -107.25],
"geo_lower_right": [35, -105.5],
"date": "2016-07-27",
"geo_upper_left": [41.5, -78.5],
"geo_lower_right": [40.0, -77.5],
"region": "",
"sensor": "GOES16_ABI_C",
"files_loc": "local",
"data_home": "/arcdata/goes/grb/goes16",
"oco2_overlay_info": {
"file": "/data/OCO3_IOC/Ops_B10211_r01/2021/06/12/L1bSc/oco3_L1bScSC_11939a_210612_B10211_210613135727.h5",
"variable": "/SoundingMeasurements/rad_continuum_o2",
"band_number":"",
"layer": 0,
"sensor": "Worldview",
"oco2_overlay_info": {
"file": "oco2_LtCO2_160727_B99999r_sampledata.nc4",
"variable": "xco2",
"variable_plot_lims":[],
"lat_name": "/FootprintGeometry/footprint_vertex_latitude",
"lon_name": "/FootprintGeometry/footprint_vertex_longitude",
"orbit": 11939,
"lite_QF": "all",
"lite_warn_lims": [0, 15],
"lat_name": "vertex_latitude",
"lon_name": "vertex_longitude",
"orbit": 11016,
"lite_QF": "all",
"footprint": [1, 8],
"cmap": "jet",
"transparency":"",
"make_background_image":1
},
"ground_site": [],
"ground_site": [40.7934, -77.86],
"city_labels": "",
"out_plot_dir": "",
"out_plot_name": "brisbane_aws_co2.png",
"out_plot_name": "",
"out_data_dir": "",
"out_data_name": ""
}
2 changes: 1 addition & 1 deletion satpy_overlay_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module implementing satpy based plots with OCO-2 data overlays.
intended to integrate with oco2_modis_vistool.py
intended to integrate with oco_vistool.py
"""

import os, glob, datetime, collections, itertools
Expand Down

0 comments on commit c8669ea

Please sign in to comment.