diff --git a/.github/workflows/test-B01_SL_load_single_file.yml b/.github/workflows/test-B01_SL_load_single_file.yml index 6dcdee90..be9dc577 100644 --- a/.github/workflows/test-B01_SL_load_single_file.yml +++ b/.github/workflows/test-B01_SL_load_single_file.yml @@ -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 \ No newline at end of file diff --git a/src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py b/src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py index 5fbddadf..18b2fb75 100644 --- a/src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py +++ b/src/icesat2_tracks/analysis_db/B02_make_spectra_gFT.py @@ -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. @@ -16,7 +16,7 @@ np ) -#%matplotlib inline + from threadpoolctl import threadpool_info, threadpool_limits from pprint import pprint @@ -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 @@ -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'] @@ -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: @@ -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 @@ -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: @@ -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() @@ -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 @@ -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()) @@ -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 @@ -532,4 +506,3 @@ def make_dummy_beam(GG, beam): print('saved and done') -# %%