api documentation¶
main module¶
-
peakTree.check_part_not_reproduced(tree, spectrum)[source]¶ check how good the moments in the tree (only leave nodes) represent the original spectrum (i.e. if there are non-Gaussian peaks)
Parameters: - tree – a tree in the traversed (dict) format
- spectrum – and the corresponding spectrum
Returns: number of bins, where the reprocduced spectrum differs by more than 7dB
-
peakTree.saveVar(dataset, varData, dtype=<class 'numpy.float32'>)[source]¶ save an item to the dataset with data in a dict
Parameters: - ( (dataset) – obj:netCDF4.Dataset): netcdf4 Dataset to add to
- dtype – datatype of the array
- varData (dict) – data to add, for example:
Key Description var_namename of the variable dimension('time', 'height')arrdata long_namedescriptive long name optional commentdescription as a sentence unitsstring with units units_htmlunits in the html formatting missing_valuedefine missing value plot_rangetuple of range to plot plot_scale“linear” or “log” axis
-
peakTree.time_index(timestamps, sel_ts)[source]¶ get the index of a timestamp in the list
Parameters: - timestamps – array
- sel_ts – timestamp whose index is required
-
peakTree.get_time_grid(timestamps, ts_range, time_interval, filter_empty=True)[source]¶ get the mapping from timestamp indices to gridded times eg for use in interpolation routines
https://gist.github.com/martin-rdz/b7c3b9f06bb41aeb6b2fb6c888275e26
Parameters: - timestamps – list of timestamps
- ts_range – range fo the gridded timestamps
- time_interval – interval of the gridded timestamps
- filter_empty (bool, optional) – include the bins that are empty
Returns: list of (timestamp_begin, timestamp_end, grid_mid, index_begin, index_end, no_indices)
-
peakTree.get_averaging_boundaries(array, slice_length, zero_index=0)[source]¶ get the left and right indices each element in an array for a given averaging slice_length
-
class
peakTree.peakTreeBuffer(config_file='instrument_config.toml', system='Lacros')[source]¶ trees for a time-height chunk
Parameters: - config_file (string, optional) – path to the instrument config file (.toml)
- system (string, optional) – specify the system/campaign
The attribute setting may contain
Key Description decouplingdecoupling of the crosschannel smoothflag if smoothing should be applied grid_timetime in seconds to average the spectra max_no_nodesnumber of nodes to save thres_factor_cofactor between noise_lvl and noise thres in co channel thres_factor_cxfactor between noise_lvl and noise thres in cross ch. station_altitudeheight of station above msl -
load(filename, load_to_ram=False)[source]¶ convenience fuction for loader call reads the self.loader (as specified in the instrument_config)
-
load_spec_file(filename, load_to_ram=False)[source]¶ load spectra from raw file
Parameters: filename – specify file
-
load_peakTree_file(filename)[source]¶ load preprocessed peakTree file
Parameters: filename – specify file
-
load_kazr_file(filename, load_to_ram=False)[source]¶ load a kazr file
Parameters: filename – specify file
-
load_newkazr_file(filename, load_to_ram=False)[source]¶ load a kazr file
Parameters: filename – specify file
-
load_rpgbinary_spec(filename, load_to_ram=False)[source]¶ load the rpg binary (.LV0) file directly; requires rpgpy
Parameters: - filename – path to file
- load_to_ram (optional False) –
- 2022-07-25: reimplemented the polarimetry based on sldr_bulk_revised-seeding_case.ipynb
- and the communication with A. Myagkov
developed with rpgpy version 0.10.2
-
load_rpgpy_spec(filename, load_to_ram=False)[source]¶ WIP implementation of the rpgpy spectra format
-
get_tree_at(sel_ts, sel_range, temporal_average='fromparams', roll_velocity=False, peak_finding_params={}, tail_filter=False, silent=False)[source]¶ get a single tree either from the spectrum directly (prior call of load_spec_file()) or from the pre-converted file (prior call of load_peakTree_file())
Parameters: - sel_ts (tuple or float) – either value or (index, value)
- sel_range (tuple or float) – either value or (index, value)
- temporal_average (optional) – average over the interval (tuple of bin in time dimension or ‘fromparams’ or False)
- roll_velocity (optional) – shift the x rightmost bins to the left
- peak_finding_params (optional) –
- silent – verbose output
‘vel_smooth’: convolution with given array ‘prom_thres’: prominence threshold in dB
Returns: dictionary with all nodes and the parameters of each node
print_tree¶
output of visualized trees as text, plots and schematic graphs
-
peakTree.print_tree.coord_pattern_child(p)[source]¶ the coordinate pattern required for filtering the dictionary for children for use in
iterchilds()Parameters: p – coordinate of parent Returns: function that thest if a coordinate is a child of p
-
peakTree.print_tree.iterchilds(travtree, parentcoord)[source]¶ generator that yields all childs of a parent with given coordinats for use in
iternodes()
-
peakTree.print_tree.travtree2text(travtree, show_coordinates=True)[source]¶ returns a string with the tabular representation of the traversed tree
Parameters: - travtree – traversed tree
- show_coordinates (optional) – include the coordinates
Returns: string with line breaks
-
peakTree.print_tree.gen_lines_to_par(travtree)[source]¶ get all the connection lines between the nodes of travtree
Returns: list of coordinate pairs [(v,z), ..]
-
peakTree.print_tree.plot_spectrum(travtree, spectrum, savepath)[source]¶ plot the spectrum together with the traversed tree
Parameters: - travtree – traversed tree
- spectrum – spectrum dict
- savepath – either
Noneor string
Returns: fig, ax
helpers¶
Collection of common helper functions.
-
peakTree.helpers.list_of_elem(elem, length)[source]¶ return a list of given length of given elements
-
peakTree.helpers.epoch_to_timestamp(time_raw)[source]¶ converts raw time (days since year 0) to unix timestamp
-
peakTree.helpers.divide_bounds(bounds)[source]¶ divide_bounds([[10,20],[20,25],[25,30],[40,50]]) => noise_sep [[10, 30], [40, 50]], internal [20, 25]
-
peakTree.helpers.fill_with(array, mask, fill)[source]¶ fill array with fill value where mask is True
-
peakTree.helpers.round_odd(f)[source]¶ round to odd number :param f: float number to be rounded to odd number
-
peakTree.helpers.flatten(xs)[source]¶ flatten inhomogeneous deep lists e.g.
[[1,2,3],4,5,[6,[7,8],9],10]