[937] | 1 | #! /usr/bin/env python |
---|
| 2 | |
---|
| 3 | # This python program illustrates how the Mars Climate Database |
---|
| 4 | # fortran routines can be called interactively from python |
---|
| 5 | |
---|
| 6 | from fmcd import call_mcd,julian |
---|
| 7 | import numpy as np |
---|
| 8 | |
---|
| 9 | # 1. Inputs: |
---|
| 10 | dset = '' # default to 'MCD_DATA' |
---|
| 11 | perturkey = 1 # default to no perturbation |
---|
| 12 | seedin = 0 # perturbation seed (unused if perturkey=1) |
---|
| 13 | gwlength = 0 # Gravity Wave length for perturbations (unused if perturkey=1) |
---|
| 14 | |
---|
| 15 | # 1.1 Dates |
---|
| 16 | choice_date=raw_input('Use Earth date (e) or Mars date (m)?') |
---|
| 17 | if (choice_date == "e") : |
---|
| 18 | datekey=0 # Earth date |
---|
| 19 | loct=0 # local time must then also be set to zero |
---|
| 20 | day,month,year,hour,minute,second = \ |
---|
| 21 | raw_input("Enter date: day/month/year/hour/minute/second: ").split('/') |
---|
| 22 | day=int(day) |
---|
| 23 | month=int(month) |
---|
| 24 | year=int(year) |
---|
| 25 | hour=int(hour) |
---|
| 26 | minute=int(minute) |
---|
| 27 | second=int(second) |
---|
| 28 | # now call Julian routine to convert to julian date |
---|
| 29 | (ier,xdate)=julian(month,day,year,hour,minute,second) |
---|
| 30 | print " Julian date %16.8f" % xdate |
---|
| 31 | else : |
---|
| 32 | datekey=1 # Mars date |
---|
| 33 | xdate=float(raw_input("Enter solar longitude Ls (deg.):")) |
---|
| 34 | loct=float(raw_input("Local time (0 < time < 24)?")) |
---|
| 35 | |
---|
| 36 | # 1.2 Vertical coordinate |
---|
| 37 | zkey=int(raw_input("Select verical coordinate type (1: distance to center of planet, 2: height above areoid, 3: height above surface, 4: Pressure) ")) |
---|
| 38 | if (zkey == 1) : |
---|
| 39 | xz=float(raw_input("Enter distance to planet center (m) ")) |
---|
| 40 | if (zkey == 2) : |
---|
| 41 | xz=float(raw_input("Enter altitude above areoid (m) ")) |
---|
| 42 | if (zkey == 3) : |
---|
| 43 | xz=float(raw_input("Enter altitude above surface (m) ")) |
---|
| 44 | if (zkey == 4) : |
---|
| 45 | xz=float(raw_input("Enter pressure value (Pa) ")) |
---|
| 46 | |
---|
| 47 | # high resolution mode |
---|
| 48 | hrkey=int(raw_input("High resolution? (1: yes, 0: no) ")) |
---|
| 49 | |
---|
| 50 | # 1.3 Position |
---|
| 51 | lat = float(raw_input('Latitude (deg)?')) |
---|
| 52 | lon = float(raw_input('Longitude (deg)?')) |
---|
| 53 | |
---|
| 54 | # 1.4 Dust and solar scenario |
---|
| 55 | print "Dust scenario?" |
---|
| 56 | print "1= Climatology typical Mars year dust scenario" |
---|
| 57 | print " average solar EUV conditions" |
---|
| 58 | print "2= Climatology typical Mars year dust scenario" |
---|
| 59 | print " minimum solar EUV conditions" |
---|
| 60 | print "3= Climatology typical Mars year dust scenario" |
---|
| 61 | print " maximum solar EUV conditions" |
---|
| 62 | print "4= dust storm constant dust opacity = 5 (dark dust)" |
---|
| 63 | print " minimum solar EUV conditions" |
---|
| 64 | print "5= dust storm constant dust opacity = 5 (dark dust)" |
---|
| 65 | print " average solar EUV conditions" |
---|
| 66 | print "6= dust storm constant dust opacity = 5 (dark dust)" |
---|
| 67 | print " maximum solar EUV conditions" |
---|
| 68 | print "7= warm scenario dustier than Climatology scenario" |
---|
| 69 | print " maximum solar EUV conditions" |
---|
| 70 | print "8= cold scenario clearer than Climatology scenario" |
---|
| 71 | print " minimum solar EUV conditions" |
---|
| 72 | dust=int(raw_input('')) |
---|
| 73 | |
---|
| 74 | # 1.5 perturbations |
---|
| 75 | perturkey=int(raw_input("Perturbation? (1:none, 2: large scale, 3: small scale, 4: small+large, 5: n sigmas) ")) |
---|
| 76 | if (perturkey > 1) : |
---|
| 77 | seedin=int(raw_input("seedin? (only matters if adding perturbations) ")) |
---|
| 78 | if ((perturkey == 3) or (perturkey == 4)) : |
---|
| 79 | gwlength=float(raw_input("Gravity wave length? (for small scale perturbations) ")) |
---|
| 80 | |
---|
| 81 | # 1.6 extra outputs |
---|
| 82 | # here we only implement an all-or-nothing case |
---|
| 83 | extvarkey=int(raw_input("Output the extra variables? (yes==1; no==0) ")) |
---|
| 84 | if (extvarkey == 0) : |
---|
| 85 | extvarkeys = np.zeros(100) |
---|
| 86 | else : |
---|
| 87 | extvarkeys = np.ones(100) |
---|
| 88 | |
---|
| 89 | # 2. Call MCD |
---|
| 90 | (pres, dens, temp, zonwind, merwind, \ |
---|
| 91 | meanvar, extvar, seedout, ierr) \ |
---|
| 92 | = \ |
---|
| 93 | call_mcd(zkey,xz,lon,lat,hrkey, \ |
---|
| 94 | datekey,xdate,loct,dset,dust, \ |
---|
| 95 | perturkey,seedin,gwlength,extvarkeys ) |
---|
| 96 | |
---|
| 97 | # 3. Write outputs |
---|
| 98 | print "temperature is %.0f K, pressure is %.0f Pa, density is %5.3e kg/m3, zonal wind is %.1f m/s, meridional wind is %.1f m/s" % (temp,pres,dens,zonwind,merwind) |
---|
| 99 | |
---|