J-Files

J-files are the output format of the BIRRP procesing code written by Alan Chave. Not totally sure what the provenance of the format is, but it’s technically the Alan Jones format. Nevertheless it exists and we shall try to accommodate it.

The metadata is minimal, but self describes where the station is located.

The data are represented as transfer function estimates and data errors.

Warning: There is no write method yet or TF.to_jfile() method.

[1]:
from mt_metadata import TF_JFILE
from mt_metadata.transfer_functions import TF
from mt_metadata.transfer_functions.io.jfiles import JFile

J file format

The J-file is not a common format, lets have a look at the header. It contains BIRRP processing parameters, a null location, a rotation angle and a station name. The data are in blocks that have the format (period, real, imaginary, error, coherence, coherence)

[2]:
with open(TF_JFILE, "r") as fid:
    lines = fid.readlines()

print("".join(lines[0:36]))
#BIRRP Version 5 basic mode output
#outputs=       2 inputs=       2 references=       2
#tbw=   2.000000     deltat=  0.1000000
#nfft=    5164 nsctinc=       2 nsctmax=       7
#nf1=       4 nfinc=       2 nfsect=       2
#uin=   0.000000     ainlin=  -999.0000     ainuin=  0.9990000
#c2threshe=  0.7000000
#nz=       0
#c2threshe1=   0.000000
# npcs=       1 nar=       3
#imode=       2 jmode=       0
#nfil=       0
#ncomp=       4
#indices=       1       2       3       4
#filnam=/data/mtpy/examples/birrp_processing/birrp_wd/birrp_data_3.txt
#nskip=       0 nread=   38750
#nfil=      0
#ncomp=       4
#indices=       3       4
#filnam=/data/mtpy/examples/birrp_processing/birrp_wd/birrp_data_3.txt
#nskip=       0 nread=   38750
#theta1=   0.000000     theta2=   90.00000     phi=   0.000000
#theta1=   0.000000     theta2=   90.00000     phi=   0.000000
#theta1=   0.000000     theta2=   90.00000     phi=   0.000000
>LATITUDE  =
>LONGITUDE =
>ELEVATION =
>AZIMUTH   =    0.000000
BP05
ZXX S.I.
14
    1.333333       8.260304       9.270211      0.9625573      0.5000000      0.4335710
    2.000000       6.266990       9.504742       1.045094      0.7272727      0.6245316
    2.683333       5.705301       14.69156       1.828255      0.5636364      0.5054545
    4.025000       7.892698       27.24741       2.497948      0.6727273      0.5981818
    5.366667       4.128862       32.00328       5.598819      0.5185185      0.4222222

Translation to TF

The translation is straight forward, most of the metadata is stored in station_metadata.transfer_function.processing_parameters

[3]:
tf_object = TF(fn=TF_JFILE)
tf_object.read()
j_object = JFile(fn=TF_JFILE)
[4]:
j_object.header
[4]:
{
    "header": {
        "azimuth": 0.0,
        "declination.model": "WMM",
        "declination.value": 0.0,
        "elevation": 0.0,
        "latitude": 0.0,
        "longitude": 0.0,
        "station": "BP05",
        "title": "BIRRP Version 5 basic mode output"
    }
}
[5]:
j_object.header.birrp_parameters
[5]:
{
    "birrp_parameters": {
        "ainlin": -999.0,
        "ainuin": 0.999,
        "c2threshe": 0.7,
        "c2threshe1": 0.0,
        "deltat": 0.1,
        "imode": 2,
        "inputs": 2,
        "jmode": 0,
        "nar": 3,
        "ncomp": 0,
        "nf1": 4,
        "nfft": 5164.0,
        "nfinc": 2,
        "nfsect": 2,
        "npcs": 1,
        "nsctinc": 2.0,
        "nsctmax": 7.0,
        "nz": 0,
        "outputs": 2,
        "references": 2,
        "tbw": 2.0,
        "uin": 0.0
    }
}
[6]:
tf_object.station_metadata
[6]:
{
    "station": {
        "channels_recorded": [
            "ex",
            "ey",
            "hx",
            "hy"
        ],
        "data_type": "MT",
        "geographic_name": null,
        "id": "BP05",
        "location.declination.model": "WMM",
        "location.declination.value": 0.0,
        "location.elevation": 0.0,
        "location.latitude": 0.0,
        "location.longitude": 0.0,
        "orientation.method": null,
        "orientation.reference_frame": "geographic",
        "provenance.archive.name": null,
        "provenance.creation_time": "1980-01-01T00:00:00+00:00",
        "provenance.creator.name": null,
        "provenance.software.author": null,
        "provenance.software.name": "BIRRP",
        "provenance.software.version": "5",
        "provenance.submitter.email": null,
        "provenance.submitter.name": null,
        "provenance.submitter.organization": null,
        "release_license": "CC0-1.0",
        "run_list": [
            "001"
        ],
        "time_period.end": "1980-01-01T00:00:00+00:00",
        "time_period.start": "1980-01-01T00:00:00+00:00",
        "transfer_function.coordinate_system": "geopgraphic",
        "transfer_function.data_quality.rating.value": 0,
        "transfer_function.id": "BP05",
        "transfer_function.processed_by.name": null,
        "transfer_function.processed_date": "2023-04-21",
        "transfer_function.processing_parameters": [
            "ainlin = -999.0",
            "ainuin = 0.999",
            "c2threshe = 0.7",
            "c2threshe1 = 0.0",
            "deltat = 0.1",
            "imode = 2",
            "inputs = 2",
            "jmode = 0",
            "nar = 3",
            "ncomp = 0",
            "nf1 = 4",
            "nfft = 5164.0",
            "nfinc = 2",
            "nfsect = 2",
            "npcs = 1",
            "nsctinc = 2.0",
            "nsctmax = 7.0",
            "nz = 0",
            "outputs = 2",
            "references = 2",
            "tbw = 2.0",
            "uin = 0.0"
        ],
        "transfer_function.processing_type": null,
        "transfer_function.remote_references": [],
        "transfer_function.runs_processed": [
            "001"
        ],
        "transfer_function.sign_convention": null,
        "transfer_function.software.author": null,
        "transfer_function.software.name": null,
        "transfer_function.software.version": null,
        "transfer_function.units": null
    }
}

Statistical Estimates

The statistical estimates are the impedance, tipper and errors

[7]:
print(j_object.z[0])
print(tf_object.impedance[0].data)
[[  8.260304 +9.270211j  24.26376 -26.85942j ]
 [-24.24131 +38.11477j   -2.271694 -8.677796j]]
[[  8.260304 +9.270211j  24.26376 -26.85942j ]
 [-24.24131 +38.11477j   -2.271694 -8.677796j]]
[8]:
print(j_object.z_err[0])
print(tf_object.impedance_error[0].data)
[[0.9625573 2.303654 ]
 [0.8457434 1.930154 ]]
[[0.9625573 2.303654 ]
 [0.8457434 1.930154 ]]
[9]:
tf_object.dataset
[9]:
<xarray.Dataset>
Dimensions:                        (period: 12, output: 5, input: 5)
Coordinates:
  * period                         (period) float64 1.333 2.0 ... 43.03 64.55
  * output                         (output) <U2 'ex' 'ey' 'hx' 'hy' 'hz'
  * input                          (input) <U2 'ex' 'ey' 'hx' 'hy' 'hz'
Data variables:
    transfer_function              (period, output, input) complex128 (nan+na...
    transfer_function_error        (period, output, input) float64 nan ... nan
    transfer_function_model_error  (period, output, input) float64 nan ... nan
    inverse_signal_power           (period, output, input) complex128 (nan+na...
    residual_covariance            (period, output, input) complex128 0j ... 0j
Attributes: (12/14)
    survey:             0
    project:            None
    id:                 BP05
    name:               None
    latitude:           0.0
    longitude:          0.0
    ...                 ...
    datum:              None
    acquired_by:        None
    start:              1980-01-01T00:00:00+00:00
    end:                1980-01-01T00:00:00+00:00
    runs_processed:     ['001']
    coordinate_system:  geographic
[ ]: