MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / FITS_Reader

Class FITS_Reader

ij/src/main/java/ij/plugin/FITS_Reader.java:86–1416  ·  view source on GitHub ↗

Opens and displays FITS images. The FITS format is described at "http://fits.gsfc.nasa.gov/fits_standard.html". Add setOption("FlipFitsImages",false) to the Edit/Options/Startup dialog to have FITS images not flipped vertically.

Source from the content-addressed store, hash-verified

84 * flipped vertically.
85*/
86@AstroImageJ(reason = "Support for compressed FITS files via nom.tam.fits, invert flipImages to fix inverted aperture display",
87 modified = true)
88@Translation("Fits Reader")
89public class FITS_Reader extends ImagePlus implements PlugIn {
90 private static final boolean USE_NEW_READER = !"true".equalsIgnoreCase(System.getProperty("legacy.fits.reader"));
91 private static boolean flipImages = true;
92 // private WCS wcs;
93 private ImagePlus imagePlus;
94 private String directory;
95 private String fileName;
96 private String fileBase;
97 private String fileType;
98 private int wi;
99 private int he;
100 private int de;
101 @AstroImageJ(reason = "make double for the images that need it", modified = true)
102 private double bzero;
103 @AstroImageJ(reason = "make double for the images that need it", modified = true)
104 private double bscale;
105
106 private Locale locale = Locale.US;
107 private DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
108 private DecimalFormat fourDigits = new DecimalFormat("0000", dfs);
109 private DecimalFormat fiveDigits = new DecimalFormat("00000", dfs);
110
111 public static boolean skipTessQualCheck = Prefs.getBoolean(".aij.skipTessQualCheck", false);
112 private static final LeapSeconds LEAP_SECONDS = new LeapSeconds();
113
114 // The image data comes in different types, but in the end, we turn them all into floats.
115 // So no matter what type the data is, we wrap it with a lambda that takes two indices and
116 // returns a float. This uses floats as there is no DoubleProcessor from imagej
117 @FunctionalInterface
118 private interface TableWrapper { double valueAt(int x, int y); }
119
120 public static HeaderCardFilter filter = null;
121 private static final MPTableLoadSettings MP_TABLE_LOAD_SETTINGS = new MPTableLoadSettings();
122 public static final ScopedValue<Boolean> HEADER_ONLY = ScopedValue.newInstance();
123 public static final ScopedValue<ImageProcessor> REF_SLICE = ScopedValue.newInstance();
124
125 /**
126 * Main processing method for the FITS_Reader object
127 *
128 * @param path path of FITS file
129 */
130 public void run(String path) {
131 // wcs = null;
132 imagePlus = null;
133
134 AIJLogger.setLogAutoCloses(Prefs.getBoolean(AIJLogger.CERTAIN_LOGS_AUTO_CLOSE, true));
135
136 if (USE_NEW_READER) {
137 try (var r = FitsReader.create(path)) {
138 if (r.size() <= 0) {
139 if (r.isMeasurementsTable()) {
140 // Read table
141 r.getHeaders();
142 }
143

Callers

nothing calls this directly

Calls 3

getBooleanMethod · 0.95
getPropertyMethod · 0.45
newInstanceMethod · 0.45

Tested by

no test coverage detected