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): ...@@ -67,10 +67,10 @@ class AEFile(object):
ae_data = self.ae_sets[set_nr] ae_data = self.ae_sets[set_nr]
index = np.searchsorted(ae_data[:, 0], radius) index = np.searchsorted(ae_data[:, 0], radius)
index = max(1, index) index = max(1, index)
setnr1, setnr2 = ae_data[index - 1:index + 1, 3] setnrs = ae_data[index - 1:index + 1, 3]
if setnr1 != setnr2: if setnrs[0] != setnrs[-1]:
raise NotImplementedError raise NotImplementedError
return setnr1 return setnrs[0]
......
...@@ -176,8 +176,8 @@ class HTCSection(HTCContents): ...@@ -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")) s += "%send %s;%s\n" % (" "*level, self.name_, (("", "\t" + self.end_comments)[self.end_comments.strip() != ""]).replace("\t\n","\n"))
return s return s
def get_subsection_by_name(self, name): def get_subsection_by_name(self, name, field='name'):
lst = [s for s in self if 'name' in s and s.name[0]==name] lst = [s for s in self if field in s and s[field][0]==name]
if len(lst)==1: if len(lst)==1:
return lst[0] return lst[0]
else: else:
......
...@@ -140,7 +140,6 @@ class SSHPBSClusterResource(Resource): ...@@ -140,7 +140,6 @@ class SSHPBSClusterResource(Resource):
_, output, _ = self.ssh.execute('qstat -n1') _, output, _ = self.ssh.execute('qstat -n1')
users, host, nodesload = pbswrap.parse_qstat_n1(output.split("\n"), self.ssh.host) 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 # if the user does not have any jobs, this will not exist
try: try:
cpu_user = users[self.ssh.username]['cpus'] cpu_user = users[self.ssh.username]['cpus']
......
...@@ -241,6 +241,9 @@ class SSHClient(object): ...@@ -241,6 +241,9 @@ class SSHClient(object):
size = len(localfile.read()) size = len(localfile.read())
localfile.seek(0) localfile.seek(0)
ret = self.sftp.putfo(localfile, filepath, file_size=size, callback=callback) ret = self.sftp.putfo(localfile, filepath, file_size=size, callback=callback)
except Exception as e:
print ("upload failed ", str(e))
raise e
finally: finally:
SSHClient.__exit__(self) SSHClient.__exit__(self)
if verbose: if verbose:
...@@ -271,6 +274,8 @@ class SSHClient(object): ...@@ -271,6 +274,8 @@ class SSHClient(object):
self.upload(zn, remote_zn, callback=callback) self.upload(zn, remote_zn, callback=callback)
self.execute("unzip %s -d %s && rm %s"%(remote_zn, remotepath, remote_zn)) self.execute("unzip %s -d %s && rm %s"%(remote_zn, remotepath, remote_zn))
except: except:
print ("upload files failed", )
traceback.print_exc()
raise raise
finally: finally:
os.remove(zn) os.remove(zn)
......
...@@ -40,6 +40,17 @@ def MoninObukhov_length(u,v,w, T): ...@@ -40,6 +40,17 @@ def MoninObukhov_length(u,v,w, T):
def L2category(L, full_category_name=False): def L2category(L, full_category_name=False):
"""Stability category from Monin-Obukhov length """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 Parameters
---------- ----------
L : float or int L : float or int
...@@ -57,12 +68,12 @@ def L2category(L, full_category_name=False): ...@@ -57,12 +68,12 @@ def L2category(L, full_category_name=False):
>>> L2category(1000) >>> L2category(1000)
n 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 index = np.searchsorted( 1/cat_limits, 1/np.array(L))-1
if full_category_name: 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: 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): def MoninObukhov_length2(u_star, w, T, specific_humidity=None):
"""Calculate the Monin Obukhov length """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