Skip to content
Snippets Groups Projects
Commit e8e82a29 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

some changes and modifications

parent 40c7c955
No related branches found
No related tags found
No related merge requests found
......@@ -67,10 +67,10 @@ class AEFile(object):
ae_data = self.ae_sets[set_nr]
index = np.searchsorted(ae_data[:, 0], radius)
index = max(1, index)
setnr1, setnr2 = ae_data[index - 1:index + 1, 3]
if setnr1 != setnr2:
setnrs = ae_data[index - 1:index + 1, 3]
if setnrs[0] != setnrs[-1]:
raise NotImplementedError
return setnr1
return setnrs[0]
......
......@@ -176,8 +176,8 @@ class HTCSection(HTCContents):
s += "%send %s;%s\n" % (" "*level, self.name_, (("", "\t" + self.end_comments)[self.end_comments.strip() != ""]).replace("\t\n","\n"))
return s
def get_subsection_by_name(self, name):
lst = [s for s in self if 'name' in s and s.name[0]==name]
def get_subsection_by_name(self, name, field='name'):
lst = [s for s in self if field in s and s[field][0]==name]
if len(lst)==1:
return lst[0]
else:
......
......@@ -140,7 +140,6 @@ class SSHPBSClusterResource(Resource):
_, output, _ = self.ssh.execute('qstat -n1')
users, host, nodesload = pbswrap.parse_qstat_n1(output.split("\n"), self.ssh.host)
# if the user does not have any jobs, this will not exist
try:
cpu_user = users[self.ssh.username]['cpus']
......
......@@ -241,6 +241,9 @@ class SSHClient(object):
size = len(localfile.read())
localfile.seek(0)
ret = self.sftp.putfo(localfile, filepath, file_size=size, callback=callback)
except Exception as e:
print ("upload failed ", str(e))
raise e
finally:
SSHClient.__exit__(self)
if verbose:
......@@ -271,6 +274,8 @@ class SSHClient(object):
self.upload(zn, remote_zn, callback=callback)
self.execute("unzip %s -d %s && rm %s"%(remote_zn, remotepath, remote_zn))
except:
print ("upload files failed", )
traceback.print_exc()
raise
finally:
os.remove(zn)
......
......@@ -40,6 +40,17 @@ def MoninObukhov_length(u,v,w, T):
def L2category(L, full_category_name=False):
"""Stability category from Monin-Obukhov length
Categories:
0>L>-50: Extreme unstable (eu)
-50>L>-100: Very unstable (vu)
-100>L>-200: Unstable (u)
-200>L>-500: Near unstable (nu)
500<|L|: Neutral (n)
200<L<500: Near stable (ns)
50<L<200: Stable (s)
10<L<50: Very stable (vs)
0<L<10: Extreme stable (es)
L=NaN: Undefined (-)
Parameters
----------
L : float or int
......@@ -57,12 +68,12 @@ def L2category(L, full_category_name=False):
>>> L2category(1000)
n
"""
cat_limits = np.array([-50,-100,-200,-500,500,200,50,10])
cat_limits = np.array([-1e-99,-50,-100,-200,-500,500,200,50,10,1e-99])
index = np.searchsorted( 1/cat_limits, 1/np.array(L))-1
if full_category_name:
return np.array(['Very unstable','Unstable','Near unstable','Neutral','Near stable','Stable','Very stable','undefined'])[index]
return np.array(['Extreme unstable', 'Very unstable','Unstable','Near unstable','Neutral','Near stable','Stable','Very stable','Extreme stable','Undefined'])[index]
else:
return np.array(['vu','u','nu','n','ns','s','vs','-'])[index]
return np.array(['eu', 'vu','u','nu','n','ns','s','vs','es','-'])[index]
def MoninObukhov_length2(u_star, w, T, specific_humidity=None):
"""Calculate the Monin Obukhov length
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment