[653] | 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 | |
---|
| 6 | from string import split ; import numpy as np ; import matplotlib.pyplot as mpl |
---|
| 7 | from mcd import mcd |
---|
| 8 | |
---|
| 9 | ### MCD INSTANCE and SETTINGS (actually, default. but one never knows) |
---|
| 10 | query = mcd() ; query.zkey = 3 ; query.dust = 2 ; query.hrkey = 1 |
---|
| 11 | |
---|
| 12 | ### GET COORDINATES |
---|
| 13 | lines = open("input_coord", "r").readlines() |
---|
| 14 | query.lon = float(split(lines[0])[0]) ; query.lat = float(split(lines[1])[0]) |
---|
| 15 | query.xdate = float(split(lines[2])[0]) ; query.loct = float(split(lines[3])[0]) |
---|
| 16 | query.printcoord() |
---|
| 17 | |
---|
| 18 | ### OPEN FILES TO BE WRITTEN |
---|
| 19 | sounding = open("input_sounding", "w") ; additional = open("input_therm", "w") ; more = open("input_more", "w") |
---|
| 20 | |
---|
| 21 | ### GET and WRITE SURFACE VALUES |
---|
| 22 | query.xz = 0. ; query.update() ; query.printmeanvar() |
---|
| 23 | sounding.write( "%10.2f%12.2f%12.2f\n" % (query.pres/100.,query.temp*(610./query.pres)**(1.0/3.9),0.) ) |
---|
| 24 | more.write( "%10.2f%10.2f" % (query.extvar[1],query.extvar[14]) ) ; more.close() |
---|
| 25 | |
---|
| 26 | ### GET and WRITE VERTICAL PROFILE |
---|
| 27 | query.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]))) ) |
---|
| 28 | for 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 |
---|
| 37 | sounding.close() ; additional.close() |
---|
[805] | 38 | query.plot1d(["p","t","u","v"]) ; mpl.show() |
---|