Kamodo Logo

Kamodo Python script for selected plot options of
  IRI Run Lynne_Githio_030724_IT_2


#Python file for hash=c98293d6b5b3104a368671e93da0a2c1
file_dir='/PATH_TO_DATA/IRI/Lynne_Githio_030724_IT_2/'
out_file='/PATH_TO_OUTPUT/plot'

# Load Python packages
from datetime import datetime
import pytz
from kamodo_ccmc.tools.plotfunctions import figMods
import kamodo_ccmc.flythrough.model_wrapper as MW

# Set values to build later pieces of this script
model='IRI'
Krun='Lynne_Githio_030724_IT_2'
Kvar='N_e'
Kvarunits='1/m**3'
Kvarijk=Kvar+'_ijk'
Kshore=True
Klog=False
Kcolorbar='Viridis'
Ksymcb=False
Kcmin=''
Kcmax=''

# Build plot title and set dimension slice values
Ktitle = ''
Ktime='8759.75'
tsPlot = 1388534400+(float(Ktime)*3600.)
Ktitle = Ktitle+'Time = 2014/12/31 23:45:00 UT, '
Kheight='300'
Ktitle = Ktitle+'Height = 300 km'

# Load the requested variable data into a Kamodo object
variables_requested = [Kvar]
reader = MW.Model_Reader(model)
ko = reader(file_dir, variables_requested=variables_requested)

# Create figure object in Kamodo
fig=ko.plot(Kvarijk, plot_partial={Kvarijk: {'time': 8759.75, 'height': 300, }})
plotCoord = 'GDZ'

# For contour plot, modify the figure
fig=figMods(fig,
    ncont=200, colorscale=Kcolorbar, enhanceHover=True, log10=Klog,
    newTitle=Ktitle, cText=Kvar+' ['+Kvarunits+']',
    coText=plotCoord+" Coordinates", 
    llText="CCMC Run: "+Krun, llText2="Model: "+model, xtic=90., ytic=45., )

# Add shorelines
from kamodo_ccmc.tools.shoreline import shoreline
tsPlotint = int(tsPlot)
if plotCoord == 'GDZ':
    # GDZ is really GEO-sph
    pos = shoreline(coord='GEO', coordT='sph', utcts=tsPlotint)
else:
    pos = shoreline(coord=plotCoord, coordT='sph', utcts=tsPlotint)
fig.add_scattergl(mode='lines', x=pos[:, 0], y=pos[:, 1],
    hoverinfo='skip', showlegend=False, line=dict(width=1, color='#EEEEEE'))

# Save interactive figure to html file
fig.write_html(out_file+'.html', full_html=False, include_mathjax='cdn')
print('SUCCESS, script exiting.')