Search in sources :

Example 1 with Axis

use of ca.nrc.cadc.caom2.wcs.Axis in project caom2db by opencadc.

the class AbstractObservationDAOTest method getCustomChunk.

private Chunk getCustomChunk(boolean full) {
    Chunk c = new Chunk();
    c.metaProducer = URI.create("test:chunk/roundrip-1.0");
    if (full)
        c.productType = ProductType.SCIENCE;
    c.customAxis = new Integer(1);
    c.custom = new CustomWCS(new CoordAxis1D(new Axis("FDEP", "flibbles")));
    c.custom.getAxis().range = new CoordRange1D(new RefCoord(100.0, 1.0), new RefCoord(900.0, 200.0));
    c.custom.getAxis().bounds = new CoordBounds1D();
    c.custom.getAxis().bounds.getSamples().add(new CoordRange1D(new RefCoord(100.0, 100.0), new RefCoord(400.0, 140.0)));
    c.custom.getAxis().bounds.getSamples().add(new CoordRange1D(new RefCoord(600.0, 160.0), new RefCoord(900.0, 200.0)));
    c.custom.getAxis().function = new CoordFunction1D(1024L, 1.0, new RefCoord(1.0, 1.0));
    return c;
}
Also used : CoordAxis1D(ca.nrc.cadc.caom2.wcs.CoordAxis1D) CustomWCS(ca.nrc.cadc.caom2.wcs.CustomWCS) CoordRange1D(ca.nrc.cadc.caom2.wcs.CoordRange1D) RefCoord(ca.nrc.cadc.caom2.wcs.RefCoord) Chunk(ca.nrc.cadc.caom2.Chunk) CoordFunction1D(ca.nrc.cadc.caom2.wcs.CoordFunction1D) CoordBounds1D(ca.nrc.cadc.caom2.wcs.CoordBounds1D) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) CustomAxis(ca.nrc.cadc.caom2.CustomAxis) Axis(ca.nrc.cadc.caom2.wcs.Axis)

Example 2 with Axis

use of ca.nrc.cadc.caom2.wcs.Axis in project caom2db by opencadc.

the class AbstractObservationDAOTest method getObservableChunk.

private Chunk getObservableChunk(boolean full) {
    Chunk c = new Chunk();
    c.metaProducer = URI.create("test:chunk/roundrip-1.0");
    if (full)
        c.productType = ProductType.SCIENCE;
    c.observableAxis = new Integer(1);
    c.observable = new ObservableAxis(new Slice(new Axis("flux", "J"), new Long(3L)));
    c.observable.independent = new Slice(new Axis("WAV", "um"), new Long(4L));
    return c;
}
Also used : Slice(ca.nrc.cadc.caom2.wcs.Slice) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) Chunk(ca.nrc.cadc.caom2.Chunk) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) CustomAxis(ca.nrc.cadc.caom2.CustomAxis) Axis(ca.nrc.cadc.caom2.wcs.Axis)

Example 3 with Axis

use of ca.nrc.cadc.caom2.wcs.Axis in project caom2db by opencadc.

the class AbstractObservationDAOTest method getSpecChunk.

private Chunk getSpecChunk(boolean full) {
    Chunk c = new Chunk();
    c.metaProducer = URI.create("test:chunk/roundrip-1.0");
    if (full)
        c.productType = ProductType.SCIENCE;
    c.energyAxis = new Integer(1);
    c.energy = new SpectralWCS(new CoordAxis1D(new Axis("WAVE", "m")), "TOPOCENT");
    c.energy.ssysobs = "TOPOCENT";
    c.energy.ssyssrc = "TOPOCENT";
    c.energy.restwav = 1.0e-6;
    c.energy.resolvingPower = 50000.0;
    RefCoord c1 = new RefCoord(0.5, 300.0e-9);
    RefCoord c2 = new RefCoord(1024.0, 450.0e-9);
    RefCoord c3 = new RefCoord(2048.5, 600.0e-9);
    c.energy.getAxis().range = new CoordRange1D(c1, c3);
    c.energy.getAxis().bounds = new CoordBounds1D();
    c.energy.getAxis().bounds.getSamples().add(new CoordRange1D(c1, c2));
    c.energy.getAxis().bounds.getSamples().add(new CoordRange1D(c2, c3));
    c.energy.getAxis().function = new CoordFunction1D(1024L, (c3.val - c1.val) / 1024.0, c1);
    return c;
}
Also used : CoordAxis1D(ca.nrc.cadc.caom2.wcs.CoordAxis1D) SpectralWCS(ca.nrc.cadc.caom2.wcs.SpectralWCS) CoordRange1D(ca.nrc.cadc.caom2.wcs.CoordRange1D) RefCoord(ca.nrc.cadc.caom2.wcs.RefCoord) Chunk(ca.nrc.cadc.caom2.Chunk) CoordFunction1D(ca.nrc.cadc.caom2.wcs.CoordFunction1D) CoordBounds1D(ca.nrc.cadc.caom2.wcs.CoordBounds1D) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) CustomAxis(ca.nrc.cadc.caom2.CustomAxis) Axis(ca.nrc.cadc.caom2.wcs.Axis)

Example 4 with Axis

use of ca.nrc.cadc.caom2.wcs.Axis in project caom2db by opencadc.

the class AbstractObservationDAOTest method testUpdateSimpleObservation.

@Test
public void testUpdateSimpleObservation() {
    try {
        int minDepth = 1;
        int maxDepth = 5;
        boolean full = true;
        for (int i = minDepth; i <= maxDepth; i++) {
            log.info("testUpdateSimpleObservation: full=" + full + ", depth=" + i);
            Observation orig = getTestObservation(full, i, false, true);
            // txnManager.startTransaction();
            dao.put(orig);
            // txnManager.commitTransaction();
            // this is so we can detect incorrect timestamp round trips
            // caused by assigning something other than what was stored
            Thread.sleep(2 * TIME_TOLERANCE);
            Observation ret1 = dao.get(orig.getURI());
            Assert.assertNotNull("found", ret1);
            log.info("testUpdateSimpleObservation/created: orig vs ret1");
            testEqual(orig, ret1);
            // the lastModified timestamps are maintained by the DAO, so lets set them to null here
            Util.assignLastModified(ret1, null, "lastModified");
            for (Plane p : ret1.getPlanes()) {
                Util.assignLastModified(p, null, "lastModified");
                for (Artifact a : p.getArtifacts()) {
                    Util.assignLastModified(a, null, "lastModified");
                    for (Part pa : a.getParts()) {
                        Util.assignLastModified(pa, null, "lastModified");
                        for (Chunk c : pa.getChunks()) Util.assignLastModified(c, null, "lastModified");
                    }
                }
            }
            // now modify the objects
            ret1.proposal.getKeywords().add("something=new");
            if (i > 1) {
                Plane p = ret1.getPlanes().iterator().next();
                p.calibrationLevel = CalibrationLevel.PRODUCT;
                if (i > 2) {
                    Artifact a = p.getArtifacts().iterator().next();
                    a.contentType = "application/foo";
                    a.contentLength = 123456789L;
                    if (i > 3) {
                        Part part = a.getParts().iterator().next();
                        part.productType = ProductType.PREVIEW;
                        if (i > 4) {
                            Chunk c = part.getChunks().iterator().next();
                            c.observable = new ObservableAxis(new Slice(new Axis("flux", "J"), new Long(2)));
                            c.observable.independent = new Slice(new Axis("wavelength", "nm"), new Long(1));
                        }
                    }
                }
            }
            // txnManager.startTransaction();
            dao.put(ret1);
            // txnManager.commitTransaction();
            // this is so we can detect incorrect timestamp round trips
            // caused by assigning something other than what was stored
            Thread.sleep(2 * TIME_TOLERANCE);
            Observation ret2 = dao.get(orig.getURI());
            Assert.assertNotNull("found", ret2);
            log.info("testUpdateSimpleObservation/updated: ret1 vs ret2");
            testEqual(ret1, ret2);
            if (i > 1) {
                // test setting lastModified on observation when it is only force-updated for maxLastModified
                // the lastModified timestamps are maintained by the DAO, so lets set them to null here
                Util.assignLastModified(ret1, null, "lastModified");
                for (Plane p : ret1.getPlanes()) {
                    Util.assignLastModified(p, null, "lastModified");
                    for (Artifact a : p.getArtifacts()) {
                        Util.assignLastModified(a, null, "lastModified");
                        for (Part pa : a.getParts()) {
                            Util.assignLastModified(pa, null, "lastModified");
                            for (Chunk c : pa.getChunks()) Util.assignLastModified(c, null, "lastModified");
                        }
                    }
                }
                Plane pp = ret1.getPlanes().iterator().next();
                pp.calibrationLevel = CalibrationLevel.RAW_INSTRUMENTAL;
                // txnManager.startTransaction();
                dao.put(ret1);
                // txnManager.commitTransaction();
                // this is so we can detect incorrect timestamp round trips
                // caused by assigning something other than what was stored
                Thread.sleep(2 * TIME_TOLERANCE);
                Observation ret3 = dao.get(orig.getURI());
                Assert.assertNotNull("found", ret3);
                // make sure the DAO assigned lastModified values everywhere
                Assert.assertNotNull(ret1.getLastModified());
                for (Plane p : ret1.getPlanes()) {
                    Assert.assertNotNull(p.getLastModified());
                    for (Artifact a : p.getArtifacts()) {
                        Assert.assertNotNull(a.getLastModified());
                        for (Part pa : a.getParts()) {
                            Assert.assertNotNull(pa.getLastModified());
                            for (Chunk c : pa.getChunks()) Assert.assertNotNull(c.getLastModified());
                        }
                    }
                }
                log.info("testUpdateSimpleObservation/updated-timestamps: ret1 vs ret3");
                // this makes sure the lastModified values assigned in the put match the ones in the DB
                testEqual(ret1, ret3);
            }
            // txnManager.startTransaction();
            dao.delete(orig.getURI());
            // txnManager.commitTransaction();
            Observation deleted = dao.get(orig.getURI());
            Assert.assertNull("deleted", deleted);
        }
    } catch (Exception unexpected) {
        log.error("unexpected exception", unexpected);
        if (txnManager.isOpen())
            try {
                txnManager.rollbackTransaction();
            } catch (Throwable t) {
                log.error("failed to rollback transaction", t);
            }
        Assert.fail("unexpected exception: " + unexpected);
    }
}
Also used : Plane(ca.nrc.cadc.caom2.Plane) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) Chunk(ca.nrc.cadc.caom2.Chunk) Point(ca.nrc.cadc.caom2.types.Point) Artifact(ca.nrc.cadc.caom2.Artifact) SQLException(java.sql.SQLException) PreconditionFailedException(ca.nrc.cadc.net.PreconditionFailedException) Part(ca.nrc.cadc.caom2.Part) Slice(ca.nrc.cadc.caom2.wcs.Slice) DerivedObservation(ca.nrc.cadc.caom2.DerivedObservation) Observation(ca.nrc.cadc.caom2.Observation) DeletedObservation(ca.nrc.cadc.caom2.DeletedObservation) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) ObservableAxis(ca.nrc.cadc.caom2.wcs.ObservableAxis) CustomAxis(ca.nrc.cadc.caom2.CustomAxis) Axis(ca.nrc.cadc.caom2.wcs.Axis) Test(org.junit.Test)

Example 5 with Axis

use of ca.nrc.cadc.caom2.wcs.Axis in project caom2db by opencadc.

the class CaomRepoIntTests method testPutInvalidWCS.

@Test
public void testPutInvalidWCS() throws Throwable {
    String observationID = generateID("testPostInvalidWCS");
    SimpleObservation observation = new SimpleObservation(TEST_COLLECTION, observationID);
    Plane plane = new Plane("foo");
    observation.getPlanes().add(plane);
    // computation test looks at science artifacts; we want to test that complete WCS validation works
    plane.getArtifacts().add(new Artifact(new URI("ad:TEST/foo"), ProductType.SCIENCE, ReleaseType.DATA));
    Artifact invalid = new Artifact(new URI("ad:TEST/bar"), ProductType.AUXILIARY, ReleaseType.DATA);
    plane.getArtifacts().add(invalid);
    Part part = new Part(0);
    invalid.getParts().add(part);
    Chunk ch = new Chunk();
    part.getChunks().add(ch);
    ch.naxis = 1;
    ch.energyAxis = 1;
    ch.energy = new SpectralWCS(new CoordAxis1D(new Axis("FREQ", "Hz")), "TOPOCENT");
    // set delta to 0
    // 100MHz
    ch.energy.getAxis().function = new CoordFunction1D(10L, 0.0, new RefCoord(0.5, 100.0e6));
    observation.getPlanes().add(plane);
    putObservation(observation, subject1, 400, "invalid input: ", null);
}
Also used : CoordAxis1D(ca.nrc.cadc.caom2.wcs.CoordAxis1D) SpectralWCS(ca.nrc.cadc.caom2.wcs.SpectralWCS) Plane(ca.nrc.cadc.caom2.Plane) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Part(ca.nrc.cadc.caom2.Part) RefCoord(ca.nrc.cadc.caom2.wcs.RefCoord) Chunk(ca.nrc.cadc.caom2.Chunk) CoordFunction1D(ca.nrc.cadc.caom2.wcs.CoordFunction1D) URI(java.net.URI) Artifact(ca.nrc.cadc.caom2.Artifact) Axis(ca.nrc.cadc.caom2.wcs.Axis) Test(org.junit.Test)

Aggregations

Axis (ca.nrc.cadc.caom2.wcs.Axis)12 Chunk (ca.nrc.cadc.caom2.Chunk)11 RefCoord (ca.nrc.cadc.caom2.wcs.RefCoord)10 CustomAxis (ca.nrc.cadc.caom2.CustomAxis)8 CoordAxis1D (ca.nrc.cadc.caom2.wcs.CoordAxis1D)8 ObservableAxis (ca.nrc.cadc.caom2.wcs.ObservableAxis)8 CoordFunction1D (ca.nrc.cadc.caom2.wcs.CoordFunction1D)7 Artifact (ca.nrc.cadc.caom2.Artifact)5 Part (ca.nrc.cadc.caom2.Part)5 Plane (ca.nrc.cadc.caom2.Plane)5 SimpleObservation (ca.nrc.cadc.caom2.SimpleObservation)5 SpectralWCS (ca.nrc.cadc.caom2.wcs.SpectralWCS)5 Test (org.junit.Test)5 URI (java.net.URI)4 CoordBounds1D (ca.nrc.cadc.caom2.wcs.CoordBounds1D)3 CoordRange1D (ca.nrc.cadc.caom2.wcs.CoordRange1D)3 Coord2D (ca.nrc.cadc.caom2.wcs.Coord2D)2 CoordAxis2D (ca.nrc.cadc.caom2.wcs.CoordAxis2D)2 Slice (ca.nrc.cadc.caom2.wcs.Slice)2 SpatialWCS (ca.nrc.cadc.caom2.wcs.SpatialWCS)2