source: trunk/UTIL/PYTHON/mcd/inimeso/inimeso5.py @ 1007

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

clean and organized UTIL/PYTHON folder

  • 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
12query.toversion5()
13
14### GET COORDINATES
15lines = open("input_coord", "r").readlines()
16query.lon   = float(split(lines[0])[0]) ; query.lat   = float(split(lines[1])[0]) 
17query.xdate = float(split(lines[2])[0]) ; query.loct  = float(split(lines[3])[0])
18query.printcoord()
19
20### OPEN FILES TO BE WRITTEN
21sounding = open("input_sounding", "w") ; additional = open("input_therm", "w") ; more = open("input_more", "w")
22
23### GET and WRITE SURFACE VALUES
24query.xz = 0. ; query.update() ; query.printmeanvar()
25sounding.write( "%10.2f%12.2f%12.2f\n" % (query.pres/100.,query.temp*(610./query.pres)**(1.0/3.9),0.) )
26more.write( "%10.2f%10.2f" % (query.extvar[1],query.extvar[14]) ) ; more.close()
27
28### GET and WRITE VERTICAL PROFILE
29query.profile( tabperso = np.append([0,5,10,20,50,100],np.linspace(200.,float(split(lines[4])[0])*1000.,float(split(lines[5])[0]))) )
30for iz in range(len(query.prestab)):
31    sounding.write(   "%10.2f%12.2f%12.2f%12.2f%12.2f\n" % ( \
32                      query.extvartab[iz,2],query.temptab[iz]*(610./query.prestab[iz])**(1.0/3.9),\
33                      0.,query.zonwindtab[iz],query.merwindtab[iz]) )
34    additional.write( "%12.2f%12.2f%18.6e%18.6e%12.2f\n" % ( \
35                      query.extvartab[iz,53],query.extvartab[iz,8],\
36                      query.prestab[iz],query.denstab[iz],query.temptab[iz]) )
37
38### FINISH
39sounding.close() ; additional.close()
40query.plot1d(["p","t","u","v"]) ; mpl.show()
Note: See TracBrowser for help on using the repository browser.