From 5cd3ce0edeca02c9ac248ad0a136fd709894dee6 Mon Sep 17 00:00:00 2001 From: Erik Tollerud Date: Wed, 28 Apr 2021 11:59:52 -0400 Subject: [PATCH] switch to using symlinks --- .../jwst-data-products-part1-live.ipynb | 10 ++++------ .../jwst-data-products-part1-solutions.ipynb | 10 ++++------ .../jwst-data-products-part2-live.ipynb | 5 ++--- .../jwst-data-products-part2-solutions.ipynb | 5 ++--- .../jwst-data-products-part3-live.ipynb | 10 ++++------ .../jwst-data-products-part3-solutions.ipynb | 12 +++++------- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/pipeline_products_session/jwst-data-products-part1-live.ipynb b/pipeline_products_session/jwst-data-products-part1-live.ipynb index eba8f0e..e69319e 100644 --- a/pipeline_products_session/jwst-data-products-part1-live.ipynb +++ b/pipeline_products_session/jwst-data-products-part1-live.ipynb @@ -231,12 +231,10 @@ "exercise_obs = \"example_exercise_uncal.fits\"\n", "demo_ex_file = download_file(exercise_obs_link+exercise_obs, cache=True)\n", "\n", - "# Save the files so that we can use them later\n", - "with fits.open(demo_file, ignore_missing_end=True) as f:\n", - " f.writeto(uncal_obs, overwrite=True)\n", - " \n", - "with fits.open(demo_ex_file, ignore_missing_end=True) as f:\n", - " f.writeto(exercise_obs, overwrite=True) " + "# Create local links to the cached copy - this is not necessary - you can use the `demo_file`/`demo_ex_file` \n", + "# names directly. But this is a convenient to see what you've downloaded and remind yourself laiter\n", + "os.symlink(demo_file, uncal_obs)\n", + "os.symlink(demo_ex_file, exercise_obs) " ] }, { diff --git a/pipeline_products_session/jwst-data-products-part1-solutions.ipynb b/pipeline_products_session/jwst-data-products-part1-solutions.ipynb index 1836f62..7d8acd5 100644 --- a/pipeline_products_session/jwst-data-products-part1-solutions.ipynb +++ b/pipeline_products_session/jwst-data-products-part1-solutions.ipynb @@ -231,12 +231,10 @@ "exercise_obs = \"example_exercise_uncal.fits\"\n", "demo_ex_file = download_file(exercise_obs_link+exercise_obs, cache=True)\n", "\n", - "# Save the files so that we can use them later\n", - "with fits.open(demo_file, ignore_missing_end=True) as f:\n", - " f.writeto(uncal_obs, overwrite=True)\n", - " \n", - "with fits.open(demo_ex_file, ignore_missing_end=True) as f:\n", - " f.writeto(exercise_obs, overwrite=True) " + "# Create local links to the cached copy - this is not necessary - you can use the `demo_file`/`demo_ex_file` \n", + "# names directly. But this is a convenient to see what you've downloaded and remind yourself laiter\n", + "os.symlink(demo_file, uncal_obs)\n", + "os.symlink(demo_ex_file, exercise_obs) " ] }, { diff --git a/pipeline_products_session/jwst-data-products-part2-live.ipynb b/pipeline_products_session/jwst-data-products-part2-live.ipynb index ea9cb7e..fb31895 100644 --- a/pipeline_products_session/jwst-data-products-part2-live.ipynb +++ b/pipeline_products_session/jwst-data-products-part2-live.ipynb @@ -256,9 +256,8 @@ "for file in all_files:\n", " demo_file = download_file(file[0], cache=True)\n", " \n", - " # Save the file so that we can use it later\n", - " with fits.open(demo_file) as f:\n", - " f.writeto(file[1], overwrite=True)" + " # Make a symbolic link using a local name for convenience\n", + " os.symlink(demo_file, file[1])" ] }, { diff --git a/pipeline_products_session/jwst-data-products-part2-solutions.ipynb b/pipeline_products_session/jwst-data-products-part2-solutions.ipynb index 12b2ce2..c05f119 100644 --- a/pipeline_products_session/jwst-data-products-part2-solutions.ipynb +++ b/pipeline_products_session/jwst-data-products-part2-solutions.ipynb @@ -256,9 +256,8 @@ "for file in all_files:\n", " demo_file = download_file(file[0], cache=True)\n", " \n", - " # Save the file so that we can use it later\n", - " with fits.open(demo_file) as f:\n", - " f.writeto(file[1], overwrite=True)" + " # Make a symbolic link using a local name for convenience\n", + " os.symlink(demo_file, file[1])" ] }, { diff --git a/pipeline_products_session/jwst-data-products-part3-live.ipynb b/pipeline_products_session/jwst-data-products-part3-live.ipynb index 7c342d4..e9fb651 100644 --- a/pipeline_products_session/jwst-data-products-part3-live.ipynb +++ b/pipeline_products_session/jwst-data-products-part3-live.ipynb @@ -284,12 +284,10 @@ "final_c1d = download_file(final_c1d_file_link, cache=True)\n", "final_c1d_file = \"example_nircam_wfss_c1d.fits\"\n", "\n", - "# Save the files so that we can use them later\n", - "with fits.open(combined_i2d, ignore_missing_end=True) as f:\n", - " f.writeto(combined_i2d_file, overwrite=True)\n", - " \n", - "with fits.open(final_c1d, ignore_missing_end=True) as f:\n", - " f.writeto(final_c1d_file, overwrite=True) " + "# Create local links to the cached copies of the fits file. This is not necessary - you can use \n", + "#`combined_i2d`/`final_c1d` directly. But this is convenient to remind yourself later what you downloaded\n", + "os.symlink(combined_i2d, combined_i2d_file)\n", + "os.symlink(final_c1d, final_c1d_file) " ] }, { diff --git a/pipeline_products_session/jwst-data-products-part3-solutions.ipynb b/pipeline_products_session/jwst-data-products-part3-solutions.ipynb index 2de05ee..85ed7de 100644 --- a/pipeline_products_session/jwst-data-products-part3-solutions.ipynb +++ b/pipeline_products_session/jwst-data-products-part3-solutions.ipynb @@ -282,14 +282,12 @@ "# For the NIRCam WFSS 1D file:\n", "final_c1d_file_link = 'https://stsci.box.com/shared/static/ixfnu50ju78vs40dcec8i7w0u6kwtoli.fits'\n", "final_c1d = download_file(final_c1d_file_link, cache=True)\n", - "final_c1d_file = \"example_nircam_wfss_c1d.fits\"\n", + "final_c1d_file = \"example_nircam_wfss_c1d.fits\" \n", "\n", - "# Save the files so that we can use them later\n", - "with fits.open(combined_i2d, ignore_missing_end=True) as f:\n", - " f.writeto(combined_i2d_file, overwrite=True)\n", - " \n", - "with fits.open(final_c1d, ignore_missing_end=True) as f:\n", - " f.writeto(final_c1d_file, overwrite=True) " + "# Create local links to the cached copies of the fits file. This is not necessary - you can use \n", + "#`combined_i2d`/`final_c1d` directly. But this is convenient to remind yourself later what you downloaded\n", + "os.symlink(combined_i2d, combined_i2d_file)\n", + "os.symlink(final_c1d, final_c1d_file) " ] }, {