Skip to content

Latest commit

 

History

History
86 lines (73 loc) · 9.33 KB

which-function.md

File metadata and controls

86 lines (73 loc) · 9.33 KB

Which function do I need?

Find your task, then the function for it in your language; each links its Reference entry. How to use them is in the guide, starting at Save and read a file; whole scripts are in the Examples.

Files

I want to… Python (lbd) MATLAB (lbd) Julia (LBD)
build a measurement in memory [Dataset][lbd.Dataset], [add_axis][lbd.Dataset.add_axis], [add_value][lbd.Dataset.add_value] lbd.Dataset, addAxis, addValue Dataset, add_axis!, add_value!
fill a value point by point [Dataset.write][lbd.Dataset.write] write write!
save it [Dataset.save][lbd.Dataset.save] save LBD.save
check before a long measurement [Dataset.check][lbd.Dataset.check], save(dry_run=True) check, save(DryRun=true) LBD.check, save(dry_run=true)
read a file [lbd.load][lbd.load] lbd.load LBD.load
read only some values [lbd.load][lbd.load] with values= lbd.load with Values= LBD.load with values=
list or check many files quickly [lbd.info][lbd.info] lbd.info LBD.info
read part of a file larger than memory [lbd.open][lbd.open] lbd.open, lbd.OnDisk LBD.open, OnDisk
change a file in place, without loading it [lbd.open][lbd.open] with mode="r+" lbd.open with Mode="r+" LBD.open with mode="r+"
change measured data on purpose (the rules) [Dataset.save][lbd.Dataset.save] with overwrite=True, [lbd.open][lbd.open] with mode="r+", overwrite=True d.save with Overwrite=true, lbd.open with Mode="r+", Overwrite=true LBD.save with overwrite=true, LBD.open with mode="r+", overwrite=true
a variable sweep (axis group) [add_group][lbd.Dataset.add_group] addGroup add_group!
a variable sweep as a rectangle, by row, as points [to_dense][lbd.Dataset.to_dense], [rows][lbd.Dataset.rows], [coords][lbd.Dataset.coords] toDense, rows, coords to_dense, rows, coords
save a loaded file as a new measurement [Dataset.new_id][lbd.Dataset.new_id] newId new_id!
save a style whole with the data [Dataset.set_style][lbd.Dataset.set_style] setStyle set_style!
give a file a saved view without rewriting it [lbd.set_plot][lbd.set_plot] none: load, set Plot, save none: load, set plot, LBD.save
know which version is installed [lbd.version][lbd.version] lbd.version LBD.version

Labels

I want to… Python MATLAB Julia
set labels on a dataset or Writer [Labels][lbd.Labels], [add_tags][lbd.Dataset.add_tags] Labels, addTags Labels, add_tags!
read a file's labels [lbd.labels][lbd.labels] lbd.labels LBD.labels
change a file's labels without rewriting it [lbd.set_labels][lbd.set_labels], [lbd.remove_labels][lbd.remove_labels] lbd.setLabels, lbd.removeLabels LBD.set_labels, LBD.remove_labels

Writing while measuring

I want to… Python MATLAB Julia
write a file while measuring [lbd.Writer][lbd.Writer] lbd.Writer LBD.Writer
write the data I just measured [Writer.write][lbd.Writer.write] w.write write!
make readers see it now [Writer.flush][lbd.Writer.flush] w.flush flush
finish the file [Writer.close][lbd.Writer.close] (the with block) w.close close (the do-block)
stop on an error, keeping what was measured the with block does it w.abort in catch the do-block does it (abort!)
know whether a file is still measured [lbd.writing_status][lbd.writing_status] lbd.writingStatus writing_status
how far a measurement is [lbd.writing_progress][lbd.writing_progress] none: read name.lbd.live as JSON none: read name.lbd.live as JSON
recover a stopped measurement, repair a marked file, read a rescue file [lbd.recover][lbd.recover] lbd.recover recover

Figures from Python (lbd.plot)

Python only: from another language, save the file and open it in LBD Viewer, or draw it from Python; it looks the same. How: Plotting from your code (Python).

import lbd.plot as lp     # pip install "lbd[plot]"
I want to… Use Example
plot an .lbd file like the viewer [lp.plot][lbd.plot.plot] lp.plot("signal.lbd")
plot a Dataset in memory (saved or not) [lp.plot][lbd.plot.plot] lp.plot(d, "heatmap", "signal", complex="db")
plot plain arrays [lp.quick][lbd.plot.quick] lp.quick(t, v, x_unit="s", y_unit="V")
a figure with several panels [lp.plot][lbd.plot.plot] with ax= Panels
style a figure I draw with matplotlib [lp.use][lbd.plot.use] with lp.use("thesis"): fig, ax = plt.subplots()
style every figure in a notebook [lp.activate][lbd.plot.activate] lp.activate("thesis")
another size, or a grid of axes [lp.subplots][lbd.plot.subplots] lp.subplots(1, 2, figsize=(170 / 25.4, 64 / 25.4))
restyle a figure made by other code [lp.apply][lbd.plot.apply] lp.apply(fig, "thesis")
readable units (7e9 Hz → 7 GHz) or a fixed prefix [lp.prefix][lbd.plot.prefix] f, unit = lp.prefix(f, "Hz", to="M")
an axis title with its unit [lp.axis_label][lbd.plot.axis_label] lp.axis_label("Frequency", unit)
save exactly like the viewer exports [lp.save][lbd.plot.save] lp.save(fig, "fig.pdf", style="thesis")
the numbers a plot shows, as CSV [lp.table][lbd.plot.table] lp.table("signal.lbd", "curve", "signal").to_csv("s.csv")
see the preset names [lp.list_styles][lbd.plot.list_styles] lp.list_styles()
read or change settings in Python [lp.load_style][lbd.plot.load_style] s = lp.load_style("thesis"); s.rcparams["font.size"]
see what a style looks like, without data of your own [lp.preview][lbd.plot.preview] fig = lp.preview("thesis", sample="map")
keep a style next to a paper's data [Style.save][lbd.plot.style.Style.save] lp.load_style("thesis").save("thesis.lbd.json")
give a style to someone without LBD [Style.to_mplstyle][lbd.plot.style.Style.to_mplstyle] mplstyle recipe
create, change or delete a preset [PresetStore][lbd.plot.PresetStore] lp.PresetStore().save("paper", {...})
the exact style the viewer uses for a file [lp.plot][lbd.plot.plot] without style= (the style saved in the file, else [PresetStore.resolve][lbd.plot.PresetStore.resolve]) lp.plot(d)

When something goes wrong

Functions raise an error when they can't do what was asked (the message names the problem and the valid choices) and give a warning when they did it but ignored or adjusted something. Nothing is dropped silently. The errors of each language: Python (and lbd.plot), MATLAB, Julia.