-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate step 2 #44
Integrate step 2 #44
Changes from 16 commits
f0ef135
6c852f5
e71e1c7
8820d2d
e27ee64
3dac298
28b253d
ce05d64
0f706f0
701d18d
ae9fba6
0a4edaa
b02a4b2
e3ebaf8
7e93e0b
8d210c7
67846f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,8 +111,10 @@ dependencies = [ # Optional | |
"mpi4py", | ||
"icesat2-toolkit==1.0.0.22", | ||
"geopandas", | ||
"sliderule", | ||
"ipyleaflet" | ||
"sliderule==4.1.0", | ||
"ipyleaflet", | ||
"lmfit", | ||
"tables" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might be able to remove this dep if the I/O is optimized in step 2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be nice. |
||
] | ||
|
||
# List additional groups of dependencies here (e.g. development | ||
|
kmilo9999 marked this conversation as resolved.
Show resolved
Hide resolved
kmilo9999 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean as a whistle! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
# %% | ||
|
||
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. | ||
This is python 3 | ||
""" | ||
|
||
exec(open(os.environ['PYTHONSTARTUP']).read()) | ||
exec(open(STARTUP_2021_IceSAT2).read()) | ||
from icesat2_tracks.config.IceSAT2_startup import ( | ||
mconfig, | ||
xr, | ||
color_schemes, | ||
font_for_pres, | ||
plt, | ||
np | ||
) | ||
|
||
|
||
#%matplotlib inline | ||
from threadpoolctl import threadpool_info, threadpool_limits | ||
from pprint import pprint | ||
|
||
|
||
import ICEsat2_SI_tools.convert_GPS_time as cGPS | ||
import icesat2_tracks.ICEsat2_SI_tools.convert_GPS_time as cGPS | ||
import h5py | ||
import ICEsat2_SI_tools.io as io | ||
import ICEsat2_SI_tools.spectral_estimates as spec | ||
import icesat2_tracks.ICEsat2_SI_tools.io as io | ||
import icesat2_tracks.ICEsat2_SI_tools.spectral_estimates as spec | ||
|
||
import time | ||
import imp | ||
import copy | ||
import spicke_remover | ||
from icesat2_tracks.local_modules.m_spectrum_ph3 import spicke_remover | ||
import datetime | ||
import generalized_FT as gFT | ||
import icesat2_tracks.ICEsat2_SI_tools.generalized_FT as gFT | ||
from scipy.ndimage.measurements import label | ||
import icesat2_tracks.local_modules.m_tools_ph3 as MT | ||
from icesat2_tracks.local_modules import m_general_ph3 as M | ||
|
||
# from guppy import hpy | ||
# h=hpy() | ||
# h.heap() | ||
#import s3fs | ||
#from memory_profiler import profile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not delete these too? |
||
|
@@ -50,13 +56,8 @@ 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might change after the cli is implemented. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely! |
||
#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 | ||
#track_name, batch_key, test_flag = '20190207111114_06260210_004_01', 'SH_batch02', False | ||
#track_name, batch_key, test_flag = '20190208152826_06440210_004_01', 'SH_batch01', False | ||
#track_name, batch_key, test_flag = '20190213133330_07190212_004_01', 'SH_batch02', False | ||
#track_name, batch_key, test_flag = '20190205231558_06030212_004_01', 'SH_batch02', False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have missed suggesting removing other commented code, but lines 61-76, 78, 106 could be deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed all the commented code |
||
|
||
#local track | ||
|
@@ -87,7 +88,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'] | ||
|
@@ -104,7 +105,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: | ||
|
@@ -129,7 +130,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 | ||
|
@@ -161,35 +162,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: | ||
|
@@ -226,7 +201,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() | ||
|
@@ -263,7 +238,7 @@ def linear_gap_fill(F, key_lead, key_int): | |
|
||
# compute slope spectra !! | ||
dd = np.gradient(dd) | ||
dd, _ = spicke_remover.spicke_remover(dd, spreed=10, verbose=False) | ||
dd, _ = spicke_remover(dd, spreed=10, verbose=False) | ||
dd_nans = (np.isnan(dd) ) + (Gd_cut['N_photos'] <= 5) | ||
|
||
# dd_filled = np.copy(dd) | ||
|
@@ -302,7 +277,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 | ||
|
@@ -453,10 +428,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()) | ||
|
@@ -505,7 +480,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 | ||
|
@@ -524,4 +499,3 @@ def make_dummy_beam(GG, beam): | |
|
||
print('saved and done') | ||
|
||
# %% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't seem to be able to install this using the description in the README any more – I'm getting the following error:
Is there something special I need to do to make this work? On main it still builds fine. It looks like a problem with
tables
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kmilo9999 check when tables is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hollandjg This error is because it's not finding HDF5 in your macos. I created a workflow that checks the installation in that system and they seem to work. Have you set the
HDF5_DIR
environmental variable?@cpaniaguam @hollandjg This is the stack trace of the throw error when the
pytables
dependency is missed.Basically, when the analysis results are being save to a pandas table,
pandas
calls the function :import_optional_dependency("tables")
and that producess the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solves it, but I think it needs to be in the README. I've put in a suggestion in #49 which can be merged into this branch.