Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code updates for JWSTSIAF-284 #363

Open
wants to merge 5 commits into
base: siaf-updates
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 15 additions & 28 deletions generate/generate_nircam.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,43 +558,30 @@
for sca in ["1", "2", "3", "4", "5"]
],
[
"NRCA2_MASK210R",
"NRCA5_MASK210R",
"NRCA2_TAMASK210R",
"NRCA2_FSTAMASK210R",
"NRCA5_{}STRIPE{}_DHS_F322W2".format(pix,stripe)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fancy -- A little less readable in my opinion but if this is a request added by a team I won't say anymore 👍

for pix in ["41", "82", "164", "260"]
for stripe in ["1", "2", "3", "4"]
],
[
"NRCA5_MASK335R",
"NRCA2_MASK335R",
"NRCA5_TAMASK335R",
"NRCA5_FSTAMASK335R",
"NRCA5_{}STRIPE{}_DHS_F444W".format(pix,stripe)
for pix in ["41", "82", "164", "260"]
for stripe in ["1", "2", "3", "4"]
],
[
"NRCA5_MASK430R",
"NRCA2_MASK430R",
"NRCA5_TAMASK430R",
"NRCA5_FSTAMASK430R",
"NRCA5_{}STRIPE{}_DHS_F322W2".format(pix,stripe)
for pix in ["40", "80", "160", "256"]
for stripe in ["1", "2", "3", "4"]
],
[
"NRCA5_400X256_MASKLWB",
"NRCA4_400X256_MASKLWB",
"NRCA5_TAMASKLWB",
"NRCA5_TAMASKLWBL",
"NRCA5_FSTAMASKLWB",
"NRCA5_400X256_MASKLWB_NARROW",
"NRCA5_400X256_MASKLWB_F444W",
"NRCA5_400X256_MASKLWB_F250M",
"NRCA5_{}STRIPE{}_DHS_F444W".format(pix,stripe)
for pix in ["40", "80", "160", "256"]
for stripe in ["1", "2", "3", "4"]
],
[
"NRCA4_MASKSWB",
"NRCA5_MASKSWB",
"NRCA4_TAMASKSWB",
"NRCA4_TAMASKSWBS",
"NRCA4_FSTAMASKSWB",
"NRCA4_MASKSWB_NARROW",
"NRCA4_MASKSWB_F212N",
"NRCA4_MASKSWB_F182M",
"NRCA5_TADHSTS_SCI_{}".format(filter)
for filter in ["F322W2", "F444W"]
],

]

for selected_aperture_name in selected_aperture_names:
Expand Down
4 changes: 2 additions & 2 deletions pysiaf/iando/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ def read_roman_siaf(siaf_file=None):
from pysiaf import specpars

if not siaf_file:
with importlib_resources.path('pysiaf.prd_data.Roman',
'roman_siaf.xml') as siaf_file:
source = importlib_resources.files('pysiaf.prd_data.Roman').joinpath('roman_siaf.xml')
with importlib_resources.as_file(source) as siaf_file:
siaf_file = str(siaf_file)
else:
siaf_file = str(siaf_file)
Expand Down
20 changes: 10 additions & 10 deletions pysiaf/source_data/NIRCam/nircam_siaf_aperture_definition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@
# Grism Time Series, DHS (Module-A)
NRCA5_TADHSTS32 , SUBARRAY , 863.5 , 1031.5 , 32 , 32 , 16.5 , 16.5 , NRCA5_FULL , default
NRCA5_TADHSTS32_F405N , SUBARRAY , 863.43 , 1031.85 , 32 , 32 , 16.5 , 16.5 , NRCA5_FULL , default
NRCA5_TADHSTS_SCI_F322W2 , ROI , 468.0 , 1046.5 , 32 , 32 , 16.0 , 16.5 , NRCA5_FULL , default
NRCA5_TADHSTS_SCI_F444W , ROI , 1191.0 , 1046.5 , 32 , 32 , 16.0 , 16.5 , NRCA5_FULL , default
NRCA5_40STRIPE1_DHS_F322W2 , SUBARRAY , 468.0 , 1024.5 , 2048 , 36 , 1581.0 , 18.5 , NRCA5_FULL , default
NRCA5_80STRIPE2_DHS_F322W2 , SUBARRAY , 468.0 , 1024.5 , 2048 , 38 , 1581.0 , 19.5 , NRCA5_FULL , default
NRCA5_160STRIPE4_DHS_F322W2 , SUBARRAY , 468.0 , 1024.5 , 2048 , 39 , 1581.0 , 20.5 , NRCA5_FULL , default
NRCA5_256STRIPE4_DHS_F322W2 , SUBARRAY , 468.0 , 1024.5 , 2048 , 63 , 1581.0 , 32.5 , NRCA5_FULL , default
NRCA5_40STRIPE1_DHS_F444W , SUBARRAY , 1191.0 , 1024.5 , 2048 , 36 , 858.0 , 18.5 , NRCA5_FULL , default
NRCA5_80STRIPE2_DHS_F444W , SUBARRAY , 1191.0 , 1024.5 , 2048 , 38 , 858.0 , 19.5 , NRCA5_FULL , default
NRCA5_160STRIPE4_DHS_F444W , SUBARRAY , 1191.0 , 1024.5 , 2048 , 39 , 858.0 , 20.5 , NRCA5_FULL , default
NRCA5_256STRIPE4_DHS_F444W , SUBARRAY , 1191.0 , 1024.5 , 2048 , 63 , 858.0 , 32.5 , NRCA5_FULL , default
NRCA5_TADHSTS_SCI_F322W2 , ROI , 465.0 , 1015.7 , 32 , 32 , 16.0 , 16.5 , NRCA5_FULL , default
NRCA5_TADHSTS_SCI_F444W , ROI , 1187.0 , 1011.7 , 32 , 32 , 16.0 , 16.5 , NRCA5_FULL , default
NRCA5_41STRIPE1_DHS_F322W2 , SUBARRAY , 465.0 , 993.7 , 2048 , 40 , 1584.0 , 20.5 , NRCA5_FULL , default
NRCA5_82STRIPE2_DHS_F322W2 , SUBARRAY , 465.0 , 993.7 , 2048 , 40 , 1584.0 , 20.5 , NRCA5_FULL , default
NRCA5_164STRIPE4_DHS_F322W2 , SUBARRAY , 465.0 , 993.7 , 2048 , 40 , 1584.0 , 20.5 , NRCA5_FULL , default
NRCA5_260STRIPE4_DHS_F322W2 , SUBARRAY , 465.0 , 993.7 , 2048 , 64 , 1584.0 , 32.5 , NRCA5_FULL , default
NRCA5_41STRIPE1_DHS_F444W , SUBARRAY , 1187.0 , 993.7 , 2048 , 40 , 862.0 , 20.5 , NRCA5_FULL , default
NRCA5_82STRIPE2_DHS_F444W , SUBARRAY , 1187.0 , 993.7 , 2048 , 40 , 862.0 , 20.5 , NRCA5_FULL , default
NRCA5_164STRIPE4_DHS_F444W , SUBARRAY , 1187.0 , 993.7 , 2048 , 40 , 862.0 , 20.5 , NRCA5_FULL , default
NRCA5_260STRIPE4_DHS_F444W , SUBARRAY , 1187.0 , 993.7 , 2048 , 64 , 862.0 , 32.5 , NRCA5_FULL , default
# WFSC / MIMF Field Points (Module-A)
NRCA3_DHSPIL , FULLSCA , 1084.0 , 1194.0 , 2048 , 2048 , 965.0 , 1194.0 , NRCA3_FULL , default
NRCA3_DHSPIL_SUB96 , SUBARRAY , 1084.0 , 1194.0 , 96 , 96 , 48.0 , 49.0 , NRCA3_FULL , default
Expand Down
4 changes: 2 additions & 2 deletions pysiaf/tests/test_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def makeup_polynomial(order = 5):
a = np.zeros(terms)

np.random.seed(seed=1)
a[1] = 0.05 + 0.01 * np.random.rand(1)
a[1] = 0.05 + 0.01 * np.random.rand()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbennet I see we are changing the dimensions of the coefficients here. Does this change anything downstream?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to be specific, I know that with numpy 2.0 there were updates to array operations, but is there a benefit to changing values of a from float * single_value_array to float * float?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first case gives me the old warning

<ipython-input-8-7508f9c68cc9>:1: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

and the dimensions of both outputs look the same to me:

`In [10]: a[1] = 0.05 + 0.01 * np.random.rand(1)
:1: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
a[1] = 0.05 + 0.01 * np.random.rand(1)

In [11]: print(a.shape)
(3,)

In [12]: a[1] = 0.05 + 0.01 * np.random.rand()

In [13]: print(a.shape)
(3,)`

np.random.seed(seed=2)
a[2] = 0.0001 * np.random.rand(1)
a[2] = 0.0001 * np.random.rand()
np.random.seed(seed=3)
a[3:6] = 1.0e-7 * np.random.rand(3)
np.random.seed(seed=4)
Expand Down
2 changes: 1 addition & 1 deletion pysiaf/utils/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def prepend_rotation_to_polynomial(a, theta, verbose=False):
for j in range(m-n-mu, m-mu+1):
factor = (-1)**(m-n-mu) * choose(m-j, mu) * choose(j, m-n-mu)
cosSin = c**(j+2*mu-m+n) * s**(2*m-2*mu-j-n)
atrotate[m, n] = atrotate[m, n] + factor * cosSin * at[m, j]
atrotate[m, n] = np.squeeze(atrotate[m, n] + factor * cosSin * at[m, j])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking at a two-dimensional array in python:

>>>: x = np.random.rand(3,3)
>>> print(x)

array([[0.8991704 , 0.47865258, 0.24120141],
       [0.14969249, 0.59154556, 0.9030803 ],
       [0.46856477, 0.45624738, 0.92141728]])

>>> x.squeeze()

array([[0.8991704 , 0.47865258, 0.24120141],
       [0.14969249, 0.59154556, 0.9030803 ],
       [0.46856477, 0.45624738, 0.92141728]])

It looks like the squeeze method doesn't change the shape/dimensions of the array, is this change necessary?

if verbose:
print(m, n, j, factor, 'cos^', j+2*mu-m+n, 'sin^', 2*m-2*mu-j-n, ' A', m, j)
# Put back in linear layout
Expand Down