Skip to content

Commit

Permalink
Improved merging
Browse files Browse the repository at this point in the history
Now merging happens only with the files contained in the currently loaded group of files.
  • Loading branch information
nickssl committed Jul 10, 2024
1 parent e7f4741 commit d3843b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pytplot/importers/netcdf_to_tplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def netcdf_to_tplot(filenames, time='', prefix='', suffix='', plot=False, merge=
logging.error("Invalid filenames input. Must be string or list of strings.")
return stored_variables

filenames = sorted(list(set(filenames)))
for filename in filenames:

# Read file
Expand Down Expand Up @@ -181,7 +182,9 @@ def netcdf_to_tplot(filenames, time='', prefix='', suffix='', plot=False, merge=
# Store the data, and merge variables if that was requested.
var_name = prefix + var + suffix
to_merge = False
if (var_name in pytplot.data_quants.keys() and (merge == True)):
# Merge only if the variable has been saved already in the current group of files.
# Otherwise, the tplot variable will be replaced.
if (var_name in stored_variables) and (var_name in pytplot.data_quants.keys() and (merge == True)):
prev_data_quant = pytplot.data_quants[var_name]
to_merge = True

Expand Down

0 comments on commit d3843b1

Please sign in to comment.