(String path)
| 56 | public static final ExecutorService savingThread = Executors.newSingleThreadExecutor(); |
| 57 | |
| 58 | @AstroImageJ(reason = "commented out GET FILE...file deletion iff exists, use nom.tam for export", modified = true) |
| 59 | public void run(String path) { |
| 60 | ImagePlus imp = IJ.getImage(); |
| 61 | |
| 62 | if (true) { // AIJ uses nom.tam for fits export |
| 63 | saveImage(imp, path, imp.getCurrentSlice()); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | ImageProcessor ip = imp.getProcessor(); |
| 68 | int numImages = imp.getImageStackSize(); |
| 69 | int bitDepth = imp.getBitDepth(); |
| 70 | if (bitDepth==24) { |
| 71 | IJ.error("RGB images are not supported"); |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | // GET PATH |
| 76 | if (path == null || path.trim().length() == 0) { |
| 77 | String title = "image.fits"; |
| 78 | SaveDialog sd = new SaveDialog("Write FITS image",title,".fits"); |
| 79 | path = sd.getDirectory()+sd.getFileName(); |
| 80 | } |
| 81 | |
| 82 | /*// GET FILE |
| 83 | File f = new File(path); |
| 84 | String directory = f.getParent()+File.separator; |
| 85 | String name = f.getName(); |
| 86 | if (f.exists()) f.delete();*/ |
| 87 | int numBytes = 0; |
| 88 | |
| 89 | cal = imp.getCalibration(); |
| 90 | unsigned16 = (bitDepth==16 && cal.getFunction()==Calibration.NONE && cal.getCoefficients()==null); |
| 91 | |
| 92 | // GET IMAGE |
| 93 | if (bitDepth==8) { |
| 94 | numBytes = 1; |
| 95 | if (cal.getFunction()!=Calibration.NONE && cal.getCoefficients()!=null) { |
| 96 | bZero = cal.getCoefficients()[0]; |
| 97 | if (cal.getCoefficients()[1] != 0) bScale = cal.getCoefficients()[1]; |
| 98 | } |
| 99 | } else if (ip instanceof ShortProcessor) { |
| 100 | numBytes = 2; |
| 101 | if (unsigned16) { |
| 102 | bZero = 32768.0; |
| 103 | bScale = 1.0; |
| 104 | } else { |
| 105 | if (cal.getCoefficients()[1] != 0) bScale = cal.getCoefficients()[1]; |
| 106 | bZero = cal.getCoefficients()[0] + (32768.0*bScale); |
| 107 | } |
| 108 | } else if (ip instanceof FloatProcessor) { |
| 109 | numBytes = 4; //float processor does not support calibration - data values are shifted and scaled in FITS_Reader |
| 110 | bZero = 0.0; //float values are written back out without shifting |
| 111 | bScale = 1.0; //and without scaling |
| 112 | } |
| 113 | |
| 114 | int fillerLength = 2880 - ( (numBytes * imp.getWidth() * imp.getHeight()) % 2880 ); |
| 115 |
nothing calls this directly
no test coverage detected