sevnpy.io.logreader
Logfile Handling, (sevny.io.logreader)
This module contains methods and utilities to read the SEVN logfiles
- readlogfiles:
wrapper function to easily read the logfiles
- readlogstr:
wrapper function to easily read a log message from a string
- logcolumns_info:
Methods returning info about the columns from the various events in the logfile
- logevents_list:
Methods returning a list of all the available events
Class
- LogReader:
this is the basic class used to read the logfile getting the information of a specific event from the logfile. It automatically set the necessary information to read the Header file, but the “schema” of the body needs to be provided. The module contains a list of pre-made classes inherited from LogReader to read all the events in the SEVN logfile
Developers: how to add a new specific LogReader class.
Let’s assume that we want to define a new class that can be used to read the information of a new event called SPAM. The event only is triggered by the single stellar evolution and produce just two values that we call Atest and Btest, Aspam is in an integer value while Bspam is a float. The schema will be
>>> body_schema={"Aspam": (int, "information about Aspam"), "Bspam": (float,"information about Bspam")}
So we will define a new class following the name structure <EVENTNAME>LogReader, since the event is triggered from SSE this class will inherit from _SSELogReader (that inherits from _SpecialisedLogReader and hence LogReader) to automatically include the informationa about the header. In case the log event had been triggered by BSE, the class would have inherited from _BSELogReader. Then we have to define just the log_event name and the body schema, and optionally, but is warmly suggested a shor description of the event in the attribute event_description
>>> class SPAMLogReader(_SpecialisedLogReader):
>>> log_event = "SPAM"
>>> event_description = "A simple example"
>>> body_schema={"Aspam": (int, "information about Aspam"), "Bspam": (float,"information about Bspam")}
If we know that such event need to happen only once for a star or a binary (e.g. the event SN for a star), it is enough to add as a first parent class _OnlyOnePerSystemGetLast or _OnlyOnePerSystemGetFirst, the first one automatically remove the duplicates base on name,ID and IDfile mantaining the last occurence, while the last one mantain just the last occurence. So for example
>>> class SPAMLogReader(_OnlyOnePerSystemGetLast,_SpecialisedLogReader):
>>> log_event = "SPAM"
>>> event_description = "A simple example"
>>> body_schema={"Aspam": (int, "information about Aspam"), "Bspam": (float,"information about Bspam")}
Finally we have to include a new item (“SPAM”,SPAMLogReader) in the module attribute _logevents.
At this point the new log events will appear in the available logevents list and can be read thorugh the wrapper function readlogfiles.
Functions
Return the info about the values stored in a given event |
|
Return the list of the available log events |
|
Read a series of logfiles retrieving the information for the events in input |
|
Read a log string retrieving the information for the events in input |
Classes
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Basic class to read a log file |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |
|
Specialised |