Commit 47081b7a2f811ade00f498844716507a93d9cb0b
1 parent
e2271bb5
Exists in
master
work
Showing
4 changed files
with
40 additions
and
23 deletions
Show diff stats
Bin.py/makeRequest.py
... | ... | @@ -19,18 +19,18 @@ def checkArgs(nbArgs, message): |
19 | 19 | # In[3]: |
20 | 20 | |
21 | 21 | # CHECK ARGS |
22 | -checkArgs(6, 'Usage : python makeRequest.py (target) (tgt_vi) (sw_vi) (TaoStopTime) (SwStopTime)') | |
22 | +checkArgs(5, 'Usage : python makeRequest.py (tgt_vi) (sw_vi) (TaoStopTime) (SwStopTime)') | |
23 | 23 | |
24 | -prefix = sys.argv[1] | |
25 | -tgtVI = sys.argv[2] | |
26 | -plasmaVI = sys.argv[3] | |
24 | +prefix = sys.argv[1].split("_")[0] | |
25 | +tgtVI = sys.argv[1] | |
26 | +plasmaVI = sys.argv[2] | |
27 | 27 | |
28 | 28 | # In[4]: |
29 | -omniStopTime = datetime.strptime(sys.argv[5], '%Y-%m-%dT%H:%M:%S') | |
29 | +omniStopTime = datetime.strptime(sys.argv[4], '%Y-%m-%dT%H:%M:%S.000Z') | |
30 | 30 | print omniStopTime |
31 | 31 | |
32 | 32 | # In[5]: |
33 | -missionStopTime = datetime.strptime(sys.argv[4], '%Y-%m-%dT%H:%M:%S.000Z') | |
33 | +missionStopTime = datetime.strptime(sys.argv[3], '%Y-%m-%dT%H:%M:%S.000Z') | |
34 | 34 | print missionStopTime |
35 | 35 | |
36 | 36 | # In[6]: |
... | ... | @@ -70,7 +70,7 @@ if newMissionStop <= newMissionStart: |
70 | 70 | else: |
71 | 71 | print "Database has to be updated" |
72 | 72 | |
73 | -if newMissionStart.year != newMissionStop.year: | |
73 | +if newMissionStart.year != newMissionStop.year and plasmaVI != 'ace_swepam_real': | |
74 | 74 | print "2 files will be producted" |
75 | 75 | newMissionxml1Start = datetime(newMissionStart.year,1,1,0,0) |
76 | 76 | newMissionxml1Stop = datetime(newMissionStop.year,1,1,0,0) |
... | ... | @@ -86,7 +86,10 @@ if newMissionStart.year != newMissionStop.year: |
86 | 86 | writeXMLMission(XMLfilename,newMissionxml2Start.isoformat(),newMissionxml2Stop.isoformat(),plasmaVI,tgtVI,tgtRParam,tgtLonParam) |
87 | 87 | else: |
88 | 88 | print "1 file will be producted" |
89 | - newMissionxmlStart = datetime(newMissionStart.year,1,1,0,0) | |
89 | + if plasmaVI == "ace_swepam_real": | |
90 | + newMissionxmlStart = datetime(newMissionStart.year,newMissionStart.month,newMissionStart.day,0,0) | |
91 | + else: | |
92 | + newMissionxmlStart = datetime(newMissionStart.year,1,1,0,0) | |
90 | 93 | newMissionxmlStop = newMissionStop |
91 | 94 | print 'XML Start : ' + newMissionxmlStart.isoformat() |
92 | 95 | print 'XML Stop : ' + newMissionxmlStop.isoformat() | ... | ... |
Bin.py/run.py
... | ... | @@ -26,10 +26,10 @@ def main(): |
26 | 26 | SW2MISSIONS = os.getenv('REQ') |
27 | 27 | SW2DATA = os.getenv('SW2DATA') |
28 | 28 | SW2NC = os.getenv('SW2NC') |
29 | - | |
29 | + | |
30 | 30 | # GET INFOS FROM XML CONFIG FILE |
31 | 31 | start,stop,plasmaVi,srcVi,srcR,srcLon,tgtVi,tgtR,tgtLon = getXMLConfig(xmlFile) |
32 | - src = plasmaVi.split('_')[0] | |
32 | + src = plasmaVi.split('_')[0] | |
33 | 33 | |
34 | 34 | # CREATE A DIRECTORY FOR THE NEW QUERY |
35 | 35 | MYDIR = SW2DATA+'/'+src+'/'+prefix+'_'+datetime.now().strftime('%Y%m%d') |
... | ... | @@ -54,7 +54,8 @@ def main(): |
54 | 54 | marginPlasma = getMarginDays(tgtVi) #Days |
55 | 55 | plasmaStart = shiftedDate(start, days=-marginPlasma, seconds=-1) |
56 | 56 | plasmaDDStart = time2ddtime(plasmaStart) |
57 | - plasmaStop = shiftedDate(stop, days=marginPlasma) | |
57 | + # if run run.py 'alone' - for previous years | |
58 | + #plasmaStop = shiftedDate(stop, days=marginPlasma) | |
58 | 59 | plasmaStop = shiftedDate(stop) |
59 | 60 | plasmaDDStop = time2ddtime(plasmaStop) |
60 | 61 | ddTimeDeltaPlasma = DDTimeDelta(plasmaStart, plasmaStop) |
... | ... | @@ -179,7 +180,7 @@ def main(): |
179 | 180 | xmin1 = 0.3 |
180 | 181 | else: |
181 | 182 | idprop = 1 |
182 | - xmax1 = 10.8 | |
183 | + xmax1 = 5.8 | |
183 | 184 | xmin1 = 0.8 |
184 | 185 | |
185 | 186 | # QUALITY FLAG |
... | ... | @@ -342,9 +343,9 @@ def getXMLConfig(XMLFilename): |
342 | 343 | |
343 | 344 | def getMarginDays(tgtName): |
344 | 345 | if tgtName == 'mercury': |
345 | - distAU == 0.48 | |
346 | + distAU == 0.61 | |
346 | 347 | elif tgtName == 'venus': |
347 | - distAU = 0.48 | |
348 | + distAU = 0.28 | |
348 | 349 | elif tgtName == 'mars': |
349 | 350 | distAU = 0.52 |
350 | 351 | elif tgtName == 'jupiter': |
... | ... | @@ -437,8 +438,8 @@ def writeNamelist(directory,idprop,xmax1,xmin1): |
437 | 438 | nl.write(' fnout=\''+directory+'/outputs.txt\'\n') |
438 | 439 | nl.write(' fdirtmp=\''+directory+'/\'\n') |
439 | 440 | nl.write(' instop=0\n') |
440 | - nl.write(' dtr=300.\n') | |
441 | - nl.write(' touts=12.\n') | |
441 | + nl.write(' dtr=90.\n') | |
442 | + nl.write(' touts=40.\n') | |
442 | 443 | nl.write(' xmin1='+str(xmin1)+'\n') |
443 | 444 | nl.write(' xmax1='+str(xmax1)+'\n') |
444 | 445 | nl.write('/\n') | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +from datetime import datetime, date, time, timedelta | |
2 | +import pandas as pd | |
3 | +import numpy as np | |
4 | +import os | |
5 | +import sys | |
6 | +from lxml import etree | |
7 | +from netCDF4 import Dataset | |
8 | +import logging | |
9 | +from logging.handlers import RotatingFileHandler | |
10 | +import time as myTime | |
0 | 11 | \ No newline at end of file | ... | ... |
runRequest
1 | 1 | #!/bin/bash |
2 | 2 | # Prepare & Run Request |
3 | 3 | |
4 | -tgt=$1 # prefix | |
5 | -tgt_vi=$2 | |
6 | -src_vi=$3 | |
7 | -TaoStop=$4 | |
8 | -SwStop=$5 | |
4 | +tgt_vi=$1 | |
5 | +src_vi=$2 | |
6 | +TaoStop=$3 | |
7 | +SwStop=$4 | |
9 | 8 | |
10 | 9 | . $(dirname $BASH_SOURCE)/env.sh |
11 | 10 | |
11 | + IFS='_' read -r -a array <<< "$tgt_vi" | |
12 | + tgt=${array[0]} | |
13 | + | |
12 | 14 | # delete results of previous calculations |
13 | 15 | rm -rf $SW2NC/$tgt* $SW2DATA/$src/$tgt* |
14 | 16 | |
15 | 17 | # delete previous requests |
16 | 18 | rm -f $REQ/*.xml |
17 | 19 | |
18 | - cd $SW2ROOT/Bin.py; python makeRequest.py $tgt $tgt_vi $src_vi $TaoStop $SwStop > log | |
20 | + cd $SW2ROOT/Bin.py; python makeRequest.py $tgt_vi $src_vi $TaoStop $SwStop > log | |
19 | 21 | DDLogin $DDUSER $DDPWD >> log |
20 | 22 | |
21 | 23 | |
22 | 24 | # run newly created Request |
25 | + # can be launched as stand alone executable | |
23 | 26 | for request in $REQ/$tgt*.xml |
24 | 27 | do |
25 | - python run.py $tgt $request & echo $! | |
28 | + python run.py $tgt $request & echo $! | |
26 | 29 | done |
27 | 30 | |
28 | 31 | \ No newline at end of file | ... | ... |