-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMake_Timelist.py
More file actions
70 lines (47 loc) · 1.52 KB
/
Make_Timelist.py
File metadata and controls
70 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from netCDF4 import Dataset
import glob,os.path
import numpy as np
from scipy.interpolate import UnivariateSpline
import matplotlib
import matplotlib.pyplot as plt
import site
site.addsitedir('/tera/phil/nchaparr/python')
from nchap_fun import *
"""
Get list of strings representing times of Output
"""
#TDOD: put into nchap_fun?
def make_string(num):
"""Integer to string
Arguments:
integer --
Returns:
string -- eg '0000000030'
"""
if num<100:
string = '00000000' + str(num)
if num >99 and num<1000:
string = '0000000' + str(num)
if num >999 and num<10000:
string = '000000' + str(num)
if num >9999 and num<100000:
string = '00000' + str(num)
if num >99999 and num<1000000:
string = '0000' + str(num)
return string
def Make_Timelists(dt, time_diff, stop_time):
"""Main Function
Arguments:
dt -- from prm file
time_diff -- interval between output writes
stop_time -- end of run from prm
Returns:
dump_time_list, Times_hrs -- list of strings for filenames. list of times
"""
num_times = int(1.0*stop_time/time_diff)
Times = [(i+1)*time_diff for i in range(num_times)]
Times_hrs = [1.0*dt*Time/3600 for Time in Times]
dump_time_list = [make_string(Time) for Time in Times]
return dump_time_list, Times_hrs
if __name__ == "__main__":
dump_time_list, Times_hrs = Make_Timelists(2, 30, 14400)