From e5ab16996ff73140fa555e8c3b90b38f3994ab8c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 20:58:52 +0000 Subject: [PATCH 1/3] Initial plan From 32ac1cf771b4b240ea95362e516f417f6a86bfa1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 21:03:58 +0000 Subject: [PATCH 2/3] Add error handling for download_magic_from_id in anisotropy notebook Co-authored-by: Swanson-Hysell <4332322+Swanson-Hysell@users.noreply.github.com> --- .../anisotropy_plot_AMS.ipynb | 31 +++++++++-- .../anisotropy_slump/contribution.txt | 3 ++ example_data/anisotropy_slump/locations.txt | 3 ++ example_data/anisotropy_slump/samples.txt | 19 +++++++ example_data/anisotropy_slump/sites.txt | 8 +++ example_data/anisotropy_slump/specimens.txt | 51 +++++++++++++++++++ 6 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 example_data/anisotropy_slump/contribution.txt create mode 100644 example_data/anisotropy_slump/locations.txt create mode 100644 example_data/anisotropy_slump/samples.txt create mode 100644 example_data/anisotropy_slump/sites.txt create mode 100644 example_data/anisotropy_slump/specimens.txt diff --git a/anisotropy_notebooks/anisotropy_plot_AMS.ipynb b/anisotropy_notebooks/anisotropy_plot_AMS.ipynb index b73b7dd..a57921d 100644 --- a/anisotropy_notebooks/anisotropy_plot_AMS.ipynb +++ b/anisotropy_notebooks/anisotropy_plot_AMS.ipynb @@ -48,7 +48,9 @@ "\n", "The MagIC formated data for that study can be found here: https://earthref.org/MagIC/19571. We can use the MagIC id of `19571` to download the data from MagIC using the `ipmag.download_magic_from_id()` function.\n", "\n", - "We will set the directory, download the file from MagIC (using `ipmag.download_magic_from_id()`), unpack the MagIC file into its constituent tables (using `ipmag.unpack_magic`), and make those tables into a Contribution object (using `cb.Contribution()`)." + "We will set the directory, download the file from MagIC (using `ipmag.download_magic_from_id()`), unpack the MagIC file into its constituent tables (using `ipmag.unpack_magic`), and make those tables into a Contribution object (using `cb.Contribution()`).\n", + "\n", + "**Note:** The download function requires the Python `requests` module to be installed. If the download fails (e.g., due to network issues or missing dependencies), the notebook will automatically fall back to using pre-downloaded data that is included in the `example_data/anisotropy_slump` directory." ] }, { @@ -74,8 +76,29 @@ ], "source": [ "dir_path = 'example_data/anisotropy_slump'\n", - "result, magic_file = ipmag.download_magic_from_id('19571', directory=dir_path)\n", - "ipmag.unpack_magic(magic_file, dir_path, print_progress=False)\n", + "\n", + "# Try to download data from MagIC database\n", + "# Note: This requires the 'requests' module to be installed\n", + "try:\n", + " result, magic_file = ipmag.download_magic_from_id('19571', directory=dir_path)\n", + " if result:\n", + " ipmag.unpack_magic(magic_file, dir_path, print_progress=False)\n", + " else:\n", + " print(f\"Download failed, but will attempt to use existing data in {dir_path}\")\n", + " magic_file = 'magic_contribution_19571.txt'\n", + "except (AttributeError, Exception) as e:\n", + " print(f\"Unable to download from MagIC (error: {e})\")\n", + " print(f\"Using pre-downloaded data from {dir_path}\")\n", + " magic_file = 'magic_contribution_19571.txt'\n", + " # Unpack the existing file if it exists\n", + " import os\n", + " magic_file_path = os.path.join(dir_path, magic_file)\n", + " if os.path.exists(magic_file_path):\n", + " try:\n", + " ipmag.unpack_magic(magic_file_path, dir_path, print_progress=False)\n", + " except:\n", + " pass # May already be unpacked\n", + "\n", "contribution = cb.Contribution(dir_path)" ] }, @@ -1738,4 +1761,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/example_data/anisotropy_slump/contribution.txt b/example_data/anisotropy_slump/contribution.txt new file mode 100644 index 0000000..8df470a --- /dev/null +++ b/example_data/anisotropy_slump/contribution.txt @@ -0,0 +1,3 @@ +tab contribution +contributor data_model_version id lab_names reference timestamp version +@ltauxe 3.0 19571 Paleomagnetic Lab (Scripps Institution of Oceanography, UCSD, USA) 10.1130/0091-7613(2003)031<0203:COSSDD>2.0.CO;2 2022-06-26T20:15:26.614Z 1 diff --git a/example_data/anisotropy_slump/locations.txt b/example_data/anisotropy_slump/locations.txt new file mode 100644 index 0000000..d1d6afd --- /dev/null +++ b/example_data/anisotropy_slump/locations.txt @@ -0,0 +1,3 @@ +tab locations +age_high age_low age_unit citations continent_ocean country geologic_classes lat_n lat_s lithologies location location_type lon_e lon_w plate_blocks region tectonic_settings terranes +49 46 Ma This study North America United States of America Sedimentary 32.8544 32.8544 Limey shale Scripps Beach Outcrop 242.7555 242.7555 Pacific Plate Southern California Continental Shelf Baja California diff --git a/example_data/anisotropy_slump/samples.txt b/example_data/anisotropy_slump/samples.txt new file mode 100644 index 0000000..12add6c --- /dev/null +++ b/example_data/anisotropy_slump/samples.txt @@ -0,0 +1,19 @@ +tab samples +azimuth citations dip height method_codes orientation_quality sample site +95.0 This study -45 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as1a as1 +105.0 This study -39 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as1b as1 +90.0 This study -51 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as1c as1 +93.0 This study -49 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as1d as1 +90.0 This study -49 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as1e as1 +85.0 This study -65 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2a as2 +86.0 This study -64 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2b as2 +85.0 This study -69 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2c as2 +81.0 This study -74 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2d as2 +81.0 This study -73 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2e as2 +86.0 This study -59 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as2f as2 +35.0 This study -64 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3a as3 +39.0 This study -63 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3b as3 +37.0 This study -61 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3c as3 +53.0 This study -66 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3d as3 +60.0 This study -62 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3e as3 +77.0 This study -54 0 FS-FD:SO-CMD-NORTH:SO-POM:SO-MAG g as3f as3 diff --git a/example_data/anisotropy_slump/sites.txt b/example_data/anisotropy_slump/sites.txt new file mode 100644 index 0000000..0512d31 --- /dev/null +++ b/example_data/anisotropy_slump/sites.txt @@ -0,0 +1,8 @@ +tab sites +age_high age_low age_unit aniso_tilt_correction aniso_type aniso_v1 aniso_v2 aniso_v3 citations description geologic_classes geologic_types lat lithologies location lon method_codes samples site site_alternatives specimens +49 46 Ma 0 AMS 0.34364864:155:0.7:eta/zeta:64.9:7.8:37.7:249.8:82.2:3.5 0.34138933:64.9:7.8:eta/zeta:155:0.7:37.7:249.8:82.2:3.8 0.31496203:249.8:82.2:eta/zeta:155:0.7:37.7:64.9:7.8:3.8 This study as1:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-H:LP-AN as1b : as1c : as1d : as1e:as1a as1 Cryptoslump:Site B as1a2 : as1a3 : as1b1 : as1b2 : as1b3 : as1c1 : as1c2 : as1c3 : as1d1 : as1d2 : as1d3 : as1e1 : as1e2:as1a1 +49 46 Ma 0 AMS 0.34364864:155:0.7:eta/zeta:249.4:80.1:1.1:63.4:9.8:11.3 0.34138933:64.9:7.8:eta/zeta:242.9:82.3:0.9:334.9:0.3:7.6 0.31496203:249.8:82.2:eta/zeta:114.6:5.5:0.7:24.1:5.4:1 This study as1:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-BS:AE-H:LP-AN as1b : as1c : as1d : as1e:as1a as1 Cryptoslump:Site B as1a2 : as1a3 : as1b1 : as1b2 : as1b3 : as1c1 : as1c2 : as1c3 : as1d1 : as1d2 : as1d3 : as1e1 : as1e2:as1a1 +49 46 Ma 0 AMS 0.34858122:358.4:5.6:eta/zeta:88.7:3.6:29.6:210.8:83.3:9.9 0.33781892:88.7:3.6:eta/zeta:358.4:5.6:29.6:210.8:83.3:14.2 0.31359982:210.8:83.3:eta/zeta:358.4:5.6:29.6:88.7:3.6:14.2 This study as2:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-H:LP-AN as2b : as2c : as2d : as2e : as2f:as2a as2 Slumped:Site C as2a2 : as2a3 : as2a4 : as2b1 : as2b2 : as2b3 : as2b4 : as2c1 : as2c2 : as2c3 : as2c4 : as2d1 : as2d2 : as2e1 : as2e2 : as2f1 : as2f2:as2a1 +49 46 Ma 0 AMS 0.34858122:358.4:5.6:eta/zeta:182.8:84.4:2.5:88.4:0.4:4.3 0.33781892:88.7:3.6:eta/zeta:188.7:70.4:1.9:357.4:19.3:4.4 0.31359982:210.8:83.3:eta/zeta:68.2:5.3:2.1:337.8:4:2.6 This study as2:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-BS:AE-H:LP-AN as2b : as2c : as2d : as2e : as2f:as2a as2 Slumped:Site C as2a2 : as2a3 : as2a4 : as2b1 : as2b2 : as2b3 : as2b4 : as2c1 : as2c2 : as2c3 : as2c4 : as2d1 : as2d2 : as2e1 : as2e2 : as2f1 : as2f2:as2a1 +49 46 Ma 0 AMS 0.34502691:358:5.8:eta/zeta:88.6:5.2:43.4:220.5:82.2:14.6 0.337455:88.6:5.2:eta/zeta:358:5.8:43.4:220.5:82.2:19.7 0.31751812:220.5:82.2:eta/zeta:358:5.8:43.4:88.6:5.2:19.7 This study as3:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-H:LP-AN as3b : as3c : as3d : as3e : as3f:as3a as3 Undeformed:Site A as3a2 : as3a3 : as3b1 : as3b2 : as3b3 : as3c1 : as3c2 : as3c3 : as3d1 : as3d2 : as3d3 : as3e1 : as3e2 : as3e3 : as3f1 : as3f2:as3a1 +49 46 Ma 0 AMS 0.34502691:358:5.8:eta/zeta:163.7:84.1:2.3:267.7:1.4:4.9 0.337455:88.6:5.2:eta/zeta:198.7:75:3:357.1:14:4.9 0.31751812:220.5:82.2:eta/zeta:360:5.9:2.3:90.5:5.1:3 This study as3:AMS Sedimentary Sediment Layer 32.8694 Limey shale Scripps Beach 242.7463 AE-BS:AE-H:LP-AN as3b : as3c : as3d : as3e : as3f:as3a as3 Undeformed:Site A as3a2 : as3a3 : as3b1 : as3b2 : as3b3 : as3c1 : as3c2 : as3c3 : as3d1 : as3d2 : as3d3 : as3e1 : as3e2 : as3e3 : as3f1 : as3f2:as3a1 diff --git a/example_data/anisotropy_slump/specimens.txt b/example_data/anisotropy_slump/specimens.txt new file mode 100644 index 0000000..6c54f35 --- /dev/null +++ b/example_data/anisotropy_slump/specimens.txt @@ -0,0 +1,51 @@ +tab specimens +aniso_s aniso_s_mean aniso_s_n_measurements aniso_s_sigma aniso_s_unit aniso_type citations geologic_classes geologic_types lithologies method_codes sample specimen +0.34406999:0.34145039:0.31447965:-0.00168019:0.00414139:0.00152697 0.000250466667 15 0.00052489 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1a as1a1 +0.34351686:0.34047559:0.31600755:-0.00129778:0.00339327:0.00125112 0.000229266667 15 0.00078145 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1a as1a2 +0.34317553:0.34108347:0.315741:-0.00083286:0.00326305:0.0007202 0.000235266667 15 0.00036582 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1a as1a3 +0.34141964:0.34004751:0.31853285:-0.0005353:0.00190212:0.00016655 0.000240866667 15 0.00054581 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1b as1b1 +0.34097505:0.34068653:0.31833842:-0.00101421:0.0022525:0.0011572 0.000230333333 15 0.00048239 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1b as1b2 +0.34512332:0.34413338:0.3107433:-0.00177674:0.0047107:0.00023523 0.0002538 15 0.000518 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1b as1b3 +0.3430306:0.34192824:0.31504112:-0.000796:0.00393136:0.00098298 0.000263533333 15 0.00039998 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1c as1c1 +0.34327549:0.34130883:0.31541568:-0.00056881:0.00294627:0.00070241 0.0002766 15 0.00076218 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1c as1c2 +0.34189418:0.34063521:0.31747064:-0.00066421:0.00203405:0.00082024 0.000236866667 15 0.00050304 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1c as1c3 +0.34377083:0.34210697:0.3141222:-0.00068657:0.00420506:0.0016346 0.000262733333 15 0.00053494 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1d as1d1 +0.34193784:0.34051162:0.31755051:-0.00086076:0.00308701:0.0009102 0.000235 15 0.00057908 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1d as1d2 +0.34405649:0.34288949:0.31305403:-0.00178181:0.00397489:0.00324311 0.0002848 15 0.00084129 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1d as1d3 +0.34592408:0.34170985:0.31236601:-0.00087383:0.00340819:0.00234418 0.0002846 15 0.00088167 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1e as1e1 +0.34244603:0.34016421:0.31738976:-0.00094397:0.00348509:0.00108591 0.000231666667 15 0.00047962 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as1e as1e2 +0.36389422:0.33517885:0.30092686:0.00353046:-0.00354419:0.00431378 0.000555 15 0.00106408 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2a as2a1 +0.36170322:0.33583695:0.30245984:0.0023445:-0.00090962:0.00568174 0.0004832 15 0.0015105 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2a as2a2 +0.35231003:0.33561212:0.31207782:0.00100424:0.00122943:0.00382133 0.000287066667 15 0.00095596 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2a as2a3 +0.34708691:0.33623931:0.31667379:0.00094996:0.00161225:0.00251576 0.0002468 15 0.00062057 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2a as2a4 +0.34942445:0.33513805:0.3154375:9.725e-05:-0.0030497:0.00146765 0.000242933333 15 0.00062209 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2b as2b1 +0.34447342:0.33515152:0.32037506:0.00076163:-0.00126093:0.00146286 0.000214866667 15 0.00055455 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2b as2b2 +0.34808135:0.3321946:0.31972405:0.00099185:0.00134318:0.0036739 0.000290533333 15 0.00059247 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2b as2b3 +0.34909812:0.3332268:0.31767508:0.00361469:5.312e-05:0.0047583 0.000490266667 15 0.00063498 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2b as2b4 +0.34608561:0.3341603:0.31975409:-0.00082277:-0.00118635:0.00221559 0.0002408 15 0.00043775 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2c as2c1 +0.3527424:0.33137098:0.31588662:0.00034742:0.00011353:0.00215516 0.000414066667 15 0.00098959 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2c as2c2 +0.35414323:0.33323857:0.31261823:-7.562e-05:0.00037727:0.00638297 0.000599533333 15 0.00087714 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2c as2c3 +0.35182214:0.33141348:0.31676438:0.00097282:-0.00022841:0.00701841 0.000987866667 15 0.00097017 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2c as2c4 +0.35195285:0.33339003:0.31465709:-0.00034904:-0.00071313:0.00062335 0.000284266667 15 0.00112947 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2d as2d1 +0.35509837:0.33150673:0.3133949:0.00112142:0.00167727:0.00262382 0.000177266667 15 0.00342454 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2d as2d2 +0.35800666:0.33223015:0.30976319:-0.00566446:-0.00162781:0.00515906 0.000376933333 15 0.00139358 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2e as2e1 +0.35870659:0.33311459:0.30817878:-0.00515056:0.00130616:0.00679767 0.000333266667 15 0.00088837 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2e as2e2 +0.34933397:0.34440169:0.30626434:-0.00102886:0.00152818:0.01711998 0.0004084 15 0.00118902 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2f as2f1 +0.34469131:0.34519607:0.31011263:-0.00265236:0.00143709:0.01595598 0.0003126 15 0.0013812 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as2f as2f2 +0.33294922:0.33564943:0.33140138:-0.00533521:0.00335696:0.00760978 0.000207 15 0.00080515 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3a as3a1 +0.33843949:0.33817899:0.32338148:-0.00020947:-0.00178141:0.00135121 0.000216666667 15 0.0009245 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3a as3a2 +0.33820483:0.3377558:0.32403934:-0.00059525:-0.00174375:0.00127366 0.000189533333 15 0.00069364 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3a as3a3 +0.33969876:0.33965841:0.32064283:-0.00180637:0.00534557:0.0010394 0.000202133333 15 0.00402628 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3b as3b1 +0.33569983:0.34147659:0.32282361:0.00083109:0.00515435:0.00038798 0.000209333333 15 0.00226752 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3b as3b2 +0.33669358:0.33759224:0.32571417:0.00218041:0.00134302:0.00211947 0.000125533333 15 0.00521015 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3b as3b3 +0.33873025:0.33836567:0.32290411:0.00109104:0.00154824:-0.0004876 0.000195733333 15 0.00220588 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3c as3c1 +0.33731282:0.33902717:0.32366002:0.00103064:0.00016768:-0.00079806 0.000197333333 15 0.00190944 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3c as3c2 +0.33759287:0.33830321:0.32410395:-0.00040597:0.00105278:6.708e-05 0.000141533333 15 0.00127797 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3c as3c3 +0.34114856:0.33937207:0.31947935:-0.00110861:0.00025925:-0.00134654 0.000185466667 15 0.00154491 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3d as3d1 +0.34107029:0.32664222:0.33228749:-0.0004464:0.01045345:-0.0004164 0.000188933333 15 0.0022083 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3d as3d2 +0.33966753:0.32765597:0.3326765:4.264e-05:0.01038845:0.00122087 0.000185866667 15 0.00125396 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3d as3d3 +0.33978784:0.3407141:0.31949803:-0.00118344:0.00056415:0.00349775 0.000201733333 15 0.00219278 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3e as3e1 +0.33842105:0.33376026:0.32781869:-0.00187255:0.0022676:0.00420439 0.0001954 15 0.00217275 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3e as3e2 +0.33827138:0.33604705:0.32568157:0.00149973:-0.00086203:0.00228208 0.0001892 15 0.00273253 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3e as3e3 +0.33537519:0.33225599:0.33236882:-0.00123474:0.00144038:0.00432219 0.0001718 15 0.00299186 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3f as3f1 +0.33931324:0.33790049:0.32278624:0.00023604:0.00046812:0.00049717 0.0001292 15 0.00204418 SI AMS This study Sedimentary Sediment Layer Shallow Marine Sediments AE-H:LP-X as3f as3f2 From c59d7a69f9ba369212b95cd6c2709037ac89c734 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 21:10:00 +0000 Subject: [PATCH 3/3] Address code review feedback: improve error handling and fix spelling Co-authored-by: Swanson-Hysell <4332322+Swanson-Hysell@users.noreply.github.com> --- .../anisotropy_plot_AMS.ipynb | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/anisotropy_notebooks/anisotropy_plot_AMS.ipynb b/anisotropy_notebooks/anisotropy_plot_AMS.ipynb index a57921d..3d9a690 100644 --- a/anisotropy_notebooks/anisotropy_plot_AMS.ipynb +++ b/anisotropy_notebooks/anisotropy_plot_AMS.ipynb @@ -46,7 +46,7 @@ "\n", "> Schwehr and Tauxe (2003). Characterization of soft-sediment deformation: Detection of cryptoslumps using magnetic methods. Geology 31 (3):203. doi:10.1130/0091-7613(2003)031<0203:COSSDD>2.0.CO;2.\n", "\n", - "The MagIC formated data for that study can be found here: https://earthref.org/MagIC/19571. We can use the MagIC id of `19571` to download the data from MagIC using the `ipmag.download_magic_from_id()` function.\n", + "The MagIC formatted data for that study can be found here: https://earthref.org/MagIC/19571. We can use the MagIC id of `19571` to download the data from MagIC using the `ipmag.download_magic_from_id()` function.\n", "\n", "We will set the directory, download the file from MagIC (using `ipmag.download_magic_from_id()`), unpack the MagIC file into its constituent tables (using `ipmag.unpack_magic`), and make those tables into a Contribution object (using `cb.Contribution()`).\n", "\n", @@ -55,27 +55,15 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Download successful. File saved to: example_data/anisotropy_slump/magic_contribution_19571.txt\n", - "1 records written to file /Users/yimingzhang/Github/RockmagPy-notebooks/anisotropy_notebooks/example_data/anisotropy_slump/contribution.txt\n", - "1 records written to file /Users/yimingzhang/Github/RockmagPy-notebooks/anisotropy_notebooks/example_data/anisotropy_slump/locations.txt\n", - "6 records written to file /Users/yimingzhang/Github/RockmagPy-notebooks/anisotropy_notebooks/example_data/anisotropy_slump/sites.txt\n", - "17 records written to file /Users/yimingzhang/Github/RockmagPy-notebooks/anisotropy_notebooks/example_data/anisotropy_slump/samples.txt\n", - "49 records written to file /Users/yimingzhang/Github/RockmagPy-notebooks/anisotropy_notebooks/example_data/anisotropy_slump/specimens.txt\n", - "-I- Using online data model\n", - "-I- Getting method codes from earthref.org\n", - "-I- Importing controlled vocabularies from https://earthref.org\n" - ] - } - ], + "outputs": [], "source": [ + "import os\n", + "\n", "dir_path = 'example_data/anisotropy_slump'\n", + "magic_file = 'magic_contribution_19571.txt'\n", + "magic_file_path = os.path.join(dir_path, magic_file)\n", "\n", "# Try to download data from MagIC database\n", "# Note: This requires the 'requests' module to be installed\n", @@ -85,19 +73,19 @@ " ipmag.unpack_magic(magic_file, dir_path, print_progress=False)\n", " else:\n", " print(f\"Download failed, but will attempt to use existing data in {dir_path}\")\n", - " magic_file = 'magic_contribution_19571.txt'\n", - "except (AttributeError, Exception) as e:\n", - " print(f\"Unable to download from MagIC (error: {e})\")\n", + " # Unpack the pre-downloaded file if it exists\n", + " if os.path.exists(magic_file_path):\n", + " ipmag.unpack_magic(magic_file_path, dir_path, print_progress=False)\n", + "except Exception as e:\n", + " print(f\"Unable to download from MagIC (error: {type(e).__name__})\")\n", " print(f\"Using pre-downloaded data from {dir_path}\")\n", - " magic_file = 'magic_contribution_19571.txt'\n", " # Unpack the existing file if it exists\n", - " import os\n", - " magic_file_path = os.path.join(dir_path, magic_file)\n", " if os.path.exists(magic_file_path):\n", " try:\n", " ipmag.unpack_magic(magic_file_path, dir_path, print_progress=False)\n", - " except:\n", - " pass # May already be unpacked\n", + " except Exception as unpack_error:\n", + " # May already be unpacked or have other issues\n", + " print(f\"Note: Could not unpack file (it may already be unpacked): {unpack_error}\")\n", "\n", "contribution = cb.Contribution(dir_path)" ]