-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
239,954 additions
and
19,833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main, release*] | ||
|
||
|
||
jobs: | ||
pre-commit: | ||
env: | ||
SKIP: ruff | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
# must match the version in .pre-commit-config.yaml:default_language_version.python | ||
python-version: '3.9' | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
release: | ||
types: [ published ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "85effe3b-5328-412f-8957-5b606fed8c29", | ||
"metadata": {}, | ||
"source": [ | ||
"Extracts the rows with blanked integrations and an additional `nints` integrations before the blank." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"id": "732d3e8c-dfb0-4d32-8869-a8f2c05b9801", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"\n", | ||
"from astropy.io import fits\n", | ||
"\n", | ||
"from dysh import util\n", | ||
"from dysh.fits.gbtfitsload import GBTFITSLoad" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 70, | ||
"id": "83e3fa86-c4be-4b8e-b5fa-7e90c7539e3a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Select the VEGAS banks to use,\n", | ||
"# and the scan numbers you are interested in.\n", | ||
"vbanks = [\"A\"]\n", | ||
"scans = [156, 157]\n", | ||
"nints = 2\n", | ||
"\n", | ||
"# Where do you find the original data?\n", | ||
"example_data = \"/home/dysh/example_data/\" # @GBO\n", | ||
"data_path = f\"{example_data}onoff-L/data/TGBT21A_501_11.raw.vegas/\"\n", | ||
"data_file = lambda vbank : f\"{data_path}/TGBT21A_501_11.raw.vegas.{vbank}.fits\"\n", | ||
"# Where will you put the smaller data?\n", | ||
"# Use meaningful names.\n", | ||
"output_path = f\"{util.get_project_testdata()}/TGBT21A_501_11/NGC2782_blanks/\"\n", | ||
"output = lambda vbank : f\"{output_path}/NGC2782.raw.vegas.{vbank}.fits\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 92, | ||
"id": "6c394d08-a514-4585-850e-12fb1453fa31", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
" SCAN IFNUM PLNUM CAL SIG EXPOSURE\n", | ||
"45160 156 0 1 b'F' b'T' 1.976916\n", | ||
"45161 156 0 1 b'T' b'T' 1.976916\n", | ||
"45162 156 0 0 b'F' b'T' 1.976916\n", | ||
"45163 156 0 0 b'T' b'T' 1.976916\n", | ||
"45164 156 1 1 b'F' b'T' 1.976916\n", | ||
"45165 156 1 1 b'T' b'T' 1.976916\n", | ||
"45166 156 1 0 b'F' b'T' 1.976916\n", | ||
"45167 156 1 0 b'T' b'T' 1.976916\n", | ||
"45168 156 2 1 b'F' b'T' 1.976916\n", | ||
"45169 156 2 1 b'T' b'T' 1.976916\n", | ||
"45170 156 2 0 b'F' b'T' 1.976916\n", | ||
"45171 156 2 0 b'T' b'T' 1.976916\n", | ||
"45172 156 3 1 b'F' b'T' 1.976916\n", | ||
"45173 156 3 1 b'T' b'T' 1.976916\n", | ||
"45174 156 3 0 b'F' b'T' 1.976916\n", | ||
"45175 156 3 0 b'T' b'T' 1.976916\n", | ||
"45176 156 4 1 b'F' b'T' 1.976916\n", | ||
"45177 156 4 1 b'T' b'T' 1.976916\n", | ||
"45178 156 4 0 b'F' b'T' 1.976916\n", | ||
"45179 156 4 0 b'T' b'T' 1.976916\n", | ||
"\n", | ||
"\n", | ||
" SCAN IFNUM PLNUM CAL SIG EXPOSURE\n", | ||
"45180 156 0 1 b'F' b'T' 0.121635\n", | ||
"45181 156 0 1 b'T' b'T' 0.000000\n", | ||
"45182 156 0 0 b'F' b'T' 0.121635\n", | ||
"45183 156 0 0 b'T' b'T' 0.000000\n", | ||
"45184 156 1 1 b'F' b'T' 0.121635\n", | ||
"45185 156 1 1 b'T' b'T' 0.000000\n", | ||
"45186 156 1 0 b'F' b'T' 0.121635\n", | ||
"45187 156 1 0 b'T' b'T' 0.000000\n", | ||
"45188 156 2 1 b'F' b'T' 0.121635\n", | ||
"45189 156 2 1 b'T' b'T' 0.000000\n", | ||
"45190 156 2 0 b'F' b'T' 0.121635\n", | ||
"45191 156 2 0 b'T' b'T' 0.000000\n", | ||
"45192 156 3 1 b'F' b'T' 0.121635\n", | ||
"45193 156 3 1 b'T' b'T' 0.000000\n", | ||
"45194 156 3 0 b'F' b'T' 0.121635\n", | ||
"45195 156 3 0 b'T' b'T' 0.000000\n", | ||
"45196 156 4 1 b'F' b'T' 0.121635\n", | ||
"45197 156 4 1 b'T' b'T' 0.000000\n", | ||
"45198 156 4 0 b'F' b'T' 0.121635\n", | ||
"45199 156 4 0 b'T' b'T' 0.000000\n", | ||
"\n", | ||
"\n", | ||
" SCAN IFNUM PLNUM CAL SIG EXPOSURE\n", | ||
"46680 157 0 1 b'F' b'T' 1.957343\n", | ||
"46681 157 0 1 b'T' b'T' 1.976916\n", | ||
"46682 157 0 0 b'F' b'T' 1.957343\n", | ||
"46683 157 0 0 b'T' b'T' 1.976916\n", | ||
"46684 157 1 1 b'F' b'T' 1.957343\n", | ||
"46685 157 1 1 b'T' b'T' 1.976916\n", | ||
"46686 157 1 0 b'F' b'T' 1.957343\n", | ||
"46687 157 1 0 b'T' b'T' 1.976916\n", | ||
"46688 157 2 1 b'F' b'T' 1.957343\n", | ||
"46689 157 2 1 b'T' b'T' 1.976916\n", | ||
"46690 157 2 0 b'F' b'T' 1.957343\n", | ||
"46691 157 2 0 b'T' b'T' 1.976916\n", | ||
"46692 157 3 1 b'F' b'T' 1.957343\n", | ||
"46693 157 3 1 b'T' b'T' 1.976916\n", | ||
"46694 157 3 0 b'F' b'T' 1.957343\n", | ||
"46695 157 3 0 b'T' b'T' 1.976916\n", | ||
"46696 157 4 1 b'F' b'T' 1.957343\n", | ||
"46697 157 4 1 b'T' b'T' 1.976916\n", | ||
"46698 157 4 0 b'F' b'T' 1.957343\n", | ||
"46699 157 4 0 b'T' b'T' 1.976916\n", | ||
"\n", | ||
"\n", | ||
" SCAN IFNUM PLNUM CAL SIG EXPOSURE\n", | ||
"46700 157 0 1 b'F' b'T' 0.121635\n", | ||
"46701 157 0 1 b'T' b'T' 0.000000\n", | ||
"46702 157 0 0 b'F' b'T' 0.121635\n", | ||
"46703 157 0 0 b'T' b'T' 0.000000\n", | ||
"46704 157 1 1 b'F' b'T' 0.121635\n", | ||
"46705 157 1 1 b'T' b'T' 0.000000\n", | ||
"46706 157 1 0 b'F' b'T' 0.121635\n", | ||
"46707 157 1 0 b'T' b'T' 0.000000\n", | ||
"46708 157 2 1 b'F' b'T' 0.121635\n", | ||
"46709 157 2 1 b'T' b'T' 0.000000\n", | ||
"46710 157 2 0 b'F' b'T' 0.121635\n", | ||
"46711 157 2 0 b'T' b'T' 0.000000\n", | ||
"46712 157 3 1 b'F' b'T' 0.121635\n", | ||
"46713 157 3 1 b'T' b'T' 0.000000\n", | ||
"46714 157 3 0 b'F' b'T' 0.121635\n", | ||
"46715 157 3 0 b'T' b'T' 0.000000\n", | ||
"46716 157 4 1 b'F' b'T' 0.121635\n", | ||
"46717 157 4 1 b'T' b'T' 0.000000\n", | ||
"46718 157 4 0 b'F' b'T' 0.121635\n", | ||
"46719 157 4 0 b'T' b'T' 0.000000\n", | ||
"\n", | ||
"\n", | ||
"Saved rows to /home/sandboxes/psalas/Dysh/dysh/testdata/TGBT21A_501_11/NGC2782_blanks//NGC2782.raw.vegas.A.fits\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for vbank in vbanks:\n", | ||
"\n", | ||
" file_in = data_file(vbank)\n", | ||
" file_out = output(vbank)\n", | ||
" \n", | ||
" # Open.\n", | ||
" hdu = fits.open(file_in)\n", | ||
" table = hdu[1].data\n", | ||
"\n", | ||
" # Bookkeeping.\n", | ||
" nif = len(list(set(table[\"IFNUM\"])))\n", | ||
" npl = len(list(set(table[\"PLNUM\"])))\n", | ||
" nnd = len(list(set(table[\"CAL\"])))\n", | ||
" nsw = len(list(set(table[\"SIG\"])))\n", | ||
"\n", | ||
" orows = []\n", | ||
" nrows = []\n", | ||
" \n", | ||
" for i,scan in enumerate(scans):\n", | ||
"\n", | ||
" # Bookkeeping.\n", | ||
" nrows.append(nif * npl * nnd * nsw)\n", | ||
"\n", | ||
" # Row selection.\n", | ||
" mask = np.all(np.isnan(table[\"DATA\"]), axis=1) & (table[\"SCAN\"] == scan)\n", | ||
" rows = np.where(mask == True)[0]\n", | ||
" for j in range(nints):\n", | ||
" skip = j*nrows[i]\n", | ||
" rowi = (rows[0] - 1) - skip\n", | ||
" rowf = rows[-1] - skip\n", | ||
" orows += list(np.arange(rowi, rowf+1))\n", | ||
"\n", | ||
" # Check results.\n", | ||
" # The resulting data frame should have entries for all \n", | ||
" # noise diode states in all polarizations, spectral windows\n", | ||
" # and switching states.\n", | ||
" table_ = np.lib.recfunctions.drop_fields(hdu[1].data, \"DATA\")\n", | ||
" df = pd.DataFrame(table_)\n", | ||
" for i,nrow in enumerate(nrows*nints):\n", | ||
" irow = i*nrow\n", | ||
" frow = (i+1)*nrow\n", | ||
" print(df[[\"SCAN\", \"IFNUM\", \"PLNUM\", \"CAL\", \"SIG\", \"EXPOSURE\"]].iloc[np.sort(np.ravel(orows))[irow:frow]])\n", | ||
" print(\"\\n\")\n", | ||
" # If the results are correct\n", | ||
" # save the rows for one VEGAS bank.\n", | ||
" hdu0 = hdu[0].copy()\n", | ||
" table = hdu[1].data[np.sort(np.ravel(orows))]\n", | ||
" head = hdu[1].header\n", | ||
" thdu = fits.BinTableHDU(table, header=head)\n", | ||
" outhdu = fits.HDUList([hdu0, thdu])\n", | ||
" outhdu.writeto(file_out, overwrite=True)\n", | ||
" print(f\"Saved rows to {file_out}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7602f570-f969-42a3-85dc-bae1ac0c44be", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.