-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic yaml generation for magnets and screens #101
Automatic yaml generation for magnets and screens #101
Conversation
…ng. Can extract by area
…automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
…tKing06/lcls-tools into 92_automatic_yaml_generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
import meme.names | ||
import numpy as np | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments
] | ||
return areas | ||
|
||
def get_areas(self) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change into property
] | ||
return beampaths | ||
|
||
def get_beam_paths(self) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a property
self, element, pv_information: Optional[Dict[str, str]] = {} | ||
): | ||
sum_l_meters = float(element["SumL (m)"]) if element["SumL (m)"] else -1.0 | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change -1.0 to none or something else?
}, | ||
} | ||
|
||
def _construct_pv_list_from_control_system_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
) | ||
except RuntimeError as rte: | ||
print(rte) | ||
yaml_magnets.update({magnet["Element"]: {}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set value to function in next line instead?
machine_areas = [area] | ||
else: | ||
machine_areas = area | ||
for _area in machine_areas: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this loop the same as magnet loop? combine into utility function?
class YAMLWriter: | ||
def __init__(self): | ||
self.generator = YAMLGenerator() | ||
self.machine_areas = self.generator.areas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just use 'areas' instead of 'machine_area'
def _is_area(self, area: str): | ||
return area in self._machine_areas | ||
|
||
def _constuct_yaml_contents(self, area: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comments
return None | ||
|
||
def write_yaml_file(self, area: Optional[str] = "GUNB") -> None: | ||
if area not in self.machine_areas: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change machine_areas to generator.areas
* magnets and screen conversion from csv to dictionary structures working. Can extract by area * add functionality for extracting multiple areas at once * add PVs to yaml magnets extraction * removing unneeded file * working on adding image pvs to yaml files * working on image device code * flake8 and black formatting * make construction function self, add error handling for MEME timeout * formatting * make area a list in screens * add pv_info to screen construction * restrict wildcard search in meme * add areas and beampaths as members of YAMLGenerator * only construct yaml data if you find a Control System Name * initial class for writing yaml files by area * colon? * unindent loop * return when no devices found for that area * only return info if it exists, otherwise return None * add extra PVs for screen searching * write yaml when you have either magnet or screen contents * remove walrus operator for 3.6 :( * make sum_l_meters a 2 sig fig fp number, make beampaths a list * remove tuple error * force float casting * adding first version of yaml files for magnets and screens * reformat * refactoring extract_devices function from extract_magnets and extract_screens * remove member variable for machine_areas, access only via generator * tidy up with comments * removing files without PV information --------- Co-authored-by: Neveu <nneveu@pc101046.slac.stanford.edu> Co-authored-by: Neveu <nneveu@stanford.edu> Co-authored-by: matt <matt@SLACMachine.myguest.virtualbox.org>
Summary of Changes
Created a generate class to convert csv data into yaml files via classes.
Also, write.py will create yaml files for every area (from lcls_elements.csv) and in each file there will be screen and magnet data injected.
The structure of the file should be as such:
The .yaml files now in
common/devices/yaml
have been created using write.py