Skip to content

Instantly share code, notes, and snippets.

@alberthdev
Last active August 29, 2015 14:05
Show Gist options
  • Save alberthdev/73364514d0c914ad70eb to your computer and use it in GitHub Desktop.
Save alberthdev/73364514d0c914ad70eb to your computer and use it in GitHub Desktop.
PyRadmon Barebones Code
import pyradmon.enumerate as en
from pyradmon.data import get_data, rel_channels
from pyradmon.plot import plot
plot_dict = { "plot1" : { "output" : "helloplot_ch%CHANNEL%.png", "settings": { "dpi": 50, "target_size": [595, 700] }, }, }
plot_dict["plot1"]["title"] = "Testing - AMSUA_N15 channel %CHANNEL%"
plot_dict["plot1"]["plots"] = [ { "subplot1" : { "axes": { "x" : { "label": None }, "y" : { "label": None }, }, }, } ]
plot_dict["plot1"]["plots"][0]["subplot1"]["data"] = { "colors" : [ "blue", "red" ], "labels": [ "AVG", "SDV" ], "x": "timestamp", "y": [ "ges|bc_const|mean", "ges|bc_const|stddev" ] }
plot_dict["plot1"]["plots"][0]["subplot1"]["legend"] = { "line" : True }
plot_dict["plot1"]["plots"][0]["subplot1"]["title"] = "My Subplot Title"
md = {
'data_path_format' : "MERRA2/%EXPERIMENT_ID%/obs/Y%YEAR4%/M%MONTH2%/D%DAY2%/H%HOUR2%/%EXPERIMENT_ID%.diag_%INSTRUMENT_SAT%_%DATA_TYPE%.%YEAR4%%MONTH2%%DAY2%_%HOUR2%z.txt",
'experiment_id' : "d5124_m2_jan10",
'instrument_sat': "amsua_n15",
'start_year' : 2012, 'start_month' : 7, 'start_day' : 1, 'start_hour' : 0,
'end_year' : 2012, 'end_month' : 7, 'end_day' : 31, 'end_hour' : 18,
'data_type' : "anl|ges"
}
data_columns = [ "timestamp", "frequency", "iuse", "ges|bc_const|mean", "ges|bc_const|stddev" ]
channels = [6, 7]
print "Enumerating files..."
(files_to_read, stats_dict) = en.enumerate(**md)
print "Fetching data..."
data = get_data(files_to_read, data_columns, channels, md["data_path_format"])
rel_channels_dict = rel_channels(channels)
print "Plotting..."
for channel in channels:
print "Plotting channel %i..." % channel
md["channel"] = channel
plot(plot_dict, data[channel], md, rel_channels_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment