<jupyter_start><jupyter_text>Generating a custom profile of pressure setpoints1. import the library `PressureSetPointGenerator`  2. create the `waveform` object. If you don't define a Bscan Rep.Rate, it assumes 33.3 Hz3. add custom sections: `add_ramp`, `add_flat`, or `add_oscillations`. 4. See on a plot how the generated waveform looks5. Save it to a `csv` file that can be fed to LabViewRemember:- To create sections, you are asked for positive "suction" values in mbar. Those are intendend as "amount of mbar below atmospheric pressure".<jupyter_code># This is what you set on LabView. It is used here so that you are able to provide the argument
# `time` to the `add_SECTION` functions   
my_BscanRepRate = 33.333 # Hz. 

# Initializing the object - It in now an empty container, we'll fill it in the next cell
wf = PressureSetPointGenerator.waveform(Bscan_RepRate = my_BscanRepRate)

## We create sections, one at a time. 
## Keep 1 second at 0 suction
wf.add_flat(time = 1, level = 0);
## Linearly reach 5mbar suction in 2 seconds
wf.add_ramp(time = 2, to_suction = 500);
## if `add_flat` doesn't receive a level, it keeps the pressure at the last one  
wf.add_flat(time = 2);
## The suction will oscillate between max_lvl and min_lvl, at the specified frequency
## It will start at initial_phase_deg, and will be repeated N_osc
wf.add_oscillations(freq = 1/3, max_lvl=500, min_lvl=200, N_osc=2, initial_phase_deg = 0);
## After the oscillation, we'll go back down to no suction 
wf.add_flat(time =2)
wf.add_ramp(time = 2, to_suction = 0)
# This is what you set on LabView. It is used here so that you are able to provide the argument
# `time` to the `add_SECTION` functions   
my_BscanRepRate = 33.333 # Hz. 

# Initializing the object - It in now an empty container, we'll fill it in the next cell
wf = PressureSetPointGenerator.waveform(Bscan_RepRate = my_BscanRepRate)

wf.add_flat(time = 0.5, level = 0);

## Linearly reach 5mbar suction in 2 seconds
wf.add_ramp(time = 3, to_suction = 500);
wf.add_flat(time = 5);
wf.add_ramp(time = 0.5, to_suction=0)
wf.add_flat(time = 0.5);
# This is what you set on LabView. It is used here so that you are able to provide the argument
# `time` to the `add_SECTION` functions   
my_BscanRepRate = 33.33 # Hz. 

# Initializing the object - It in now an empty container, we'll fill it in the next cell
wf = PressureSetPointGenerator.waveform(Bscan_RepRate = my_BscanRepRate)

wf.add_flat(time = 0.5, level = 0);

## Linearly reach 5mbar suction in 2 seconds
wf.add_ramp(time = 3, to_suction = 200);
wf.add_ramp(time = 3, to_suction = 0)
wf.add_flat(time = 0.3);
## Let's see how the waveform looks live
my_figure = wf.plot();
## The file to feed to LabView is written here.
wf.to_csv('to200in2s_33Hz.csv')<jupyter_output><empty_output><jupyter_text>We can also read the waveform back, from a file that we created before<jupyter_code>input_filename = 'to200in2s_33Hz.csv'
input_wf = PressureSetPointGenerator.waveform()
input_wf.from_csv(input_filename)
input_wf.plot()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup