Skip to content

Commit

Permalink
renaming step workflow and removing unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilo9999 committed Dec 12, 2023
1 parent 0a4edaa commit b02a4b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-B01_SL_load_single_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
run: pip install .
- name: first step B01_SL_load_single_file
run: python src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py 20190502052058_05180312_005_01 SH_testSLsinglefile2 True
- name: second step make_spectra
- name: second step B02_make_spectra_gFT
run: python src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py SH_20190502_05180312 SH_testSLsinglefile2 True
53 changes: 13 additions & 40 deletions src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %%

import os, sys
#execfile(os.environ['PYTHONSTARTUP'])


"""
This file open a ICEsat2 track applied filters and corections and returns smoothed photon heights on a regular grid in an .nc file.
Expand All @@ -16,7 +16,7 @@
np
)

#%matplotlib inline

from threadpoolctl import threadpool_info, threadpool_limits
from pprint import pprint

Expand Down Expand Up @@ -58,7 +58,7 @@ def linear_gap_fill(F, key_lead, key_int):
return y_g


# %%

track_name, batch_key, test_flag = io.init_from_input(sys.argv) # loads standard experiment
#track_name, batch_key, test_flag = '20190605061807_10380310_004_01', 'SH_batch01', False
#track_name, batch_key, test_flag = '20190601094826_09790312_004_01', 'SH_batch01', False
Expand Down Expand Up @@ -95,7 +95,7 @@ def linear_gap_fill(F, key_lead, key_int):
MT.mkdirs_r(plot_path)
MT.mkdirs_r(save_path)
bad_track_path =mconfig['paths']['work'] +'bad_tracks/'+ batch_key+'/'
# %%


all_beams = mconfig['beams']['all_beams']
high_beams = mconfig['beams']['high_beams']
Expand All @@ -112,7 +112,7 @@ def linear_gap_fill(F, key_lead, key_int):
Gd = h5py.File(load_path +'/'+track_name + '_B01_binned.h5', 'r')
#Gd.close()

# %% test amount of nans in the data
# test amount of nans in the data

nan_fraction= list()
for k in all_beams:
Expand All @@ -137,7 +137,7 @@ def linear_gap_fill(F, key_lead, key_int):
print('exit.')
exit()

# %% test LS with an even grid where missing values are set to 0
# test LS with an even grid where missing values are set to 0
imp.reload(spec)
print(Gd.keys())
Gi =Gd[ list(Gd.keys())[0] ] # to select a test beam
Expand Down Expand Up @@ -169,35 +169,9 @@ def linear_gap_fill(F, key_lead, key_int):
dk = 2 * np.pi/ dlambda
kk = np.arange(0, 1/lambda_min, 1/dlambda) * 2*np.pi
kk = kk[k_0<=kk]
#dk = np.diff(kk).mean()
print('2 M = ', kk.size *2 )


# for k in all_beams:
# #I = G_gFT[k]
# I2 = Gd_cut
# #plt.plot(I['x_coord'], I['y_coord'], linewidth =0.3)
# plt.plot( I2['x']/1e3, I2['dist']/1e3)

print('2 M = ', kk.size *2 )

# # %%
# xscale= 1e3
# F= M.figure_axis_xy(5, 3, view_scale= 0.6)
# for k in all_beams:
# I = Gd[k]#['x']
# #I = Gd_cut
# plt.plot( I['x'][:]/xscale , I['y'][:]/xscale , '.' , markersize = 0.3)
# #plt.xlim(3e6, 3.25e6)
#
# #F.ax.axhline(0, color='gray', zorder= 2)
#
# plt.title('B01 filter and regrid | ' + track_name +'\npoleward '+str(track_poleward)+' \n \n', loc='left')
# plt.xlabel('along track distance (km)')
# plt.ylabel('across track distance (km)')

# %%

#Gd.keys()
print('define global xlims')
dist_list = np.array([np.nan, np.nan])
for k in all_beams:
Expand Down Expand Up @@ -234,7 +208,7 @@ def linear_gap_fill(F, key_lead, key_int):
print('set xlims: ', xlims)
print('Loop start: ', tracemalloc.get_traced_memory()[0]/1e6, tracemalloc.get_traced_memory()[1]/1e6)

# %%

G_gFT= dict()
G_gFT_x = dict()
G_rar_fft= dict()
Expand Down Expand Up @@ -310,7 +284,7 @@ def linear_gap_fill(F, key_lead, key_int):

xi_1=GG_x.x[i]
xi_2=GG_x.x[i+1]
#if k%2 ==0:


F = M.figure_axis_xy(16, 2)
eta = GG_x.eta
Expand Down Expand Up @@ -461,10 +435,10 @@ def get_stancil_nans(stancil):
del Gd_cut
Gd.close()

# %% save fitting parameters
# save fitting parameters
MT.save_pandas_table(Pars_optm, save_name+'_params', save_path )

# %% repack data
# repack data
def repack_attributes(DD):
#DD = G_LS
attr_dim_list = list(DD.keys())
Expand Down Expand Up @@ -513,7 +487,7 @@ def make_dummy_beam(GG, beam):
G_rar_fft = repack_attributes(G_rar_fft)


# %% save results
# save results
G_gFT_DS = xr.merge(G_gFT.values())#, compat='override')
G_gFT_DS['Z_hat_imag'] = G_gFT_DS.Z_hat.imag
G_gFT_DS['Z_hat_real'] = G_gFT_DS.Z_hat.real
Expand All @@ -532,4 +506,3 @@ def make_dummy_beam(GG, beam):

print('saved and done')

# %%

0 comments on commit b02a4b2

Please sign in to comment.