Module azcam.header

Contains the Header and System classes.

Classes

class Header (title: str = '', template=None)

Defines the Header class which is used to create and manipulate headers contained in many azcam tools.

Attributes

self.title (str): header title dictionary {index:title_line} self.keywords (dict): header keywords dictionary {keyword:keywordstring} self.values (dict): header values dictionary {keyword:value} self.comments (dict): header comments dictionary {keyword:comment} self.typestrings (dict): header typestrings dictionary {keyword:typestring) self.items (list): list of header objects Create instance.

Args

title
title of header to be used in image header
template
filename of template file with static header info

Methods

def convert_type(self, value, pythontype)

Convert a value to a specific type.

def copy_all_items(self, ptr_header)

Copy all items from the specified header object to the current image header.

def delete_all_items(self)

Delete all header items

def delete_all_keywords(self)

Delete all keywords.

def delete_keyword(self, keyword: str)

Delete a keyword.

def get_header(self) ‑> list

Returns the header list.

Returns

list of header lines
[Header[]]: Each element contains (keyword,value,comment,type).
def get_keyword(self, keyword: str) ‑> list

Return a keyword value, its comment string, and type. Comment always returned in double quotes, even if empty.

Args

keyword : str
name of keyword

Returns

list of [keyword, comment, type]

def get_keywords(self)

Return a list of all keyword names.

Returns

keywords
list of all keywords
def get_string(self)

Returns the entire header as a single formatted string.

def read_file(self, filename='')

Read a header file and import the data into the header.

def set_header(self, object_name: str, order: int = -1)

Sets object_name in the global header dictionary. order defines how headers are written in image files.

Args

object_name
name of header object
order
order to be shown in image header (-1 next)
def set_keyword(self, keyword, value, comment=None, typestring=None)

Set a keyword value, comment, and type.

Args

keyword
keyword
value
value of keyword
comment
comment string
typestring
one of 'str', 'int', or 'float'
def set_keyword_string(self, keystring)

Set keyword data from a single string.

def set_title(self, title)

Set the title of the header.

def update(self)

Update header.

class ObjectHeaderMethods

Header methods for main objects. These are called like "controller.get_keyword()".

Subclasses

Methods

def define_keywords(self)

Defines and resets keywords.

def delete_keyword(self, keyword: str)

Delete a keyword.

Args

keyword
keyword
def get_keyword(self, keyword: str) ‑> list

Return a keyword value, its comment string, and type. Comment always returned in double quotes, even if empty.

Args

keyword
name of keyword

Returns

list of [keyword, comment, type]

def get_keywords(self) ‑> list

Return a list of all keyword names.

Returns

keywords
list of all keywords
def read_header(self) ‑> list

Reads and returns current header data.

Returns

list of header lines
[Header[]]: Each element contains (keyword,value,comment,type).
Example
Header[2][1] is the value of keyword 2 and Header[2][3] is its type.
def set_keyword(self, keyword: str, value: Any, comment: str = 'none', typestring: str = 'none')

Set a keyword value, comment, and type.

Args

keyword
keyword
value
value of keyword
comment
comment string
typestring
one of 'str', 'int', or 'float'
def update_header(self)

Update the header, reading current data. Deletes all keywords if the object is not enabled.

class System (system_name, template_file=None)

System class.

Ancestors

Methods

def define_keywords(self)

Inherited from: ObjectHeaderMethods.define_keywords

Defines and resets keywords.

def delete_keyword(self, keyword: str)

Inherited from: ObjectHeaderMethods.delete_keyword

Delete a keyword.

Args

keyword
keyword
def get_keyword(self, keyword: str) ‑> list

Inherited from: ObjectHeaderMethods.get_keyword

Return a keyword value, its comment string, and type. Comment always returned in double quotes, even if empty.

Args

keyword
name of keyword

def get_keywords(self) ‑> list

Inherited from: ObjectHeaderMethods.get_keywords

Return a list of all keyword names.

Returns

keywords
list of all keywords
def read_header(self) ‑> list

Inherited from: ObjectHeaderMethods.read_header

Reads and returns current header data.

Returns

list of header lines
[Header[]]: Each element contains (keyword,value,comment,type).
Example
def set_keyword(self, keyword: str, value: Any, comment: str = 'none', typestring: str = 'none')

Inherited from: ObjectHeaderMethods.set_keyword

Set a keyword value, comment, and type.

Args

keyword
keyword
value
value of keyword
comment
comment string
typestring
one of …
def update_header(self)

Inherited from: ObjectHeaderMethods.update_header

Update the header, reading current data. Deletes all keywords if the object is not enabled.