<commit_before>#!/usr/bin/env python

import sys,os
import pandas as pd
import re
import math

def main():
    """
    NAME
        squidm_magic.py
    DESCRIPTION
        Converts SQUID microscopy files into a MagIC format files.
        This program currently supports only specimens from a single sample.  
        Method codes are applied to all rows in each table. To add method codes
        to individual rows, edit the MagIC file after this program creates it.
        A standard MagiC file is created for the location through specimen tables,
        along with measurement data from the model fits. The SQUID microscopy 
        measurement data is placed in individual files for each experiment in the
        compact MagIC file format. These measurement files are placed in a 
        directory called "measurements".
        
        This program requires a specific directory/file structure to function.
        The top directory should contain directories named for each of the SQUID
        microscopy scan groups. This name will be used as the specimen name in
        the MagIC specimen table that is created by this program. In each scan
        directory there should directories labeled "demag", "data", "images". The
        data directory should contain the .bz and .inf files for each SQUID
        microscopy scan. The .bz and .inf files must have the same name. The 
        demag directory should have a .sam file that has the same name as the
        name of the directory 2 levels up. That is, if the main directory is ZirconRun2,
        then the .sam file should be named ZirconRun2.sam. There should also be
        the CIT formatted files with the model demag data in them along with an 
        associated _fits.txt file that has information about how well the model
        dipole fits the data. In the images directory should be any human viewable
        image files that will be uploaded to MagIC along with the data. .jpg, .png,
        .gif, .pdf, etc. type files.

        Example file directory tree:
        ZirconRun1 -- (file hierarchy) 
        ZirconRun2 -- data -- run2N_140C_100k.bz
                           -- run2N_140C_100k.inf
                           -- run2N_173C_100k.bz
                           -- run2N_173C_100k.inf
                   -- demag -- 57-1-3
                            -- 57-1-3_fits.txt
                            -- 57-19-12
                            -- 57-19-12_fits.txt
                            -- ZirconRun2.sam
                   -- images -- run2N_140C_100k.pdf
                             -- run2S_89G_1M.pdf
        ZirconRun3 -- (file hierarchy)

    SYNTAX
        mit_squid_magic.py [command line options]

    OPTIONS
        -h: prints the help message and quits.

        -meas_name_num: set the starting number for the measurement name. Default:1

        -location: specify location/study name

        -location_type: specify location_type 
                        see https://www.earthref.org/vocabularies/controlled for list 

        -geologic_classes: specify geologic_classes (":" between multiple entries). 
                           see https://www.earthref.org/vocabularies/controlled for list

        -lithologies: specify lithologies. (":" between multiple entries) 
                      see https://www.earthref.org/vocabularies/controlled for list

        -lat: specify the latitude of the site.  

        -lon: specify longitude of the site.

        -age: specify the age of the site.
              One must have an age defined. age_low and age_high can be used in 
              addition to or in place of age.

        -age_sigma: specify the one sigma error on the age.

        -age_low: specify the low bound for the age. 

        -age_high: specify the high bound for the age.

        -age_unit: specify the age unit. ka, Ma, Ga are some examples.
                   see https://www.earthref.org/vocabularies/controlled for list
        -citations: list of citations (":" between entries). default: "This study". 
                    "This study" can be used for the study this MagIC contribution 
                    will be associated with. Will be added when the data is published.
                    Use DOIs for other studies.

        -site: site name for the sample that the scan slides were made from

        -geologic_types: geologic types of the site. (":" between multiple entries)
        
        -sample: sample name from which the slides were made from

        -loc_method_codes: method_codes used for all locations
                       (":" between multiple entries)
                       Recommend

        -site_method_codes: method_codes used for all sites
                       (":" between multiple entries)
                       Required

        -samp_method_codes: method_codes used for all samples
                       (":" between multiple entries)
                       Required

        -spec_method_codes: method_codes used for all specimens
                       (":" between multiple entries)
                       Required

        -meas_method_codes: method_codes used for all measurements
                       (":" between multiple entries)
                       LP-SQUIDM will be automatically added to the measurements method
                       code list if not already in the provided list of codes

        -instrument_codes: used to identify the insturment that made the measurement. 
                           Exact insturment name prefered, not type. 
                           (":" between multiple entries)
    
        -z_pos: distance from the surface in micrometers. default:0

        -oe: flag to use cgs units for magnetic field strength(Oe) or mangnetic moment(emu) 

        -ncn NCON: specify naming convention for the CIT sample files.

      Sample naming convention (NCON): 
        [1] XXXXY: where XXXX is an arbitrary length site designation and Y
            is the single character sample designation.  e.g., TG001a is the
            first sample from site TG001.    [default]
        [2] XXXX-YY: YY sample from site XXXX (XXX, YY of arbitary length)
        [3] XXXX.YY: YY sample from site XXXX (XXX, YY of arbitary length)
        [4-Z] XXXX[YYY]:  YYY is sample designation with Z characters from site XXX
        [5] site name = sample name
        [6] site name entered in sitename column in the orient.txt format input file -- NOT CURRENTLY SUPPORTED
        [7-Z] [XXX]YYY:  XXX is site designation with Z characters from samples  XXXYYY
        NB: all others you will have to either customize your self or e-mail <EMAIL> for help.

      Example command for the example data file. Data from Weiss et al., 2018 (doi:10.1130/G39938.1):
     squidm_magic.py -location "Jack Hills" -location_type "Outcrop" -geologic_classes "Metamorphic" -lithologies "Metaconglomerate" -geologic_types "Single Crystal" -lat "-26" -lon 117 -age_low 0.8 -age_high 2.6 -age_unit Ga -citations "10.1130/G39938.1" -site "Erawandoo Hill" -loc_method_codes "GM-UPB" -site_method_codes "GM-UPB" -samp_method_codes "SC-SQUIDM" -spec_method_codes "SC-SQUIDM" -geologic_types "Single Crystal" -sample RSES-57 -ncn 5 -instrument_codes "MIT SQIUD microscope" -oe 
    
    """

    if '-h' in sys.argv: # check if help is needed
        print(main.__doc__)
        sys.exit() # graceful quit

    if '-meas_name_num' in sys.argv:
        ind=sys.argv.index('-meas_name_num')
        meas_name_num=int(sys.argv[ind+1])
    else:
        meas_name_num=1
<commit_msg>fixed typos in help<commit_after>#!/usr/bin/env python

import sys,os
import pandas as pd
import re
import math

def main():
    """
    NAME
        squidm_magic.py
    DESCRIPTION
        Converts SQUID microscopy files into a MagIC format files.
        This program currently supports only specimens from a single sample.  
        Method codes are applied to all rows in each table. To add method codes
        to individual rows, edit the MagIC file after this program creates it.
        A standard MagiC file is created for the location through specimen tables,
        along with measurement data from the model fits. The SQUID microscopy 
        measurement data is placed in individual files for each experiment in the
        compact MagIC file format. These measurement files are placed in a 
        directory called "measurements".
        
        This program requires a specific directory/file structure to function.
        The top directory should contain directories named for each of the SQUID
        microscopy scan groups. This name will be used as the specimen name in
        the MagIC specimen table that is created by this program. In each scan
        directory there should directories labeled "demag", "data", "images". The
        data directory should contain the .bz and .inf files for each SQUID
        microscopy scan. The .bz and .inf files must have the same name. The 
        demag directory should have a .sam file that has the same name as the
        name of the directory 2 levels up. That is, if the main directory is ZirconRun2,
        then the .sam file should be named ZirconRun2.sam. There should also be
        the CIT formatted files with the model demag data in them along with an 
        associated _fits.txt file that has information about how well the model
        dipole fits the data. In the images directory should be any human viewable
        image files that will be uploaded to MagIC along with the data. .jpg, .png,
        .gif, .pdf, etc. type files.

        Example file directory tree:
        ZirconRun1 -- (file hierarchy) 
        ZirconRun2 -- data -- run2N_140C_100k.bz
                           -- run2N_140C_100k.inf
                           -- run2N_173C_100k.bz
                           -- run2N_173C_100k.inf
                   -- demag -- 57-1-3
                            -- 57-1-3_fits.txt
                            -- 57-19-12
                            -- 57-19-12_fits.txt
                            -- ZirconRun2.sam
                   -- images -- run2N_140C_100k.pdf
                             -- run2S_89G_1M.pdf
        ZirconRun3 -- (file hierarchy)

    SYNTAX
        mit_squid_magic.py [command line options]

    OPTIONS
        -h: prints the help message and quits.

        -meas_name_num: set the starting number for the measurement name. Default:1

        -location: specify location/study name

        -location_type: specify location_type 
                        see https://www.earthref.org/vocabularies/controlled for list 

        -geologic_classes: specify geologic_classes (":" between multiple entries). 
                           see https://www.earthref.org/vocabularies/controlled for list

        -lithologies: specify lithologies. (":" between multiple entries) 
                      see https://www.earthref.org/vocabularies/controlled for list

        -lat: specify the latitude of the site.  

        -lon: specify longitude of the site.

        -age: specify the age of the site.
              One must have an age defined. age_low and age_high can be used in 
              addition to or in place of age.

        -age_sigma: specify the one sigma error on the age.

        -age_low: specify the low bound for the age. 

        -age_high: specify the high bound for the age.

        -age_unit: specify the age unit. ka, Ma, Ga are some examples.
                   see https://www.earthref.org/vocabularies/controlled for list
        -citations: list of citations (":" between entries). default: "This study". 
                    "This study" can be used for the study this MagIC contribution 
                    will be associated with. Will be added when the data is published.
                    Use DOIs for other studies.

        -site: site name for the sample that the scan slides were made from

        -geologic_types: geologic types of the site. (":" between multiple entries)
        
        -sample: sample name from which the slides were made from

        -loc_method_codes: method_codes used for all locations
                       (":" between multiple entries)
                       Recommend

        -site_method_codes: method_codes used for all sites
                       (":" between multiple entries)
                       Required

        -samp_method_codes: method_codes used for all samples
                       (":" between multiple entries)
                       Required

        -spec_method_codes: method_codes used for all specimens
                       (":" between multiple entries)
                       Required

        -meas_method_codes: method_codes used for all measurements
                       (":" between multiple entries)
                       LP-SQUIDM will be automatically added to the measurements method
                       code list if not already in the provided list of codes

        -instrument_codes: used to identify the instrument that made the measurement. 
                           Exact instrument name prefered, not type. 
                           (":" between multiple entries)
    
        -z_pos: distance from the surface in micrometers. default:0

        -oe: flag to use cgs units for magnetic field strength(Oe) or magnetic moment(emu) 

        -ncn NCON: specify naming convention for the CIT sample files.

      Sample naming convention (NCON): 
        [1] XXXXY: where XXXX is an arbitrary length site designation and Y
            is the single character sample designation.  e.g., TG001a is the
            first sample from site TG001.    [default]
        [2] XXXX-YY: YY sample from site XXXX (XXX, YY of arbitrary length)
        [3] XXXX.YY: YY sample from site XXXX (XXX, YY of arbitrary length)
        [4-Z] XXXX[YYY]:  YYY is sample designation with Z characters from site XXX
        [5] site name = sample name
        [6] site name entered in sitename column in the orient.txt format input file -- NOT CURRENTLY SUPPORTED
        [7-Z] [XXX]YYY:  XXX is site designation with Z characters from samples  XXXYYY
        NB: all others you will have to either customize your self or e-mail <EMAIL> for help.

      Example command for the example data file. Data from Weiss et al., 2018 (doi:10.1130/G39938.1):
     squidm_magic.py -location "Jack Hills" -location_type "Outcrop" -geologic_classes "Metamorphic" -lithologies "Metaconglomerate" -geologic_types "Single Crystal" -lat "-26" -lon 117 -age_low 0.8 -age_high 2.6 -age_unit Ga -citations "10.1130/G39938.1" -site "Erawandoo Hill" -loc_method_codes "GM-UPB" -site_method_codes "GM-UPB" -samp_method_codes "SC-SQUIDM" -spec_method_codes "SC-SQUIDM" -geologic_types "Single Crystal" -sample RSES-57 -ncn 5 -instrument_codes "MIT SQIUD microscope" -oe 
    
    """

    if '-h' in sys.argv: # check if help is needed
        print(main.__doc__)
        sys.exit() # graceful quit

    if '-meas_name_num' in sys.argv:
        ind=sys.argv.index('-meas_name_num')
        meas_name_num=int(sys.argv[ind+1])
    else:
        meas_name_num=1

{'fraction_non_alphanumeric': 0.0600568820689199, 'fraction_numerical': 0.016270917388716184, 'mean_word_length': 1.9554339327599688, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '195', 'n_tokens_mistral': 4275, 'n_tokens_neox': 3830, 'n_words': 1677}