p2obt.backend.parse#

p2obt.backend.parse.parse_array_config(line: str | None = None) List[str][source]#

Parses the array configuration from string containing it.

Parameters:

run_name (str, optional) – The name of the run.

Returns:

array_configuration – Either “UTs”, “small”, “medium”, “large” or “extended”.

Return type:

str

p2obt.backend.parse.parse_file_section(lines: List, identifier: str) Dict[source]#

Parses the section of a file that corresponds to the given identifier and returns a dict with the keys being the match to the identifier and the values being a subset of the lines list.

Parameters:
  • lines (list) – The lines read from a file.

  • identifier (str) – The identifier by which they should be split into subsets.

Returns:

subset – A dict that contains a subsets of the original lines.

Return type:

dict

p2obt.backend.parse.parse_groups(section: List) Dict[source]#

Parses any combination of a calibrator-science target block into a dictionary containing the individual blocks’ information.

Parameters:

section (list) – A section of a night plan (either a run or a night of a run).

Returns:

data – The individual science target/calibrator group within a section. Can be for instance, “SCI-CAL” or “CAL-SCI-CAL” or any combination.

Return type:

dict

p2obt.backend.parse.parse_line(parts: str) str[source]#

Parses a line from a night plan generated with the calibrator_find -tool and returns the objects name.

Parameters:

parts (str) – The line split into its individual components.

Returns:

target_name – The target’s name.

Return type:

str

p2obt.backend.parse.parse_night_name(night_name: str) str[source]#

Automatically gets the night’s date from a night key of the dictionary if the date it is included in the key.

Parameters:

night_name (str) – The dictionary’s key for a night.

Returns:

  • night (str) – The parsed night name.

  • date (str, optional) – The parsed date.

p2obt.backend.parse.parse_night_plan_to_dict(night_plan: Path, run_identifier: str | None = 'run', night_identifier: str | None = 'night') Dict[str, Dict][source]#

Parses the night plan created with calibrator_find.pro into the individual runs as key of a dictionary.

The parsed runs are specified by the ‘run_identifier’. The parsed nights are specified by the ‘night_identifier’. If no sections via the ‘run_identifier’ can be matched, then the full file will be parsed for nights and saved as ‘full_run’. The same happens if no match via the ‘night_identifier’ can be made then it parses all within a run into ‘full_night’.

Parameters:
  • night_plan (path) – The path to the night plan, a (.txt)-file containing the observations for one or more runs.

  • run_identifier (str, optional) – The run-identifier by which the night plan is split into individual runs.

  • night_identifier (str, optional) – The night-identifier by which the runs are split into the individual nights.

Returns:

night_dict – A dictionary containing the individual runs, their nights and in those the individual observing blocks for the science targets with their associated calibrators.

Return type:

dict

p2obt.backend.parse.parse_observation_type(line: str) str[source]#

Parses the run’s observation type from string containing it.

Parameters:

run_name (str) – The name of the run.

Returns:

resolution – Either “LOW”, “MED” or “HIGH”.

Return type:

str

p2obt.backend.parse.parse_operational_mode(line: str) str[source]#

Parses the run’s used instrument from string containing it, either MATISSE or GRA4MAT.

Parameters:

run_name (str) – The name of the run.

Returns:

operational_mode – Either “MATISSE” or “GRA4MAT”.

Return type:

str

p2obt.backend.parse.parse_resolution(line: str) str[source]#

Parses the run’s resolution from string containing it.

Parameters:

run_name (str) – The name of the run.

Returns:

resolution – Either “LOW”, “MED” or “HIGH”.

Return type:

str

p2obt.backend.parse.parse_run_prog_id(run_name: str) str[source]#

Parses the run’s resolution from string containing it.

If no match can be found it prompts the user for manual resolution input.

Parameters:

run_name (str) – The name of the run.

Returns:

run_prog_id – The run’s program id in the form of <period>.<program>.<run> (e.g., 110.2474.004).

Return type:

str