Skip to content

Commit

Permalink
Minor/rare bug fixes
Browse files Browse the repository at this point in the history
- When there is no manifest (early qslib eds files), assume spec 1.
- Fix rare line/packet-splitting bug in network communications.
  • Loading branch information
cgevans committed May 29, 2024
1 parent ff3fcad commit e9585da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/qslib/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,15 @@ def from_file(cls, file: str | os.PathLike[str] | IO[bytes]) -> Experiment:

z = zipfile.ZipFile(file)

manifest_info = _get_manifest_info(z, checkinfo=True)
try:
manifest_info = _get_manifest_info(z, checkinfo=True)
exp.spec_major_version = int(manifest_info["Specification-Version"][0])
except ValueError:
exp.spec_major_version = 1


z.extractall(exp._dir_base)

exp.spec_major_version = int(manifest_info["Specification-Version"][0])

exp._update_from_files()

Expand Down Expand Up @@ -2179,6 +2183,8 @@ def plot_over_time(
annotate_events: bool = True,
figure_kw: Mapping[str, Any] | None = None,
line_kw: Mapping[str, Any] | None = None,
start_time = None,
time_units: Literal["hours","seconds"] = "hours"
) -> "Sequence[Axes]":
"""
Plots fluorescence over time, optionally with temperatures over time.
Expand Down Expand Up @@ -2322,6 +2328,13 @@ def plot_over_time(
for processor in process:
reduceddata = processor.process_scoped(reduceddata, "limited")

if start_time is None:
start_time_value = 0.0
elif isinstance(start_time, (int, float)):
start_time_value = start_time
else:
raise TypeError("start_time invalid type")

lines = []
for filter in filters:
filterdat: pd.DataFrame = reduceddata.loc[filter.lowerform, :] # type: ignore
Expand All @@ -2341,7 +2354,7 @@ def plot_over_time(

lines.append(
ax[0].plot(
filterdat.loc[stages, ("time", "hours")],
filterdat.loc[stages, ("time", time_units)] - start_time_value,
filterdat.loc[stages, (well, "fl")],
label=label,
marker=marker,
Expand Down Expand Up @@ -2411,7 +2424,7 @@ def plot_over_time(
tmin, tmax = np.inf, 0.0

for i, fr in reduceddata.groupby("filter_set", as_index=False):
d = fr.loc[i, ("time", "hours")].loc[stages]
d = fr.loc[i, ("time", time_units)].loc[stages]
tmin = min(tmin, d.min())
tmax = max(tmax, d.max())

Expand Down
2 changes: 1 addition & 1 deletion src/qslib/qs_is_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from .scpi_commands import AccessLevel, SCPICommand, _arglist

NL_OR_Q = re.compile(rb"(?:\n|<(/?)([\w.]+)[ *]*>?)")
NL_OR_Q = re.compile(rb"(?:\n|<(/?)([\w.]*)[ *]*>?)")
TIMESTAMP = re.compile(rb"(\d{8,}\.\d{3})")

log = logging.getLogger(__name__)
Expand Down

0 comments on commit e9585da

Please sign in to comment.