Skip to content

Instantly share code, notes, and snippets.

@stageipsl
Last active August 29, 2015 14:02
Show Gist options
  • Save stageipsl/a049beb9304e5973206f to your computer and use it in GitHub Desktop.
Save stageipsl/a049beb9304e5973206f to your computer and use it in GitHub Desktop.
def alt_max(SR, alt, n):
u, v = np.shape(SR)
j = - 1
if (SR[n,0] > 0.01 or SR[n,0] < -10) or (SR[n,1] > 0.01 or SR[n,1] < -10):
return j
i = 2
while i < v:
if (SR[n,i] > -10) and (SR[n,i] < 0.01):
j = i
elif (SR[n,i] > 0.01) and (SR[n,i-1] > 0.01):
return j
i = i + 1
return j
def alt_max_orbite(alt, SR):
p,v = np.shape(SR)
tab1 = np.zeros((p))
tab2 = np.zeros((p))
for o in range (0,p):
j = alt_max(SR,alt,o)
if j != -1 :
tab1[o] = alt[j]
#if tab1[o] > 5.: print o
else : tab1[o] = -10
tab2[o] = o
return tab1
def alt_max_total(SR, alt):
u,v = np.shape(SR)
alt_array = np.zeros((u),dtype=int)
for i in range (0,u):
for j in range(0,v):
if (SR[i][j] < 0.01) and ( SR[i][j] >-10):
alt_array[i] = int(1)
return alt_array
def faux_pr(alt, SR):
u,v = np.shape(SR)
tab1 = np.zeros((u), dtype= int)
tab2 = np.zeros((u))
alt_arr = alt_max_orbite(alt, SR)
for i in range (0,u):
for j in range(0,v):
if (alt[j] > alt_arr[i] ) and (SR[i][j] < 0.01)and (SR[i][j] > -10) :
tab1[i] = int(1)
return tab1
def hist_lonlat(dossier,test):
nbr_fichier,fichier = lecture_dossier(dossier)
nbr_fichier = int(nbr_fichier)
if test ==1 :
for i in range(0,nbr_fichier):
lg, lt, ti, atb,alt, sol_alt, SR = extraction(dossier + fichier[i])
print np.shape(lt),np.shape(lg)
alt_max = alt_max_orbite(alt,SR)#vrai
idx = (alt_max != 0 )
alt_max = alt_max[idx]
lg = lg[idx]
lt = lt[idx]
lonb = np.arange(-90,90,2)
latb = np.arange(-180,180,2)
if i == 0:
latotal = lt
lgtotal = lg
else:
latotal = np.concatenate([latotal,lt])
lgtotal = np.concatenate([lgtotal,lg])
output = 'lonlat_total_pourcent_total'
np.savez(output,latotal,lgtotal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment