import sys
import epygram



filein=sys.argv[1]
field=sys.argv[2]
time=int(sys.argv[3])
lon=float(sys.argv[4])
lat=float(sys.argv[5])

epygram.init_env()



#loads the file to be read
r = epygram.formats.resource(filein,'r')
#reads the field LE in the upper file
f = r.readfield(field)

#gets the field for the 3rd output time step 
f2 = f.getvalidity(time)
#plots the field with graphicmode=colorshades
fig, ax = f2.plotfield(graphicmode='colorshades')
#saves the plot in the file LE.png
fig.savefig(field+".png")


#extracts the time series for the point of longitude 3. and latitude 46.
f3 = f.extract_point(lon,lat)
#plots the time series
serie, ax = f3.plotfield()
#saves the time series in the file serie.png
serie.savefig("serie.png")

#plots the animation with interval of 500ms, projection cyl
#title = LE and meridians all 20 degrees
anim = f.plotanimation(interval=500,graphicmode='colorshades',specificproj="cyl",title=field,meridians=20)
#save the animation in file LE.mp4
anim.save(field+".mp4")



