Exemple #1
0
 def test_k15_with_options(self):
     input_dir = os.path.join('Datafiles', 'Measurement_Import', 'k15_magic')
     program_ran, outfile = ipmag.k15_magic('k15_example.dat', specnum=2, sample_naming_con="3", er_location_name="Here", measfile="my_magic_measurements.txt", sampfile="my_er_samples.txt", aniso_outfile="my_rmag_anisotropy.txt", result_file="my_rmag_results.txt", input_dir_path=input_dir)
     self.assertTrue(program_ran)
     self.assertEqual(outfile, os.path.join(".", "my_magic_measurements.txt"))
Exemple #2
0
 def test_k15_succeed_option4(self):
     input_dir = os.path.join('Datafiles', 'Measurement_Import', 'k15_magic')
     program_ran, outfile = ipmag.k15_magic('k15_example.dat', sample_naming_con="4-2", input_dir_path=input_dir)
     self.assertTrue(program_ran)
     self.assertEqual(outfile, os.path.join(".", "magic_measurements.txt"))
Exemple #3
0
 def test_k15_with_files(self):
     input_dir = os.path.join('Datafiles', 'Measurement_Import', 'k15_magic')
     program_ran, outfile  = ipmag.k15_magic('k15_example.dat', input_dir_path=input_dir)
     self.assertTrue(program_ran)
     self.assertEqual(outfile, os.path.join('.', 'magic_measurements.txt'))
Exemple #4
0
 def test_k15_fail_option4(self):
     input_dir = os.path.join('Datafiles', 'Measurement_Import', 'k15_magic')
     program_ran, error_message = ipmag.k15_magic('k15_example.dat', sample_naming_con="4", input_dir_path=input_dir)
     self.assertFalse(program_ran)
     self.assertEqual(error_message, "option [4] must be in form 4-Z where Z is an integer")
Exemple #5
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


    """