def test_upgrade(self): meas, upgraded, no_upgrade = pmag.convert_directory_2_to_3(input_dir=PROJECT_WD, output_dir=PROJECT_WD) expect_out = ['measurements.txt', 'specimens.txt', 'samples.txt', 'sites.txt', 'locations.txt', 'criteria.txt', 'ages.txt'] self.assertEqual(sorted(expect_out), sorted(upgraded)) expect_not_out = ['pmag_results.txt', 'rmag_hysteresis.txt', 'rmag_anisotropy.txt', 'rmag_results.txt', 'er_images.txt'] self.assertEqual(sorted(expect_not_out), sorted(no_upgrade))
def on_convert_3(self, event): dia = pw.UpgradeDialog(None) dia.Center() res = dia.ShowModal() if res == wx.ID_CANCEL: webbrowser.open("https://www2.earthref.org/MagIC/upgrade", new=2) return ## more nicely styled way, but doesn't link to earthref #msg = "This tool is meant for relatively simple upgrades (for instance, a measurement file, a sample file, and a criteria file).\nIf you have a more complex contribution to upgrade, and you want maximum accuracy, use the upgrade tool at https://www2.earthref.org/MagIC/upgrade.\n\nDo you want to continue?" #result = pw.warning_with_override(msg) #if result == wx.ID_NO: #webbrowser.open("https://www2.earthref.org/MagIC/upgrade", new=2) #return # turn files from 2.5 --> 3.0 (rough translation) meas, upgraded, no_upgrade = pmag.convert_directory_2_to_3('magic_measurements.txt', input_dir=self.WD, output_dir=self.WD, data_model=self.contribution.data_model) if not meas: wx.MessageBox('2.5 --> 3.0 failed. Do you have a magic_measurements.txt file in your working directory?', 'Info', wx.OK | wx.ICON_INFORMATION) return # create a contribution self.contribution = nb.Contribution(self.WD) # make skeleton files with specimen, sample, site, location data self.contribution.propagate_measurement_info() # # note what DIDN'T upgrade #no_upgrade = [] #for fname in os.listdir(self.WD): # if 'rmag' in fname: # no_upgrade.append(fname) # elif fname in ['pmag_results.txt', 'pmag_criteria.txt', # 'er_synthetics.txt', 'er_images.txt', # 'er_plots.txt', 'er_ages.txt']: # no_upgrade.append(fname) # pop up upgraded_string = ", ".join(upgraded) if no_upgrade: no_upgrade_string = ", ".join(no_upgrade) msg = '2.5 --> 3.0 translation completed!\n\nThese 3.0 format files were created: {}.\n\nHowever, these 2.5 format files could not be upgraded: {}.\n\nTo convert all 2.5 files, use the MagIC upgrade tool: https://www2.earthref.org/MagIC/upgrade\n'.format(upgraded_string, no_upgrade_string) if 'criteria.txt' in upgraded: msg += '\nNote: Please check your criteria file for completeness and accuracy, as not all 2.5 files will be fully upgraded.' if 'pmag_criteria.txt' in no_upgrade: msg += '\nNote: Not all criteria files can be upgraded, even on the MagIC site. You may need to recreate an old pmag_criteria file from scratch in Thellier GUI or Demag GUI.' wx.MessageBox(msg, 'Warning', wx.OK | wx.ICON_INFORMATION) else: msg = '2.5 --> 3.0 translation completed!\nThese files were converted: {}'.format(upgraded_string) wx.MessageBox(msg, 'Info', wx.OK | wx.ICON_INFORMATION)
def on_convert_3(self, event): # turn files from 2.5 --> 3.0 (rough translation) res = pmag.convert_directory_2_to_3('magic_measurements.txt', input_dir=self.WD, output_dir=self.WD) if not res: wx.MessageBox('2.5 --> 3.0 failed. Do you have a magic_measurements.txt file in your working directory?', 'Info', wx.OK | wx.ICON_INFORMATION) return # create a contribution self.contribution = nb.Contribution(self.WD) # make skeleton files with specimen, sample, site, location data self.contribution.propagate_measurement_info() # pop up wx.MessageBox('2.5 --> 3.0 translation completed!', 'Info', wx.OK | wx.ICON_INFORMATION)
def on_convert_3(self, event): # turn files from 2.5 --> 3.0 (rough translation) res = pmag.convert_directory_2_to_3('magic_measurements.txt', input_dir=self.WD, output_dir=self.WD) if not res: wx.MessageBox( '2.5 --> 3.0 failed. Do you have a magic_measurements.txt file in your working directory?', 'Info', wx.OK | wx.ICON_INFORMATION) return # create a contribution self.contribution = nb.Contribution(self.WD) # make skeleton files with specimen, sample, site, location data self.contribution.propagate_measurement_info() # pop up wx.MessageBox('2.5 --> 3.0 translation completed!', 'Info', wx.OK | wx.ICON_INFORMATION)
def on_convert_3(self, event): # turn files from 2.5 --> 3.0 (rough translation) meas, upgraded, no_upgrade = pmag.convert_directory_2_to_3( 'magic_measurements.txt', input_dir=self.WD, output_dir=self.WD, data_model=self.contribution.data_model) if not meas: wx.MessageBox( '2.5 --> 3.0 failed. Do you have a magic_measurements.txt file in your working directory?', 'Info', wx.OK | wx.ICON_INFORMATION) return # create a contribution self.contribution = nb.Contribution(self.WD) # make skeleton files with specimen, sample, site, location data self.contribution.propagate_measurement_info() # # note what DIDN'T upgrade #no_upgrade = [] #for fname in os.listdir(self.WD): # if 'rmag' in fname: # no_upgrade.append(fname) # elif fname in ['pmag_results.txt', 'pmag_criteria.txt', # 'er_synthetics.txt', 'er_images.txt', # 'er_plots.txt', 'er_ages.txt']: # no_upgrade.append(fname) # pop up upgraded_string = ", ".join(upgraded) if no_upgrade: no_upgrade_string = ", ".join(no_upgrade) msg = '2.5 --> 3.0 translation completed!\n\nThese 3.0 format files were created: {}.\n\nHowever, these 2.5 format files could not be upgraded: {}.\n\nTo convert all 2.5 files, use the MagIC upgrade tool: https://www2.earthref.org/MagIC/upgrade\n'.format( upgraded_string, no_upgrade_string) if 'criteria.txt' in upgraded: msg += '\nNote: Please check your criteria file for completeness and accuracy, as not all 2.5 files will be fully upgraded.' if 'pmag_criteria.txt' in no_upgrade: msg += '\nNote: Not all criteria files can be upgraded, even on the MagIC site. You may need to recreate an old pmag_criteria file from scratch in Thellier GUI or Demag GUI.' wx.MessageBox(msg, 'Warning', wx.OK | wx.ICON_INFORMATION) else: msg = '2.5 --> 3.0 translation completed!\nThese files were converted: {}'.format( upgraded_string) wx.MessageBox(msg, 'Info', wx.OK | wx.ICON_INFORMATION)
def on_convert_3(self, event): pmag.convert_directory_2_to_3('magic_measurements.txt', input_dir=self.WD, output_dir=self.WD) self.contribution = nb.Contribution(self.WD) self.contribution.propagate_measurement_info()