Kamodo Logo

Kamodo Python script for selected plot options of
  CTIPe Run CTIPe-01_2015-12-TP-02_030224_IT_1


#Python file for hash=0c6094a277b53b69c6470990aaf6482e
file_dir='/PATH_TO_DATA/CTIPe/CTIPe-01_2015-12-TP-02_030224_IT_1/'
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='CTIPe'
Krun='CTIPe-01_2015-12-TP-02_030224_IT_1'
Kvar='rho'
Kvarunits='kg/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='672'
tsPlot = 1449532800+(float(Ktime)*3600.)
Ktitle = Ktitle+'Time = 2016/01/05 00:00: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': 672, '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.')