source: trunk/UTIL/PYTHON/mcd/inimeso.py @ 805

Last change on this file since 805 was 805, checked in by aslmd, 12 years ago

UTIL PYTHON mcd online. improved interface for time (earth and mars). improved titles.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#! /usr/bin/env python
2
3### AS 10/05/2012. A python script to prepare initial state for idealized mesoscale runs.
4###                use : ensure mcd class is working. fill in input_coord. execute inimeso.
5
6from string import split ; import numpy as np ; import matplotlib.pyplot as mpl
7from mcd import mcd
8
9### MCD INSTANCE and SETTINGS (actually, default. but one never knows)
10query = mcd() ; query.zkey = 3 ; query.dust = 2 ; query.hrkey = 1
11
12### GET COORDINATES
13lines = open("input_coord", "r").readlines()
14query.lon   = float(split(lines[0])[0]) ; query.lat   = float(split(lines[1])[0]) 
15query.xdate = float(split(lines[2])[0]) ; query.loct  = float(split(lines[3])[0])
16query.printcoord()
17
18### OPEN FILES TO BE WRITTEN
19sounding = open("input_sounding", "w") ; additional = open("input_therm", "w") ; more = open("input_more", "w")
20
21### GET and WRITE SURFACE VALUES
22query.xz = 0. ; query.update() ; query.printmeanvar()
23sounding.write( "%10.2f%12.2f%12.2f\n" % (query.pres/100.,query.temp*(610./query.pres)**(1.0/3.9),0.) )
24more.write( "%10.2f%10.2f" % (query.extvar[1],query.extvar[14]) ) ; more.close()
25
26### GET and WRITE VERTICAL PROFILE
27query.profile( tabperso = np.append([0,1,5,10,20,50,100],np.linspace(200.,float(split(lines[4])[0])*1000.,float(split(lines[5])[0]))) )
28for iz in range(len(query.prestab)):
29    sounding.write(   "%10.2f%12.2f%12.2f%12.2f%12.2f\n" % ( \
30                      query.extvartab[iz,2],query.temptab[iz]*(610./query.prestab[iz])**(1.0/3.9),\
31                      0.,query.zonwindtab[iz],query.merwindtab[iz]) )
32    additional.write( "%12.2f%12.2f%18.6e%18.6e%12.2f\n" % ( \
33                      query.extvartab[iz,49],query.extvartab[iz,8],\
34                      query.prestab[iz],query.denstab[iz],query.temptab[iz]) )
35
36### FINISH
37sounding.close() ; additional.close()
38query.plot1d(["p","t","u","v"]) ; mpl.show()
Note: See TracBrowser for help on using the repository browser.