Fix NaN/read-only errors in Gaia filler and guide star handling#41
Open
Fix NaN/read-only errors in Gaia filler and guide star handling#41
Conversation
In fixcols_gaiadb_to_targetdb(), Gaia sources with missing astrometry (common for faint stars) were passed through with NaN proper motion and parallax values. These NaNs propagated into get_fp_positions(), causing the coordinate transform to produce NaN focal plane positions, which then triggered a ValueError in TargetSelector.constructKDTree(). Apply the same NaN-filling used in other fetch functions: pmra/pmdec -> 0, parallax -> 1e-7 (effectively zero parallax). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…error pfs.utils.coordinates.Subaru_POPT2_PFS.radec2radecplxpm() modifies the parallax argument in-place (str_plx[...] = 0.00001). With Pandas 3.x, DataFrame.to_numpy() can return a read-only view due to Copy-on-Write, causing a ValueError when the function tries to write to it. Pass .copy() of the parallax array at both ctrans call sites in generate_guidestars_from_gaiadb() and generate_guidestars_from_csv(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pandas 3.0 enables Copy-on-Write by default, causing .to_numpy() to return read-only views. External PFS packages (pfs_utils, ics_cobraOps, etc.) have not been validated against Pandas 3.x and may have similar in-place modification issues. Pin to <3.0.0 until the ecosystem catches up. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
@wanqqq31 @yukimoritani I'm wondering whether filling NaN values as seen in this PR is good for our purpose. |
…ptions and idiomatic checks - Use specific exception types (ValueError, FileNotFoundError, KeyError, TypeError, AttributeError) instead of bare except - Replace == True/False/None with idiomatic is None, not x, elif x, ~df[col], df[col] - Use .isin() for mixed-type is_medium_resolution column (str "L/M" + bool) - Fix E701 inline if statement in reconfigure_fibers_ppp.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dbutils.py: Fill NaNpmra/pmdec/parallaxvalues for Gaia filler targets infixcols_gaiadb_to_targetdb(). Gaia sources (especially faint ones) often lack astrometry, and these NaNs propagated intoget_fp_positions(), causing the coordinate transform to produce NaN focal plane positions, which then triggeredValueError: data must be finiteinTargetSelector.constructKDTree().designutils.py: Pass.copy()of the parallax array toctrans()ingenerate_guidestars_from_gaiadb()andgenerate_guidestars_from_csv().pfs.utils.Subaru_POPT2_PFS.radec2radecplxpm()modifies the parallax array in-place, which raisesValueError: assignment destination is read-onlywhen Pandas returns a read-only view (default in Pandas 3.x with Copy-on-Write).pyproject.toml: Pinpandas<3.0.0until external PFS packages are validated against Pandas 3.x Copy-on-Write behavior.exceptwith specific exception types (ValueError,FileNotFoundError,KeyError,TypeError,AttributeError); replace== True/False/Nonecomparisons with idiomaticis None,not x,elif x,~df[col]; use.isin()for the mixed-typeis_medium_resolutioncolumn; fix E701 inlineifstatement.Test plan
pfs-fiber-allocationend-to-end and confirm noValueError: data must be finitefromKDTreeValueError: assignment destination is read-onlyfromradec2radecplxpmpfsDesign🤖 Generated with Claude Code