示例#1
0
def main():
    """
    NAME
        upload_magic.py
   
    DESCRIPTION
        This program will prepare your PMAG text files created by the programs nfo_magic.py, 
        zeq_magic.py, thellier_magic.py, mag_magic, specimens_results_magic.py and so on.  
        it will check for all the MagIC text files and skip the missing ones
    
    SYNTAX
        upload_magic.py 

    INPUT
        MagIC txt files

    OPTIONS
        -h prints help message and quits
        -all include all the measurement data, default is only those used in interpretations

    OUTPUT
        upload.txt:  file for uploading to MagIC database
    """    
    if '-h' in sys.argv:
        print main.__doc__
        sys.exit()
    else:
        dataframe = extractor.command_line_dataframe([['cat', False, 0], ['F', False, ''], ['f', False, '']])
        checked_args = extractor.extract_and_check_args(sys.argv, dataframe)
        dir_path, concat = extractor.get_vars(['WD', 'cat'], checked_args)
        ipmag.upload_magic(concat, dir_path)
示例#2
0
def main():
    """
    NAME
        combine_magic.py

    DESCRIPTION
        Combines magic format files of the same type together.

    SYNTAX
        combine_magic.py [-h] [-i] -out filename -in file1 file2 ....

    OPTIONS
        -h prints help message
        -i allows interactive  entry of input and output filenames
        -F specify output file name [must come BEFORE input file names]
        -f specify input file names [ must come last]
    """
    if "-h" in sys.argv:
        print main.__doc__
        sys.exit()
    if "-i" in sys.argv: # interactive
        dataset,datasets=[],[]
        while True:
            infile=raw_input('\n\n Enter magic files for combining, <return>  when done: ')
            if infile=='':
                break
            if os.path.isfile(infile):
                filenames.append(infile)
            else:
                print "-W- You have not provided a valid filename.\nIf the file is not in your current working directory, you will need to provide the full path to the file"
        outfile=raw_input('\n\n Enter name for new combined file')
        if not outfile:
            return False
            
    else: # non-interactive

        dataframe = extractor.command_line_dataframe([["F", True, '']])
        args = extractor.extract_and_check_args(sys.argv, dataframe)
        dir_path, outfile, filenames = extractor.get_vars(["WD", "F", "f"], args)
        #dir_path = pmag.get_named_arg_from_sys("-WD", ".")
        #outfile = pmag.get_named_arg_from_sys("-F", reqd=True)
        #if "-f" in sys.argv:
        #    ind=sys.argv.index("-f")
        #    for k in range(ind+1,len(sys.argv)):
        #        filenames.append(os.path.join(dir_path, sys.argv[k]))
        #else:
        #    raise pmag.MissingCommandLineArgException("-f")
                
    ipmag.combine_magic(filenames.split(), outfile)
示例#3
0
def main():
    """ 
    IODP_samples_magic.py
    OPTIONS:
        -f FILE, input csv file
        -Fsa FILE, output er_samples.txt file for updating, default is to overwrite er_samples.txt
    """
    if "-h" in sys.argv:
        print main.__doc__
        sys.exit()

    dataframe = extractor.command_line_dataframe([['WD', False, '.'], ['ID', False, '.'], ['f', True, ''], ['Fsa', False, None]])
    args = sys.argv
    checked_args = extractor.extract_and_check_args(args, dataframe)
    samp_file, output_samp_file, output_dir_path, input_dir_path = extractor.get_vars(['f', 'Fsa', 'WD', 'ID'], checked_args)
    ipmag.IODP_samples_magic(samp_file, output_samp_file, output_dir_path, input_dir_path)
示例#4
0
def main():
    """
    NAME
        download_magic.py

    DESCRIPTION	
        unpacks a magic formatted smartbook .txt file from the MagIC database into the
        tab delimited MagIC format txt files for use with the MagIC-Py programs.

    SYNTAX
        download_magic.py command line options]
    INPUT
        takes either the upload.txt file created by upload_magic.py or the file
        exported by the MagIC v2.2 console software (downloaded from the MagIC database
        or output by the Console on your PC).

    OPTIONS
        -h prints help message and quits
        -i allows interactive entry of filename
        -f FILE specifies input file name
        -O do not overwrite duplicate Location_* directories while downloading
    """
    if '-h' in sys.argv:
        print main.__doc__
        sys.exit()
    # interactive entry
    if '-i' in sys.argv:
        infile=raw_input("Magic txt file for unpacking? ")
        dir_path = '.'
        input_dir_path = '.'
    # non-interactive
    else:
        dataframe = extractor.command_line_dataframe([['O', False, True]])
        checked_args = extractor.extract_and_check_args(sys.argv, dataframe)
        infile, dir_path, input_dir_path, overwrite = extractor.get_vars(['f', 'WD', 'ID', 'O'], checked_args)

    ipmag.download_magic(infile, dir_path, input_dir_path, overwrite)
示例#5
0
def main():
    """
    NAME
        sufar4-asc_magic.py

    DESCRIPTION
        converts ascii files generated by SUFAR ver.4.0 to MagIC formated
        files for use with PmagPy plotting software

    SYNTAX
        sufar4-asc_magic.py -h [command line options]

    OPTIONS
        -h: prints the help message and quits
        -f FILE: specify .asc input file name
        -fsi SINFILE: specify er_specimens input file
        -F MFILE: specify magic_measurements output file
        -Fa AFILE: specify rmag_anisotropy output file
        -Fr RFILE: specify rmag_results output file
        -Fsi SFILE: specify er_specimens output file with location, sample, site, etc. information
        -usr USER: specify who made the measurements
        -loc LOC: specify location name for study 
        -ins INST: specify instrument used
        -spc SPEC: specify number of characters to specify specimen from sample
        -ncn NCON:  specify naming convention: default is #2 below
        -k15 : specify static 15 position mode - default is spinning
        -new : replace all existing magic files

    DEFAULTS
        AFILE: rmag_anisotropy.txt
        RFILE: rmag_results.txt
        SFILE: default is to create new er_specimen.txt file
        USER: ""
        LOC: "unknown"
        INST: ""
        SPEC: 0  sample name is same as site (if SPEC is 1, sample is all but last character)
        appends to  'er_specimens.txt, er_samples.txt, er_sites.txt' files
       Sample naming convention:
            [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 same as sample
            [6] site is entered under a separate column
            [7-Z] [XXXX]YYY:  XXXX is site designation with Z characters with sample name XXXXYYYY
            NB: all others you will have to customize your self
                 or e-mail [email protected] for help.
            [8] This is a synthetic
            [9] ODP naming convention

    """

    args = sys.argv
    if '-h' in args:
        print main.__doc__
        sys.exit()

    dataframe = extractor.command_line_dataframe([ ['WD', False, '.'], ['ID', False, '.'], ['usr', False, ''], ['ncn', False, '1'], ['k15', False, False], ['ins', False, ''], ['f', True, ''], ['F', False, 'magic_measurements.txt'], ['Fa', False, 'rmag_anisotropy.txt'], ['Fsi', False, 'er_specimens.txt'], ['loc', False, 'unknown'], ['spc', False, 0], ['fsi', False, None]])
    #'WD', 'ID', 'usr', 'ncn', 'k15', 'ins', 'f', 'F', 'Fa', 'Fsi', 'loc', 'spc',
    checked_args = extractor.extract_and_check_args(args, dataframe)
    output_dir_path, input_dir_path, user, sample_naming_con, static_15_position_mode, instrument, ascfile, meas_output, aniso_output, spec_outfile, locname, specnum, spec_infile = extractor.get_vars(['WD', 'ID', 'usr', 'ncn', 'k15', 'ins', 'f', 'F', 'Fa', 'Fsi', 'loc', 'spc', 'fsi'], checked_args)

    ipmag.SUFAR4_magic(ascfile, meas_output, aniso_output, spec_infile, spec_outfile, specnum=specnum, sample_naming_con=sample_naming_con, user=user, locname=locname, instrument=instrument, static_15_position_mode=static_15_position_mode, output_dir_path=output_dir_path, input_dir_path=input_dir_path)
示例#6
0
def main():
    """
    NAME 
        ani_depthplot.py

    DESCRIPTION
        plots tau, V3_inc, V1_dec, P and chi versus core_depth

    SYNTAX
        ani_depthplot.py [command line optins]

    OPTIONS
        -h prints help message and quits
        -f FILE: specify input rmag_anisotropy format file from magic
        -fb FILE: specify input magic_measurements format file from magic
        -fsa FILE: specify input er_samples format file from magic 
        -fsum FILE : specify input LIMS database (IODP) core summary csv file
                to print the core names, set lab to 1
        -fa FILE: specify input er_ages format file from magic 
        -d min max [in m] depth range to plot
        -ds [mcd,mbsf], specify depth scale, default is mbsf
        -sav save plot without review
        -fmt specfiy format for figures - default is svg
     DEFAULTS:
         Anisotropy file: rmag_anisotropy.txt
         Bulk susceptibility file: magic_measurements.txt
         Samples file: er_samples.txt
    """


    args = sys.argv
    if '-h' in args:
        print main.__doc__
        sys.exit()
    dataframe = extractor.command_line_dataframe([['f', False, 'rmag_anisotropy.txt'],  ['fb', False, 'magic_measurements.txt'], ['fsa', False, 'er_samples.txt'], ['fa', False, None], ['fsum', False, None], ['fmt', False, 'svg'], ['ds', False, 'mbsf'], ['d', False, '-1 -1'], ['sav', False, False], ['WD', False, '.' ]])
        #args = sys.argv
    checked_args = extractor.extract_and_check_args(args, dataframe)
    ani_file, meas_file, samp_file, age_file, sum_file, fmt, depth_scale, depth, save_quietly, dir_path = extractor.get_vars(['f', 'fb', 'fsa', 'fa', 'fsum', 'fmt', 'ds', 'd', 'sav', 'WD'], checked_args)

    # format min/max depth
    try:
        dmin, dmax = depth.split()
        dmin, dmax = float(dmin), float(dmax)
    except:
        print 'you must provide depth in this format: -d dmin dmax'
        print 'could not parse "{}", defaulting to plotting all depths'.format('-d ' + str(depth))
        dmin, dmax = -1, -1

    if depth_scale:
        if age_file:
            depth_scale = 'age'
        elif 'mbsf' in depth_scale:
            depth_scale = 'sample_core_depth'
        elif 'mcd' in depth_scale:
            depth_scale = 'sample_composite_depth'
        else:
            print 'Warning: Unrecognized option "{}" provided for depth scale.\nOptions for depth scale are mbsf -- meters below sea floor -- or mcd -- meters composite depth.\nAlternatively, if you provide an age file the depth scale will be automatically set to plot by age instead.\nUsing default "mbsf"'.format(depth_scale)
            depth_scale = 'sample_composite_depth'
            
    fig, figname = ipmag.aniso_depthplot(ani_file, meas_file, samp_file, age_file, sum_file, fmt, dmin, dmax, depth_scale, dir_path)
    if save_quietly:
        if dir_path == '.':
            dir_path = os.getcwd()
        print 'Saved file: {} in folder: {}'.format(figname, dir_path)
        return False
    
    app = wx.App(redirect=False)
    if not fig:
        pw.simple_warning('No plot was able to be created with the data you provided.\nMake sure you have given all the required information and try again')
        return False

    dpi = fig.get_dpi()
    pixel_width = dpi * fig.get_figwidth()
    pixel_height = dpi * fig.get_figheight()
    figname = os.path.join(dir_path, figname)
    plot_frame = pmag_menu_dialogs.PlotFrame((int(pixel_width), int(pixel_height + 50)), fig, figname)

    app.MainLoop()
示例#7
0
def main():
    """
    NAME
        orientation_magic.py
   
    DESCRIPTION
        takes tab delimited field notebook information and converts to MagIC formatted tables
 
    SYNTAX
        orientation_magic.py [command line options]

    OPTIONS
        -f FILE: specify input file, default is: orient.txt
        -Fsa FILE: specify output file, default is: er_samples.txt 
        -Fsi FILE: specify output site location file, default is: er_sites.txt 
        -app  append/update these data in existing er_samples.txt, er_sites.txt files
        -ocn OCON:  specify orientation convention, default is #1 below
        -dcn DCON [DEC]: specify declination convention, default is #1 below
            if DCON = 2, you must supply the declination correction 
        -BCN don't correct bedding_dip_dir for magnetic declination -already corrected 
        -ncn NCON:  specify naming convention: default is #1 below
        -a: averages all bedding poles and uses average for all samples: default is NO
        -gmt HRS:  specify hours to subtract from local time to get GMT: default is 0
        -mcd: specify sampling method codes as a colon delimited string:  [default is: FS-FD:SO-POM]
             FS-FD field sampling done with a drill
             FS-H field sampling done with hand samples
             FS-LOC-GPS  field location done with GPS
             FS-LOC-MAP  field location done with map
             SO-POM   a Pomeroy orientation device was used
             SO-ASC   an ASC orientation device was used

    
        Orientation convention:
            Samples are oriented in the field with a "field arrow" and measured in the laboratory with a "lab arrow". The lab arrow is the positive X direction of the right handed coordinate system of the specimen measurements. The lab and field arrows may  not be the same. In the MagIC database, we require the orientation (azimuth and plunge) of the X direction of the measurements (lab arrow). Here are some popular conventions that convert the field arrow azimuth (mag_azimuth in the orient.txt file) and dip (field_dip in orient.txt) to the azimuth and plunge  of the laboratory arrow (sample_azimuth and sample_dip in er_samples.txt). The two angles, mag_azimuth and field_dip are explained below. 

            [1] Standard Pomeroy convention of azimuth and hade (degrees from vertical down) 
                 of the drill direction (field arrow).  lab arrow azimuth= sample_azimuth = mag_azimuth; 
                 lab arrow dip = sample_dip =-field_dip. i.e. the lab arrow dip is minus the hade.
            [2] Field arrow is the strike  of the plane orthogonal to the drill direction,
                 Field dip is the hade of the drill direction.  Lab arrow azimuth = mag_azimuth-90 
                 Lab arrow dip = -field_dip 
            [3] Lab arrow is the same as the drill direction; 
                 hade was measured in the field.  
                 Lab arrow azimuth = mag_azimuth; Lab arrow dip = 90-field_dip
            [4] lab azimuth and dip are same as mag_azimuth, field_dip : use this for unoriented samples too
            [5] Same as AZDIP convention explained below - 
                azimuth and inclination of the drill direction are mag_azimuth and field_dip; 
                lab arrow is as in [1] above. 
                lab azimuth is same as mag_azimuth,lab arrow dip=field_dip-90
            [6] Lab arrow azimuth = mag_azimuth-90; Lab arrow dip = 90-field_dip
            [7] all others you will have to either customize your 
                self or e-mail [email protected] for help.  
       
         Magnetic declination convention:
            [1] Use the IGRF value at the lat/long and date supplied [default]
            [2] Will supply declination correction
            [3] mag_az is already corrected in file 
            [4] Correct mag_az but not bedding_dip_dir
    
         Sample naming convention:
            [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 site_name column in the orient.txt format input file  
            [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 protected] for help.  
    OUTPUT
            output saved in er_samples.txt and er_sites.txt - will overwrite any existing files 
    """
    args = sys.argv
    if "-h" in args:
        print main.__doc__
        sys.exit()
    else:
        info = [['WD', False, '.'], ['ID', False, '.'], ['f', False, 'orient.txt'], ['app', False, False], ['ocn', False, 1], ['dcn', False, 1], ['BCN', False, True], ['ncn', False, '1'], ['gmt', False, 0], ['mcd', False, ''], ['a', False, False]]

        #output_dir_path, input_dir_path, orient_file, append, or_con, dec_correction_con, samp_con, hours_from_gmt, method_codes, average_bedding
        # leave off -Fsa, -Fsi b/c defaults in command_line_extractor
        dataframe = extractor.command_line_dataframe(info)
        checked_args = extractor.extract_and_check_args(args, dataframe)
        output_dir_path, input_dir_path, orient_file, append, or_con, dec_correction_con, bed_correction, samp_con, hours_from_gmt, method_codes, average_bedding, samp_file, site_file = extractor.get_vars(['WD', 'ID', 'f', 'app', 'ocn', 'dcn', 'BCN', 'ncn', 'gmt', 'mcd', 'a', 'Fsa', 'Fsi'], checked_args)

        if not isinstance(dec_correction_con, int):
            if len(dec_correction_con) > 1:
                dec_correction = int(dec_correction_con.split()[1])
                dec_correction_con = int(dec_correction_con.split()[0])
            else:
                dec_correction = 0
        else:
            dec_correction = 0

        ipmag.orientation_magic(or_con, dec_correction_con, dec_correction, bed_correction, samp_con, hours_from_gmt, method_codes, average_bedding, orient_file, samp_file, site_file, output_dir_path, input_dir_path, append)

    #def orientation_magic(or_con=1, dec_correction_con=1, dec_correction=0, bed_correction=True, samp_con='1', hours_from_gmt=0, method_codes='', average_bedding=False, orient_file='orient.txt', samp_file='er_samples.txt', site_file='er_sites.txt', output_dir_path='.', input_dir_path='.', append=False):
    

##example use:
##make a pandas dataframe with three columns:
## col 1 is the command-line flag (minus the '-'), common ones include f, F, fsa, Fsa, etc.
## col 2 is a boolean for if the flag is required or not
## col 3 is a default value to use if the flag is not provided
#dataframe = command_line_dataframe([['sav', False, 0], ['fmt', False, 'svg'], ['s', False, 20]])
## get the args from the command line:
#args = sys.argv
## check through the args to make sure that reqd args are present, defaults are used as needed, and invalid args are ignored
#checked_args = extract_and_check_args(args, dataframe)
## assign values to variables based on their associated command-line flag
#fmt, size, plot = get_vars(['fmt', 's', 'sav'], checked_args)
#print "fmt:", fmt, "size:", size, "plot:", plot

            
    
    ignore="""
示例#8
0
def main():
    """
    NAME
        kly4s_magic.py

    DESCRIPTION
        converts files generated by SIO kly4S labview program to MagIC formated
        files for use with PmagPy plotting software

    SYNTAX
        kly4s_magic.py -h [command line options]

    OPTIONS
        -h: prints the help message and quits
        -i: allows interactive input of input/output filenames
        -f FILE: specify .ams input file name
        -fad AZDIP: specify AZDIP file with orientations, will create er_samples.txt file
        -fsa SFILE: specify existing er_samples.txt file with orientation information
        -fsp SPFILE: specify existing er_specimens.txt file for appending 
        -F MFILE: specify magic_measurements output file
        -Fa AFILE: specify rmag_anisotropy output file
        -ocn ORCON:  specify orientation convention: default is #3 below -only with AZDIP file
        -usr USER: specify who made the measurements
        -loc LOC: specify location name for study 
        -ins INST: specify instrument used
        -spc SPEC: specify number of characters to specify specimen from sample
        -ncn NCON:  specify naming convention: default is #1 below

    DEFAULTS
        MFILE: magic_measurements.txt
        AFILE: rmag_anisotropy.txt
        SPFILE: create new er_specimens.txt file
        USER: ""
        LOC: "unknown" 
        INST: "SIO-KLY4S"
        SPEC: 1  specimen name is same as sample (if SPEC is 1, sample is all but last character)
    NOTES:
        Sample naming convention:
            [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] XXXXYYY:  YYY is sample designation with Z characters from site XXX
            [5] all others you will have to either customize your 
                self or e-mail [email protected] for help.  
       Orientation convention:
            [1] Lab arrow azimuth= azimuth; Lab arrow dip=-dip
                i.e., dip is degrees from vertical down - the hade [default]
            [2] Lab arrow azimuth = azimuth-90; Lab arrow dip = -dip
                i.e., azimuth is strike and dip is hade
            [3] Lab arrow azimuth = azimuth; Lab arrow dip = dip-90
                e.g. dip is degrees from horizontal of drill direction
            [4] Lab arrow azimuth = azimuth; Lab arrow dip = dip 
            [5] Lab arrow azimuth = azimuth; Lab arrow dip = 90-dip 
            [6] all others you will have to either customize your
                self or e-mail [email protected] for help.

    """

    #def kly4s_magic(infile, specnum=0, locname="unknown", inst='SIO-KLY4S', samp_con="1", or_con='3' ,user='', measfile='magic_measurements.txt', aniso_outfile='rmag_anisotropy.txt', samp_infile='', spec_infile='', azdip_infile='', output_dir_path='.', input_dir_path='.'):
    args = sys.argv
    if '-h' in args:
        print main.__doc__
        sys.exit()
    dataframe = extractor.command_line_dataframe([['f', True, ''], ['fad', False, ''], ['fsa', False, ''], ['fsp', False, ''], ['Fsp', False, 'er_specimens.txt'], ['F', False, 'magic_measurements.txt'], ['Fa', False, 'rmag_anisotropy.txt'], ['ocn', False, '3'], ['usr', False, ''], ['loc', False, ''], ['ins', False, 'SIO-KLY4S'], ['spc', False, 0], ['ncn', False, '1'], ['WD', False, '.'], ['ID', False, '.'] ])
    checked_args = extractor.extract_and_check_args(args, dataframe)
    infile, azdip_infile, samp_infile, spec_infile, spec_outfile, measfile, aniso_outfile, or_con, user, locname, inst, specnum, samp_con, output_dir_path, input_dir_path = extractor.get_vars(['f', 'fad', 'fsa', 'fsp', 'Fsp', 'F', 'Fa', 'ocn', 'usr', 'loc', 'ins', 'spc', 'ncn', 'WD', 'ID'], checked_args)
    ipmag.kly4s_magic(infile, specnum=specnum, locname=locname, inst=inst, user=user, or_con=or_con, samp_con=samp_con, aniso_outfile=aniso_outfile, samp_infile=samp_infile, spec_infile=spec_infile, spec_outfile=spec_outfile, azdip_infile=azdip_infile, output_dir_path=output_dir_path, input_dir_path=input_dir_path)
示例#9
0
def main():
    """
    NAME
        k15_magic.py

    DESCRIPTION
        converts .k15 format data to magic_measurements  format.
        assums Jelinek Kappabridge measurement scheme
   
    SYNTAX 
        k15_magic.py [-h] [command line options]
    
    OPTIONS
        -h prints help message and quits
        -f KFILE: specify .k15 format input file
        -F MFILE: specify magic_measurements format output file
        -Fsa SFILE, specify er_samples format file for output 
        -Fa AFILE, specify rmag_anisotropy format file for output
        -Fr RFILE, specify rmag_results format file for output
        -loc LOC: specify location name for study
    #-ins INST: specify instrument that measurements were made on # not implemented
        -spc NUM: specify number of digits for specimen ID, default is 0
        -ncn NCOM: specify naming convention (default is #1)
       Sample naming convention:
            [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] XXXXYYY:  YYY is sample designation with Z characters from site XXX
            [5] sample = site
            [6] sample, site, location info in er_samples.txt
            [7] all others you will have to either customize your

    DEFAULTS
        MFILE: k15_measurements.txt
        SFILE: er_samples.txt
        AFILE: rmag_anisotropy.txt
        RFILE: rmag_results.txt
        LOC: unknown
        INST: unknown
        
    INPUT
      name [az,pl,strike,dip], followed by
      3 rows of 5 measurements for each specimen

    """
    args = sys.argv
    if '-h' in args:
        print do_help()
        sys.exit()

    #def k15_magic(k15file, specnum=0, sample_naming_con='1', er_location_name="unknown", measfile='magic_measurements.txt', sampfile="er_samples.txt", aniso_outfile='rmag_anisotropy.txt', result_file="rmag_results.txt", input_dir_path='.', output_dir_path='.'):

    dataframe = extractor.command_line_dataframe([['f', True, ''], ['F', False, 'magic_measurements.txt'], ['Fsa', False, 'er_samples.txt'], ['Fa', False, 'rmag_anisotropy.txt'], ['Fr', False, 'rmag_results.txt'], ['spc', False, 0], ['ncn', False, '1'], ['loc', False, 'unknown'], ['WD', False, '.'], ['ID', False, '.']])
    checked_args = extractor.extract_and_check_args(args, dataframe)
    k15file, measfile, sampfile, aniso_outfile, result_file, specnum, sample_naming_con, location_name, output_dir_path, input_dir_path = extractor.get_vars(['f', 'F', 'Fsa', 'Fa', 'Fr', 'spc', 'ncn', 'loc', 'WD', 'ID'], checked_args)
    program_ran, error_message = ipmag.k15_magic(k15file, specnum=specnum, sample_naming_con=sample_naming_con, er_location_name=location_name, measfile=measfile, sampfile=sampfile, aniso_outfile=aniso_outfile, result_file=result_file, input_dir_path=input_dir_path, output_dir_path=output_dir_path)

## assign values to variables based on their associated command-line flag
#fmt, size, plot = get_vars(['fmt', 's', 'sav'], checked_args)
#print "fmt:", fmt, "size:", size, "plot:", plot


    """
示例#10
0
def main():
    """
    NAME 
        core_depthplot.py

    DESCRIPTION
        plots various measurements versus core_depth or age.  plots data flagged as 'FS-SS-C' as discrete samples.  

    SYNTAX
        core_depthplot.py [command line optins]

    OPTIONS
        -h prints help message and quits
        -f FILE: specify input magic_measurments format file from magi
        -fsum FILE: specify input LIMS database (IODP) core summary csv file
        -fwig FILE: specify input depth,wiggle to plot, in magic format with sample_core_depth key for depth
        -fsa FILE: specify input er_samples format file from magic for depth
        -fa FILE: specify input er_ages format file from magic for age
              NB: must have either -fsa OR -fa (not both)
        -fsp FILE sym size: specify input zeq_specimen format file from magic, sym and size
              NB: PCAs will have specified color, while fisher means will be white with specified color as the edgecolor
        -fres FILE specify input pmag_results file from magic, sym and size
        -LP [AF,T,ARM,IRM, X] step [in mT,C,mT,mT, mass/vol] to plot 
        -S do not plot blanket treatment data (if this is set, you don't need the -LP)
        -sym SYM SIZE, symbol, size for continuous points (e.g., ro 5, bs 10, g^ 10 for red dot, blue square, green triangle), default is blue dot at 5 pt
        -D do not plot declination
        -M do not plot magnetization
        -log  plot magnetization  on a log scale
        -L do not connect dots with a line
        -I do not plot inclination
        -d min max [in m] depth range to plot
        -n normalize by weight in er_specimen table
        -Iex: plot the expected inc at lat - only available for results with lat info in file
        -ts TS amin amax: plot the GPTS for the time interval between amin and amax (numbers in Ma)
           TS: [ck95, gts04, gts12] 
        -ds [mbsf,mcd] specify depth scale, mbsf default 
        -fmt [svg, eps, pdf, png] specify output format for plot (default: svg)
        -sav save plot silently

     DEFAULTS:
         Measurements file: magic_measurements.txt
         Samples file: er_samples.txt
         NRM step
         Summary file: none
    """

    args = sys.argv
    if '-h' in args:
        print main.__doc__
        sys.exit()

    dataframe = extractor.command_line_dataframe([ ['f', False, ''], ['fsum', False, ''],
                                                   ['fwig', False, ''], ['fsa', False, ''],
                                                   ['fa', False, ''], ['fsp', False, ''],
                                                   ['fres', False, '' ],  ['fmt', False, 'svg'], 
                                                   ['LP', False,  ''], ['n', False, False], 
                                                   ['d', False, '-1 -1'], ['ts', False, ''],
                                                   ['WD', False, '.'], ['L', False, True],
                                                   ['S', False, True], ['D', False, True],
                                                   ['I', False, True], ['M', False, True],
                                                   ['log', False,  0],
                                                   ['ds', False, 'sample_core_depth'],
                                                   ['sym', False, 'bo 5'], ['ID', False, '.']])

    checked_args = extractor.extract_and_check_args(args, dataframe)
    meas_file, sum_file, wig_file, samp_file, age_file, spc_file, res_file, fmt, meth, norm, depth, timescale, dir_path, pltLine, pltSus, pltDec, pltInc, pltMag, logit, depth_scale, symbol, input_dir = extractor.get_vars(['f', 'fsum', 'fwig', 'fsa', 'fa', 'fsp', 'fres', 'fmt',  'LP', 'n', 'd', 'ts', 'WD', 'L', 'S', 'D', 'I', 'M', 'log', 'ds', 'sym', 'ID'], checked_args)

    # format some variables
    # format symbol/size
    try:
        sym, size = symbol.split()
        size = int(size)
    except:
        print 'you should provide -sym in this format: ro 5'
        print 'using defaults instead'
        sym, size = 'ro', 5

    # format result file, symbol, size
    if res_file:
        try:
            res_file, res_sym, res_size = res_file.split()
        except:
            print 'you must provide -fres in this format: -fres filename symbol size'
            print 'could not parse {}, defaulting to using no result file'.format(res_file)
            res_file, res_sym, res_size = '', '', 0
    else:
        res_file, res_sym, res_size = '', '', 0

    # format specimen file, symbol, size
    if spc_file:
        try:
            spc_file, spc_sym, spc_size = spc_file.split()
        except:
            print 'you must provide -fsp in this format: -fsp filename symbol size'
            print 'could not parse {}, defaulting to using no specimen file'.format(spc_file)
            spc_file, spc_sym, spc_size = '', '', 0
    else:
        spc_file, spc_sym, spc_size = '', '', 0

    # format min/max depth
    try:
        dmin, dmax = depth.split()
    except:
        print 'you must provide -d in this format: -d dmin dmax'
        print 'could not parse {}, defaulting to plotting all depths'.format(depth)
        dmin, dmax = -1, -1

    # format timescale, min/max time
    if timescale:
        try:
            timescale, amin, amax = timescale.split()
            pltTime = True
        except:
            print 'you must provide -ts in this format: -ts timescale minimum_age maximum_age'
            print 'could not parse {}, defaulting to using no timescale'.format(timescale)
            timescale, amin, amax = None, -1, -1
            pltTime = False
    else:
        timescale, amin, amax = None, -1, -1
        pltTime = False
            

    # format norm and wt_file
    if norm and not isinstance(norm, bool):
        wt_file = norm
        norm = True
    else:
        norm = False
        wt_file = ''

    # format list of protcols and step
    try:
        method, step = meth.split()
    except:
        print 'To use the -LP flag you must provide both the protocol and the step in this format:\n-LP [AF,T,ARM,IRM, X] step [in mT,C,mT,mT, mass/vol] to plot'
        print 'Defaulting to using no protocol'
        method, step = 'LT-NO', 0

    # list of varnames
    #['f', 'fsum', 'fwig', 'fsa', 'fa', 'fsp', 'fres', 'fmt',  'LP', 'n', 'd', 'ts', 'WD', 'L', 'S', 'D', 'I', 'M', 'log', 'ds', 'sym' ]
    #meas_file, sum_file, wig_file, samp_file, age_file, spc_file, res_file, fmt, meth, norm, depth, timescale, dir_path, pltLine, pltSus, pltDec, pltInc, pltMag, logit, depth_scale, symbol

    fig, figname = ipmag.core_depthplot(input_dir, meas_file, spc_file, samp_file, age_file, sum_file, wt_file, depth_scale, dmin, dmax, sym, size, spc_sym, spc_size, method, step, fmt, pltDec, pltInc, pltMag, pltLine, pltSus, logit, pltTime, timescale, amin, amax, norm)


    app = wx.App(redirect=False)
    if not fig:
        pw.simple_warning('No plot was able to be created with the data you provided.\nMake sure you have given all the required information and try again')
        return False

    dpi = fig.get_dpi()
    pixel_width = dpi * fig.get_figwidth()
    pixel_height = dpi * fig.get_figheight()
    figname = os.path.join(dir_path, figname)
    plot_frame = pmag_menu_dialogs.PlotFrame((int(pixel_width), int(pixel_height + 50)), fig, figname)

    app.MainLoop()
示例#11
0
def main():
    """
    NAME
        azdip_magic.py
   
    DESCRIPTION
        takes space delimited AzDip file and converts to MagIC formatted tables
 
    SYNTAX
        azdip_magic.py [command line options]

    OPTIONS
        -f FILE: specify input file
        -Fsa FILE: specify output file, default is: er_samples.txt 
        -ncn NCON:  specify naming convention: default is #1 below
        -mcd: specify sampling method codes as a colon delimited string:  [default is: FS-FD]
             FS-FD field sampling done with a drill
             FS-H field sampling done with hand samples
             FS-LOC-GPS  field location done with GPS
             FS-LOC-MAP  field location done with map
             SO-POM   a Pomeroy orientation device was used
             SO-ASC   an ASC orientation device was used
             SO-MAG   orientation with magnetic compass
        -loc: location name, default="unknown"
        -app appends to existing er_samples.txt file, default is to overwrite

    INPUT FORMAT
        Input files must be space delimited:
            Samp  Az Dip Strike Dip 
        Orientation convention:
             Lab arrow azimuth = mag_azimuth; Lab arrow dip = 90-field_dip
                e.g. field_dip is degrees from horizontal of drill direction
       
         Magnetic declination convention:
             Az is already corrected in file 
    
       Sample naming convention:
            [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 same as sample
            [6] site is entered under a separate column
            [7-Z] [XXXX]YYY:  XXXX is site designation with Z characters with sample name XXXXYYYY
            NB: all others you will have to customize your self
                 or e-mail [email protected] for help.
 
    OUTPUT
            output saved in er_samples.txt  will overwrite any existing files 
    """

    args = sys.argv
    if "-h" in args:
        print main.__doc__
        sys.exit()
        
    dataframe = extractor.command_line_dataframe([['f', False, 'orient.txt'], ['Fsa', False, 'er_samples.txt'], ['ncn', False, "1"], ['mcd', False, 'FS-FD'], ['loc', False, 'unknown'], ['app', False, False], ['WD', False, '.'], ['ID', False, '.']])
    checked_args = extractor.extract_and_check_args(args, dataframe)
    print 'checked_args:', checked_args
    orient_file, samp_file, samp_con, method_codes, location_name, append, output_dir, input_dir = extractor.get_vars(['f', 'Fsa', 'ncn', 'mcd', 'loc', 'app', 'WD', 'ID'], checked_args)

    if len(str(samp_con)) > 1:
        samp_con, Z = samp_con.split('-')
        Z = float(Z)
    else:
        Z = 1
        
    ipmag.azdip_magic(orient_file, samp_file, samp_con, Z, method_codes, location_name, append, output_dir, input_dir)