Skip to content

Commit 8cccf0e

Browse files
committed
fixed dataframe merge when specifying ancillary fields
1 parent 5d15d51 commit 8cccf0e

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

sliderule/icesat2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,8 @@ def atl06p(parm, asset=DEFAULT_ASSET, version=DEFAULT_ICESAT2_SDP_VERSION, callb
842842
tstart_merge = time.perf_counter()
843843
for field in field_dictionary:
844844
df = geopandas.pd.DataFrame(field_dictionary[field])
845-
gdf = gdf.merge(df, on='extent_id', how='inner').set_axis(gdf.index)
845+
gdf = gdf.merge(df, on='extent_id', how='inner')
846+
gdf.set_axis(gdf.index)
846847
profiles["merge"] = time.perf_counter() - tstart_merge
847848

848849
# Delete Extent ID Column

sliderule/sliderule.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666

6767
arrow_file_table = {}
6868

69+
profiles = {}
70+
6971
gps_epoch = datetime(1980, 1, 6)
7072
tai_epoch = datetime(1970, 1, 1, 0, 0, 10)
7173

@@ -263,8 +265,14 @@ def __parse_native(data, callbacks):
263265
rec_index = 0
264266
rec_rsps = []
265267

268+
duration = 0.0
269+
266270
for line in data.iter_content(None):
267271

272+
# Capture Start Time (for duration)
273+
tstart = time.perf_counter()
274+
275+
# Process Line Read
268276
i = 0
269277
while i < len(line):
270278

@@ -315,6 +323,12 @@ def __parse_native(data, callbacks):
315323
rec_size_index = 0
316324
rec_index = 0
317325

326+
# Capture Duration
327+
duration = duration + (time.perf_counter() - tstart)
328+
329+
# Update Timing Profile
330+
profiles[__parse_native.__name__] = duration
331+
318332
return recs
319333

320334
#

utils/utils.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
import json
3+
import sliderule
34
from sliderule import icesat2
45

56
#
@@ -155,6 +156,20 @@ def initialize_client(args):
155156
# Return Parameters and Configuration
156157
return parms, cfg
157158

159+
#
160+
# Display Timing
161+
#
162+
def display_timing():
163+
164+
print("\nSlideRule Timing Profiles")
165+
for key in sliderule.profiles:
166+
print("{:20} {:.6f} secs".format(key + ":", sliderule.profiles[key]))
167+
168+
print("\nICESat2 Timing Profiles")
169+
for key in icesat2.profiles:
170+
print("{:20} {:.6f} secs".format(key + ":", icesat2.profiles[key]))
171+
172+
158173
#
159174
# Display Statistics
160175
#
@@ -171,9 +186,7 @@ def display_statistics(gdf, name):
171186
else:
172187
print("No {} were returned".format(name))
173188

174-
print("\nTiming Profiles")
175-
for key in icesat2.profiles:
176-
print("{:16}: {:.6f} secs".format(key, icesat2.profiles[key]))
189+
display_timing()
177190

178191
#
179192
# Pretty Print JSON

0 commit comments

Comments
 (0)