mt_metadata.transfer_functions.io.edi.metadata.header
Classes
A partial location class that only includes the latitude, longitude, and elevation. |
Module Contents
- class mt_metadata.transfer_functions.io.edi.metadata.header.Header(**data)
Bases:
mt_metadata.common.BasicLocation,mt_metadata.common.GeographicLocationA partial location class that only includes the latitude, longitude, and elevation. This is used to avoid circular imports.
- acqby: Annotated[str | None, Field(default=None, description='person, group, company, university that collected the data', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['mt experts']})]
- acqdate: Annotated[mt_metadata.common.mttime.MTime | str | float | int | numpy.datetime64 | pandas.Timestamp, Field(default_factory=lambda: MTime(time_stamp=None), description='Start date the time series data were collected', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['2020-01-01']})]
- coordinate_system: Annotated[mt_metadata.common.GeographicReferenceFrameEnum, Field(default='geographic', description='coordinate system the transfer function is currently in. Its preferred the transfer function be in a geographic coordinate system for archiving and sharing.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['geopgraphic']})]
- dataid: Annotated[str, Field(default='', description='station ID.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['mt001']})]
- enddate: Annotated[mt_metadata.common.mttime.MTime | str | float | int | numpy.datetime64 | pandas.Timestamp | None, Field(default_factory=lambda: MTime(time_stamp=None), description='End date the time series data were collected', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['2020-01-01']})]
- empty: Annotated[float, Field(default=1e+32, description='null data values, usually a large number', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['1E+32']})]
- fileby: Annotated[str, Field(default='', description='person, group, company, university that made the file', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['mt experts']})]
- filedate: Annotated[mt_metadata.common.mttime.MTime | str | float | int | numpy.datetime64 | pandas.Timestamp, Field(default_factory=lambda: MTime(time_stamp=None), description='Date the file was made', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['2020-01-01']})]
- progdate: Annotated[mt_metadata.common.mttime.MTime | str | float | int | numpy.datetime64 | pandas.Timestamp, Field(default_factory=lambda: MTime(time_stamp=None), description='Date of the most recent update of the program used to make the file', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['2020-01-01']})]
- progname: Annotated[str, Field(default='mt_metadata', description='Name of the program used to make the file.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['mt_metadata']})]
- progvers: Annotated[str, Field(default='0.1.6', description='Version of the program used to make the file.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['0.1.6']})]
- project: Annotated[str | None, Field(default=None, description='Name of the project the data was collected for, usually a short description or acronym of the project name.', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['iMUSH']})]
- prospect: Annotated[str | None, Field(default=None, description='Name of the prospect the data was collected for, usually a short description of the location', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['Benton']})]
- loc: Annotated[str | None, Field(default=None, description='Usually a short description of the location', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['Benton, CA']})]
- declination: Annotated[mt_metadata.common.Declination, Field(default_factory=lambda: Declination(value=0.0), description='Declination of the station in degrees', alias=None, json_schema_extra={'units': 'degrees', 'required': True, 'examples': ['Declination(10.0)']})]
- stdvers: Annotated[mt_metadata.common.StdEDIversionsEnum, Field(default='SEG 1.0', description='EDI standards version SEG 1.0', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['SEG 1.0']})]
- survey: Annotated[str | None, Field(default=None, description='Name of the survey', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['CONUS']})]
- units: Annotated[str | None, Field(default='milliVolt per kilometer per nanoTesla', description='In the EDI standards this is the elevation units, in newer versions this should be units of the transfer function.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['milliVolt per kilometer per nanoTesla']})]
- classmethod validate_acqdate(field_value)
- classmethod validate_units(value)
- get_header_list(edi_lines)
Get the header information from the .edi file in the form of a list.
Extracts header lines from an EDI file, returning each key-value pair as a formatted string.
- Parameters:
edi_lines (list of str) – List of lines from an EDI file to parse for header information.
- Returns:
List of header key-value pairs in the format ‘key=value’.
- Return type:
list of str
Examples
>>> header = Header() >>> edi_lines = ['>HEAD', 'DATAID=MT001', 'LAT=45.5', '>'] >>> header.get_header_list(edi_lines) ['DATAID=MT001', 'LAT=45.5']
- read_header(edi_lines)
Read and parse header information from EDI file lines.
Parses header lines from an EDI file and populates the Header object attributes with the corresponding values. Handles special cases like Phoenix-formatted EDI files and coordinate system normalization.
- Parameters:
edi_lines (list of str) – List of lines from an EDI file containing header information.
- Returns:
Updates the object’s attributes in place.
- Return type:
None
Examples
>>> header = Header() >>> edi_lines = ['>HEAD', 'DATAID=MT001', 'LAT=45:30:00', 'LON=-122:30:00', '>'] >>> header.read_header(edi_lines) >>> header.dataid 'mt001' >>> header.latitude 45.5
Notes
Station IDs are automatically validated and normalized to lowercase
Coordinate systems are normalized to ‘geographic’, ‘geomagnetic’, or ‘station’
Phoenix MT-Editor format is automatically detected
- write_header(longitude_format='LON', latlon_format='dms', required=False)
Write header information to a list of formatted lines for EDI output.
Formats all header attributes as EDI-compliant key-value pairs. Automatically updates file metadata (filedate, progvers, progname) to current values.
- Parameters:
longitude_format ({'LON', 'LONG'}, default 'LON') – Format for longitude field name in output.
latlon_format ({'dms', 'dd'}, default 'dms') – Format for latitude/longitude values. - ‘dms’: degrees:minutes:seconds (e.g., ‘45:30:00’) - ‘dd’: decimal degrees (e.g., ‘45.500000’)
required (bool, default False) – If True, only include required fields in output.
- Returns:
List of formatted header lines starting with ‘>HEAD’ and ending with a blank line. Each data line follows the format ‘KEY=value’.
- Return type:
list of str
Examples
>>> header = Header(dataid='mt001', latitude=45.5, longitude=-122.5) >>> lines = header.write_header(latlon_format='dd') >>> print(lines[0]) >HEAD >>> print(lines[1]) DATAID=mt001
>>> # Write with degrees-minutes-seconds format >>> lines_dms = header.write_header(latlon_format='dms') >>> # Latitude will be formatted as 45:30:00
Notes
filedate is automatically set to current UTC time
progvers is set to mt_metadata version
Zero declination values are omitted from output
None values are skipped