Skip to content

Commit

Permalink
Updated code for file naming/moving
Browse files Browse the repository at this point in the history
  • Loading branch information
FDauphin committed Nov 27, 2023
1 parent 685694c commit c840360
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions notebooks/WFC3/calwf3_recalibration/calwf3_recal_tvb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"<a id=\"imports\"></a>\n",
"## 1. Imports\n",
"\n",
"This notebook assumes you have created the virtual environment in [WFC3 Library's](https://github.com/spacetelescope/WFC3Library) installation instructions.\n",
"This notebook assumes you have installed the required libraries as described [here](https://github.com/spacetelescope/hst_notebooks/tree/main/notebooks/WFC3/calwf3_recalibration).\n",
"\n",
"We import:\n",
"- *glob* for finding lists of files\n",
Expand Down Expand Up @@ -122,8 +122,9 @@
"science_files = glob.glob('data/mastDownload/HST/*/*fits')\n",
"\n",
"for im in science_files:\n",
" root = im.split('/')[-1]\n",
" os.rename(im, './'+root)\n",
" root = os.path.basename(im)\n",
" new_path = os.path.join('.', root)\n",
" os.rename(im, new_path)\n",
"\n",
"data_directory = './data'\n",
"\n",
Expand Down Expand Up @@ -389,14 +390,14 @@
"metadata": {},
"outputs": [],
"source": [
"os.mkdir('orig/')\n",
"os.makedirs('orig/', exist_ok=True)\n",
"\n",
"for imas in glob.glob('ibohbf*_ima.fits'):\n",
" shutil.move(imas, 'orig/')\n",
"for flts in glob.glob('ibohbf*_flt.fits'):\n",
" shutil.move(flts, 'orig/') \n",
"for driz in glob.glob('ibohbf*_drz.fits'):\n",
" shutil.move(driz, 'orig/') "
"for file_pattern in ['ibohbf*_ima.fits', 'ibohbf*_flt.fits', 'ibohbf*_drz.fits']:\n",
" for file in glob.glob(file_pattern):\n",
" destination_path = os.path.join('orig', os.path.basename(file))\n",
" if os.path.isfile(destination_path):\n",
" os.remove(destination_path)\n",
" shutil.move(file, destination_path) "
]
},
{
Expand Down Expand Up @@ -767,7 +768,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.8.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c840360

Please sign in to comment.