本文整理汇总了Java中nom.tam.fits.BasicHDU类的典型用法代码示例。如果您正苦于以下问题:Java BasicHDU类的具体用法?Java BasicHDU怎么用?Java BasicHDU使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicHDU类属于nom.tam.fits包,在下文中一共展示了BasicHDU类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readFits
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public void readFits(String fitsUrl) throws IOException, FitsException {
URL fetchUrl = new URL(fitsUrl);
String[] fileName = fitsUrl.split("/");
try (InputStream is = PluginUtils.copyUrlOpenStream(fetchUrl, "PTF-" + fileName[fileName.length - 1], 3)) {
Fits fits = new Fits(is);
for (BasicHDU<?> basicHDU : fits.read()) {
System.out.println(basicHDU);
}
ImageHDU image = (ImageHDU) fits.getHDU(1);
// float[] mags = (float[]) table.getColumn("MAG_V");
// float[] errs = (float[]) table.getColumn("ERRMAG_V");
// double[] barytimes = (double[]) table.getColumn("BARYTIME");
// double[] telapses = (double[]) table.getColumn("TELAPSE");
//
// for (int i = 0; i < mags.length; i++) {
// double jd = barytimes[i] + 2451544.5 + telapses[i] / 2 / 86400;
// System.out.println(jd + "," + mags[i] + "," + errs[i]);
// }
}
}
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:22,代码来源:Main.java
示例2: read
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
protected void read(Fits fits, boolean readFully) throws Exception {
// Read in entire FITS file
BasicHDU<?>[] HDU = fits.read();
parseScanPrimaryHDU(HDU[0]);
instrument.parseScanPrimaryHDU(HDU[0]);
instrument.parseHardwareHDU((BinaryTableHDU) HDU[1]);
instrument.validate(this);
clear();
Mustang2Integration integration = getIntegrationInstance();
integration.read((BinaryTableHDU) HDU[2]);
add(integration);
try { fits.getStream().close(); }
catch(IOException e) {}
instrument.samplingInterval = integration.instrument.samplingInterval;
instrument.integrationTime = integration.instrument.integrationTime;
}
开发者ID:attipaci,项目名称:crush,代码行数:21,代码来源:Mustang2Scan.java
示例3: readImage
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public void readImage(Fits fits) throws Exception {
image = new Data2D();
int N = fits.getNumberOfHDUs();
if(N == 1) {
image.read(fits);
return;
}
try {
int n = Integer.parseInt(type);
image.read(fits, n);
}
catch(NumberFormatException e) {
for(BasicHDU hdu : fits.read()) {
String extName = hdu.getHeader().getStringValue("EXTNAME");
if(extName != null) if(extName.equalsIgnoreCase(type)) {
image.read(hdu);
return;
}
}
}
}
开发者ID:attipaci,项目名称:crush,代码行数:24,代码来源:HistogramTool.java
示例4: main
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public static void main(String args[])
throws FitsException, IOException
{
if (args.length != 3)
usage();
//String out_name = "decimate_out.fits";
String in_name = args[0];
String out_name = args[1];
int decimate_factor = Integer.valueOf(args[2]);
Decimate decimate = new Decimate();
Fits f = new Fits(args[0]);
BasicHDU basic_hdu = f.getHDU(0);
System.out.println("decimate.isDecimateable = " + decimate.isDecimateable(f, basic_hdu));
//f = new Fits(args[0]);
Fits out_fits = decimate.do_decimate(f, basic_hdu, decimate_factor);
FileOutputStream fo = new java.io.FileOutputStream(out_name);
BufferedDataOutputStream o = new BufferedDataOutputStream(fo);
out_fits.write(o);
}
开发者ID:lsst,项目名称:firefly,代码行数:23,代码来源:Decimate.java
示例5: getMasksInFits
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
private short[] getMasksInFits(Fits fits) throws FitsException {
//get all the Header Data Unit from the fits file
BasicHDU[] HDUs = fits.read();
for (int j = 0; j < HDUs.length; j++) {
if (!(HDUs[j] instanceof ImageHDU)) {
continue; //ignor non-image extensions
}
Header header = HDUs[j].getHeader();
if (header == null) {
throw new FitsException("Missing header in FITS file");
}
else if ( header.containsKey("EXTTYPE") && header.getStringValue("EXTTYPE").equalsIgnoreCase("mask") ){
short[] mArray=(short[]) ArrayFuncs.flatten(ArrayFuncs.convertArray(HDUs[j].getData().getData(), Short.TYPE, true));
return getMasks(header, mArray);
}
}
return null;
}
开发者ID:lsst,项目名称:firefly,代码行数:23,代码来源:FitsRead.java
示例6: createFitsReadArray
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
/**
* This method is used by FitsImageCube only
* @param fits
* @param hdu
* @return
* @throws FitsException
*/
public static FitsRead[] createFitsReadArray(Fits fits, BasicHDU hdu)
throws FitsException {
if (hdu == null || hdu.getData().getSize()==0) {
// Error: file doesn't seem to have any HDUs!
return null;
}
BasicHDU[] HDUs={hdu};
ArrayList<BasicHDU> HDUList = getHDUList(HDUs);
if (HDUList.size() == 0)
throw new FitsException("No image headers in FITS file");
FitsRead[] fitsReadAry = new FitsRead[HDUList.size()];
for (int i = 0; i < HDUList.size(); i++) {
fitsReadAry[i] = new FitsRead(fits, (ImageHDU) HDUList.get(i));
fitsReadAry[i].indexInFile = i;
}
return fitsReadAry;
}
开发者ID:lsst,项目名称:firefly,代码行数:31,代码来源:FitsRead.java
示例7: splitFitsCube
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
private static BasicHDU[] splitFitsCube(ImageHDU hdu)
throws FitsException {
Header header = hdu.getHeader();
int bitpix = header.getIntValue("BITPIX", -1);
if (!SUPPORTED_BIT_PIXS.contains(new Integer(bitpix))) {
System.out.println("Unimplemented bitpix = " + bitpix);
}
int naxis3 = header.getIntValue("NAXIS3", 0);
float[][][] data32 = (float[][][]) ArrayFuncs.convertArray(hdu.getData().getData(), Float.TYPE, true);
BasicHDU[] hduList = new BasicHDU[naxis3];
for (int i = 0; i < naxis3; i++) {
hduList[i] = makeHDU(hdu,data32[i] );
hdu.addValue("SPOT_PL", i + 1, "PLANE OF FITS CUBE (IN SPOT)");
hdu.getHeader().resetOriginalSize();
}
return hduList;
}
开发者ID:lsst,项目名称:firefly,代码行数:24,代码来源:FitsRead.java
示例8: addIntegrationsFrom
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
@Override
public void addIntegrationsFrom(BasicHDU<?>[] HDU) throws Exception {
ArrayList<BinaryTableHDU> dataHDUs = new ArrayList<BinaryTableHDU>();
for(int i=1; i<HDU.length; i++) if(HDU[i] instanceof BinaryTableHDU) {
Header header = HDU[i].getHeader();
String extName = header.getStringValue("EXTNAME");
if(extName.equalsIgnoreCase("Timestream")) dataHDUs.add((BinaryTableHDU) HDU[i]);
}
HawcPlusIntegration integration = this.getIntegrationInstance();
integration.read(dataHDUs);
add(integration);
}
开发者ID:attipaci,项目名称:crush,代码行数:16,代码来源:HawcPlusScan.java
示例9: backgroundWork
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
@Override
protected PfssData backgroundWork() {
try (NetClient nc = NetClient.of(url); Fits fits = new Fits(nc.getStream())) {
BasicHDU<?> hdus[] = fits.read();
if (hdus == null || hdus.length < 2 || !(hdus[1] instanceof BinaryTableHDU))
throw new Exception("Could not read FITS: " + url);
BinaryTableHDU bhdu = (BinaryTableHDU) hdus[1];
Header header = bhdu.getHeader();
String dateFits = header.getStringValue("DATE-OBS");
if (dateFits == null)
throw new Exception("DATE-OBS not found: " + url);
JHVDate date = new JHVDate(dateFits);
if (time != date.milli)
throw new Exception("Inconsistent DATE-OBS. Expected " + new JHVDate(time) + ", got " + date + ": " + url);
int points = header.getIntValue("HIERARCH.POINTS_PER_LINE");
if (points == 0)
throw new Exception("POINTS_PER_LINE not found: " + url);
short[] flinex = (short[]) bhdu.getColumn("FIELDLINEx");
short[] fliney = (short[]) bhdu.getColumn("FIELDLINEy");
short[] flinez = (short[]) bhdu.getColumn("FIELDLINEz");
short[] flines = (short[]) bhdu.getColumn("FIELDLINEs");
if (flinex.length != fliney.length || flinex.length != flinez.length || flinex.length != flines.length)
throw new Exception("Fieldline arrays not equal " + flinex.length + " " + fliney.length + " " + flinez.length + " " + flinex.length + ": " + url);
return new PfssData(date, flinex, fliney, flinez, flines, points);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:35,代码来源:PfssDataLoader.java
示例10: do_crop
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public static Fits do_crop(Fits inFits, int min_x, int min_y, int max_x, int max_y)
throws FitsException
{
if (SUTDebug.isDebug())
{
System.out.println("RBH do_crop min_x = " + min_x +
" min_y = " + min_y + " max_x = " + max_x + " max_y = " + max_y);
}
BasicHDU out_HDU = null;
Fits ret_fits = new Fits();
BasicHDU[] myHDUs = inFits.read();
out_HDU = split_FITS_cube(myHDUs[0], min_x, min_y, max_x, max_y);
ret_fits.addHDU(out_HDU);
return(ret_fits);
}
开发者ID:lsst,项目名称:firefly,代码行数:16,代码来源:Crop.java
示例11: isCropable
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
static public boolean isCropable(Fits fits)
{
BasicHDU hdus[];
try
{
hdus = fits.read();
}
catch (FitsException fe)
{
return(false);
}
if (hdus.length > 1)
{
return (false);
}
Header header = hdus[0].getHeader();
int naxis = header.getIntValue("NAXIS");
if (naxis < 3)
{
return (true);
}
int naxis3 = header.getIntValue("NAXIS3");
if (naxis3 > 1)
{
return (false);
}
else
{
return (true);
}
}
开发者ID:lsst,项目名称:firefly,代码行数:32,代码来源:CropFile.java
示例12: getFirstHeader
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public static Header getFirstHeader(File f) throws FitsException {
BasicHDU myHDU = null;
Header header;
Fits myFits = new Fits(f);
try
{
//myHDUs = myFits.read();
myHDU = myFits.readHDU();
}
catch (FitsException fe)
{
throw fe;
//System.out.println("RBH caught FitsException");
//fe.printStackTrace();
}
catch (IOException ioe)
{
throw new FitsException(ioe.getMessage());
//System.out.println("RBH caught IOException");
//ioe.printStackTrace();
}
if (myHDU == null)
throw new FitsException("cannot read header");
header = myHDU.getHeader();
return header;
}
开发者ID:lsst,项目名称:firefly,代码行数:28,代码来源:FitsValidator.java
示例13: writeFitsFile
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public static void writeFitsFile(OutputStream stream, FitsRead[] fitsReadAry, Fits refFits) throws FitsException, IOException{
Fits output_fits = new Fits();
for(FitsRead fr : fitsReadAry) {
BasicHDU one_image_hdu = refFits.getHDU(0);
Header header = one_image_hdu.getHeader();
//Data data = one_image_hdu.getData();
//ImageHDU image_hdu = new ImageHDU(header, data);
ImageHDU imageHDU = new ImageHDU(header, fr.getImageData(header, fr.float1d));
output_fits.addHDU(imageHDU);
}
output_fits.write(new DataOutputStream(stream));
}
开发者ID:lsst,项目名称:firefly,代码行数:14,代码来源:FitsRead.java
示例14: main
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
/**
* Test the FitsImaegCube
* @param args
* @throws FitsException
* @throws IOException
*/
public static void main(String[] args) throws FitsException, IOException {
if (args.length != 2) {
usage();
}
String inFitsName = args[0];
String outFitsName = args[1];
Fits fits = new Fits(inFitsName);
FitsImageCube fic = FitsRead.createFitsImageCube(fits);
Object[] keys = fic.getMapKeys();
FitsRead fitsRead0 = fic.getFitsReadMap().get(keys[0])[1];
FileOutputStream fo = new java.io.FileOutputStream(outFitsName+"fitsRead1ReadAsImageCube.fits");
fitsRead0.writeSimpleFitsFile(fo);
fo.close();
FitsRead[] fry = FitsRead.createFitsReadArray(fits);
fo = new java.io.FileOutputStream(outFitsName+"fitsRead1ReadAsFitsRead.fits");//"f-32AsFitsRead.fits");//
fry[1].writeSimpleFitsFile(fo);
fo.close();
Fits newFits = new Fits(outFitsName+"fitsRead1ReadAsFitsRead.fits");
BasicHDU[] hdus = newFits.read();
}
开发者ID:lsst,项目名称:firefly,代码行数:33,代码来源:FitsRead.java
示例15: open_ref
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
private void open_ref(Fits refFits) throws FitsException
{
try
{
BasicHDU HDU = refFits.getHDU(0);
ref_fits_header = HDU.getHeader();
//BufferedDataInputStream ibs = refFits.getStream();
//ref_fits_header = Header.readHeader(ibs);
if (ref_fits_header == null)
{
if (SUTDebug.isDebug())
{
System.out.println("HDU null! (ref image)");
}
throw new FitsException("HDU null! (ref image)");
}
ref_header = new ImageHeader(ref_fits_header);
}
catch (IOException e)
{
if (SUTDebug.isDebug())
{
System.out.println("got IOException: " + e.getMessage());
}
throw new FitsException("got IOException: " + e.getMessage());
}
open_ref();
}
开发者ID:lsst,项目名称:firefly,代码行数:31,代码来源:Geom.java
示例16: getImageHDU
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
/**
* Convert the tiled image into a regular ImageHDU.
*
* @return The converted HDU.
*/
public ImageHDU getImageHDU() throws FitsException, IOException {
System.out.println("In getImage!!!");
int[] axes = new int[hdr.getIntValue("ZNAXIS")];
int bitpix = hdr.getIntValue("ZBITPIX");
int[] tiles = new int[axes.length];
boolean found = true;
getDimens(axes, tiles);
Object data = ArrayFuncs.newInstance(baseClass, ArrayFuncs.reverseIndices(axes));
int[] dataCorner = new int[naxis];
TileLooper tl = new TileLooper(axes, tiles);
Iterator<TileDescriptor> ti = tl.iterator();
Object[] rows = (Object[]) getColumn("COMPRESSED_DATA");
int nTile = 0;
String className = data.getClass().getName();
for (TileDescriptor td: tl) {
byte[] tileData = (byte[]) rows[td.count];
Object tile = getTile(td, tileData);
insertTile(tile, td.corner, td.size, data, dataCorner, imageSize, className, 0);
}
System.out.println("Finished the loop");
BasicHDU bhdu = FitsFactory.HDUFactory(data);
//importKeywords(bhdu);
return (ImageHDU) bhdu;
}
开发者ID:jankotek,项目名称:asterope,代码行数:35,代码来源:TiledImageHDU.java
示例17: importKeywords
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
private void importKeywords(BasicHDU hdu) {
Header newHdr = hdu.getHeader();
Header oldHdr = getHeader();
Cursor newC = newHdr.iterator();
newC.setKey("END");
Cursor oldC = oldHdr.iterator();
oldC.setKey("NAXIS");
while (oldC.hasNext()) {
HeaderCard old = (HeaderCard) (oldC.next());
String key = old.getKey();
if (!reservedKeys.contains(key)) {
newC.add(old);
}
}
}
开发者ID:jankotek,项目名称:asterope,代码行数:16,代码来源:TiledImageHDU.java
示例18: parseScanPrimaryHDU
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public void parseScanPrimaryHDU(BasicHDU<?> hdu) throws HeaderCardException {
Header header = hdu.getHeader();
// Load any options based on the FITS header...
instrument.setFitsHeaderOptions(header);
fitsVersion = header.getStringValue("FITSVER");
if(fitsVersion.length() == 0) fitsVersion = null;
// Source Information
String sourceName = header.getStringValue("OBJECT");
if(sourceName == null) sourceName = descriptor;
setSourceName(sourceName);
setSerial(header.getIntValue("SCAN", -1));
project = header.getStringValue("PROJID");
// GBT 79:50:23.406 W, 38:25:59.236 N
site = new GeodeticCoordinates(
-(79 * Unit.deg + 50 * Unit.arcmin + 23.406 * Unit.arcsec),
38 * Unit.deg + 25 * Unit.arcmin + 59.236 * Unit.arcsec
);
// or use SITELON / SITELAT from FITS?...
timeStamp = header.getStringValue("DATE-OBS");
String date = timeStamp.substring(0, timeStamp.indexOf('T'));
String startTime = timeStamp.substring(timeStamp.indexOf('T') + 1);
id = date + "." + getSerial();
equatorial = new EquatorialCoordinates(
header.getDoubleValue("RA0") * Unit.hourAngle,
header.getDoubleValue("DEC0") * Unit.deg,
CoordinateEpoch.J2000
);
info("[" + sourceName + "] of project " + project + " observed on " + date + " at " + startTime);
info("Equatorial: " + equatorial.toString());
if(hasOption("tau")) {
zenithTau = option("tau").getDouble();
info("Using tau: " + Util.f3.format(zenithTau));
}
else if(header.containsKey("TAUZ")) {
zenithTau = header.getDoubleValue("TAUZ");
info("Zenith tau from skydip: " + Util.f3.format(zenithTau));
}
else {
warning("No tau in FITS, or specified. No extinction correction.");
}
}
开发者ID:attipaci,项目名称:crush,代码行数:52,代码来源:Mustang2Scan.java
示例19: parseScanPrimaryHDU
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
public void parseScanPrimaryHDU(BasicHDU<?> hdu) throws HeaderCardException, FitsException {
Header header = hdu.getHeader();
// Platform
String platform = header.getStringValue("PLATFORM");
if(platform == null) platform = "Cassegrain";
mount = platform.equalsIgnoreCase("NASMYTH") ? Mount.RIGHT_NASMYTH : Mount.CASSEGRAIN;
info(mount.name + " mount assumed.");
rotatorZeroAngle = header.getDoubleValue("ROTZERO", Double.NaN) * Unit.deg;
rotatorAngle = header.getDoubleValue("ROTATOR", rotatorZeroAngle / Unit.deg) * Unit.deg;
rotatorOffset = header.getDoubleValue("ROTOFFST", 0.0) * Unit.deg;
rotatorMode = header.getStringValue("ROTMODE");
if(rotatorMode == null) rotatorMode = "Unknown";
// Various fixes for premature FITS files, without valid rotator information
// These typically have 1000 values.
if(rotatorZeroAngle == 1000.0 * Unit.deg) {
rotatorZeroAngle = 16.0 * Unit.deg;
info(">>> Fix: missing rotator zero angle set to 16.0 deg.");
}
if(rotatorAngle == 1000.0 * Unit.deg) {
rotatorAngle = Double.NaN;
info(">>> Fix: missing rotator angle..");
}
if(rotatorOffset == 1000.0 * Unit.deg) {
rotatorOffset = 0.0;
info(">>> Fix: assuming no rotator offset.");
}
// Focus
focusX = header.getDoubleValue("FOCUS_X") * Unit.mm;
focusY = header.getDoubleValue("FOCUS_Y") * Unit.mm;
focusZ = header.getDoubleValue("FOCUS_Z") * Unit.mm;
focusYOffset = header.getDoubleValue("FOCUS_YO") * Unit.mm;
focusZOffset = header.getDoubleValue("FOCUS_ZO") * Unit.mm;
focusMode = header.getStringValue("FOCMODE");
if(focusMode == null) focusMode = "Unknown";
info("Focus [" + focusMode + "]"
+ " X=" + Util.f2.format(focusX / Unit.mm)
+ " Y=" + Util.f2.format(focusY / Unit.mm)
+ " Z=" + Util.f2.format(focusZ / Unit.mm)
+ " Yoff=" + Util.f2.format(focusYOffset / Unit.mm)
+ " Zoff=" + Util.f2.format(focusZOffset / Unit.mm)
);
// DSOS
dsosUsed = header.getBooleanValue("DSOS");
dsosVersion = header.getStringValue("DSOSVER");
if(dsosUsed) info("DSOS version " + dsosVersion);
}
开发者ID:attipaci,项目名称:crush,代码行数:60,代码来源:CSOCamera.java
示例20: crop_extensions
import nom.tam.fits.BasicHDU; //导入依赖的package包/类
/**
* Crop images from a FITS file with extensions, given image coordinates
* Read the images directly from the FITS file on disk and write the
* output to disk
* @param in_filename FITS file on disk
* @param out_filename output FITS file on disk
* @param min_x first pixel of crop box
* @param min_y first line of crop box
* @param max_x last pixel of crop box
* @param max_y last line of crop box
*/
static public void crop_extensions(String in_filename, String out_filename,
int min_x, int min_y, int max_x, int max_y)
throws FitsException, IOException
{
Fits in_fits = new Fits(in_filename);
Fits out_fits = new Fits();
int x_center = (min_x + max_x ) / 2;
int y_center = (min_y + max_y ) / 2;
int x_size = Math.abs(max_x - min_x);
int y_size = Math.abs(max_y - min_y);
int extension = 0;
while (true)
{
BasicHDU hdu = in_fits.getHDU(extension);
BasicHDU new_hdu;
if (hdu == null)
break;
if (hdu instanceof ImageHDU)
{
ImageHDU h = (ImageHDU) hdu;
Header old_header = h.getHeader();
int naxis = old_header.getIntValue("NAXIS");
if (naxis == 0)
{
/* it's a null image - probably the primary image */
new_hdu = hdu;
}
else
{
Fits temp_fits = common_crop(h, old_header,
x_center, y_center, x_size, y_size);
new_hdu = temp_fits.getHDU(0);
}
}
else
{
/* not an ImageHDU - just copy input to output */
new_hdu = hdu;
}
out_fits.addHDU(new_hdu);
extension++;
}
FileOutputStream fo = new java.io.FileOutputStream(out_filename);
BufferedDataOutputStream o = new BufferedDataOutputStream(fo);
out_fits.write(o);
}
开发者ID:lsst,项目名称:firefly,代码行数:62,代码来源:CropFile.java
注:本文中的nom.tam.fits.BasicHDU类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论