Loading imagedb_objects.ipynb +0 −131 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python from imagedb.models import Instrument instrument = Instrument.objects.get(instrumentName='NISP') ``` %% Cell type:code id: tags: ``` python print(instrument.instrumentName) ``` %% Output NISP %% Cell type:code id: tags: ``` python from imagedb.models import ImageType, Pointing, NispDetector, NispRawFrame from datetime import datetime image = NispRawFrame(exposureTime = 105, imgNumber = 16, naxis1 = 2040, naxis2 = 2040, imageType = {'category':'SCIENCE', 'firstType':'OBJECT', 'secondType':'STD'}, observationDateTime = datetime.strptime("2025-06-21T18:27:23.000001", "%Y-%m-%dT%H:%M:%S.%f"), instrument = instrument, commandedPointing = {'rightAscension':8.48223045516, 'declination':8.48223045516, 'pointingAngle':64.8793517547}, filterWheelPosition = "Y", grismWheelPosition = "OPEN" ) ``` %% Cell type:code id: tags: ``` python image.commandedPointing ``` %% Output Pointing(rightAscension=8.48223045516, declination=8.48223045516, pointingAngle=64.8793517547) %% Cell type:code id: tags: ``` python image.commandedPointing.rightAscension ``` %% Output 8.48223045516 %% Cell type:code id: tags: ``` python image = NispRawFrame.objects.filter(commandedPointing_rightAscension__lte=8.48223045516)[0] ``` %% Cell type:code id: tags: ``` python d = NispDetector(detectorId = "11", gain = 1.0, readoutNoise = 0.0, rawFrame = image) ``` %% Cell type:code id: tags: ``` python it = image.imageType repr(it) it.to_dict() ``` %% Output {'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'} %% Cell type:code id: tags: ``` python from imagedb.serializers import NispRawFrameSerializer s = NispRawFrameSerializer() ``` %% Cell type:code id: tags: ``` python s.get_fields() ``` %% Output OrderedDict([('id', IntegerField(label='ID', read_only=True)), ('detectors', NispDetectorSerializer(many=True, read_only=True): id = IntegerField(label='ID', read_only=True) detectorId = ChoiceField(choices=[('11', '11'), ('12', '12'), ('13', '13'), ('14', '14'), ('21', '21'), ('22', '22'), ('23', '23'), ('24', '24'), ('31', '31'), ('32', '32'), ('33', '33'), ('34', '34'), ('41', '41'), ('42', '42'), ('43', '43'), ('44', '44')], label='DetectorId') gain = FloatField() readoutNoise = FloatField(label='ReadoutNoise')), ('exposureTime', FloatField(label='ExposureTime')), ('imgNumber', IntegerField(label='ImgNumber')), ('naxis1', IntegerField()), ('naxis2', IntegerField()), ('imageType_category', ChoiceField(choices=[('SCIENCE', 'SCIENCE'), ('CALIBRATION', 'CALIBRATION'), ('SIMULATION', 'SIMULATION')], label='ImageType category')), ('imageType_firstType', ChoiceField(choices=[('OBJECT', 'OBJECT'), ('STD', 'STD'), ('BIAS', 'BIAS'), ('DARK', 'DARK'), ('FLAT', 'FLAT'), ('LINEARITY', 'LINEARITY'), ('OTHER', 'OTHER')], label='ImageType firstType')), ('imageType_secondType', ChoiceField(choices=[('SKY', 'SKY'), ('LAMP', 'LAMP'), ('DOME', 'DOME'), ('OTHER', 'OTHER')], label='ImageType secondType')), ('observationDateTime', DateTimeField(label='ObservationDateTime')), ('commandedPointing_rightAscension', FloatField(label='CommandedPointing rightAscension')), ('commandedPointing_declination', FloatField(label='CommandedPointing declination')), ('commandedPointing_pointingAngle', FloatField(label='CommandedPointing pointingAngle')), ('filterWheelPosition', ChoiceField(choices=[('Y', 'Y'), ('J', 'J'), ('H', 'H'), ('OPEN', 'OPEN'), ('CLOSE', 'CLOSE')], label='FilterWheelPosition')), ('grismWheelPosition', ChoiceField(choices=[('BLUE0', 'BLUE0'), ('RED0', 'RED0'), ('RED90', 'RED90'), ('RED180OPENCLOSE', 'RED180OPENCLOSE')], label='GrismWheelPosition')), ('instrument', NestedSerializer(read_only=True): id = IntegerField(label='ID', read_only=True) instrumentName = CharField(label='InstrumentName', max_length=100) telescopeName = CharField(label='TelescopeName', max_length=100))]) %% Cell type:code id: tags: ``` python from composite_field.rest_framework_support import CompositeFieldSerializer c = CompositeFieldSerializer() ``` %% Cell type:code id: tags: ``` python c.to_representation(it) ``` %% Output {'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'} %% Cell type:code id: tags: ``` python m = NispRawFrameSerializer.Meta.model ``` %% Cell type:code id: tags: ``` python m._meta.concrete_model._meta.fields[15].serialize ``` %% Output False %% Cell type:code id: tags: ``` python type(p) ``` %% Output imagedb.models.Pointing %% Cell type:code id: tags: ``` python from composite_field import CompositeField ``` %% Cell type:code id: tags: ``` python isinstance(p, CompositeField) ``` %% Output True %% Cell type:code id: tags: ``` python ``` %% Cell type:code id: tags: ``` python ``` Loading
imagedb_objects.ipynb +0 −131 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python from imagedb.models import Instrument instrument = Instrument.objects.get(instrumentName='NISP') ``` %% Cell type:code id: tags: ``` python print(instrument.instrumentName) ``` %% Output NISP %% Cell type:code id: tags: ``` python from imagedb.models import ImageType, Pointing, NispDetector, NispRawFrame from datetime import datetime image = NispRawFrame(exposureTime = 105, imgNumber = 16, naxis1 = 2040, naxis2 = 2040, imageType = {'category':'SCIENCE', 'firstType':'OBJECT', 'secondType':'STD'}, observationDateTime = datetime.strptime("2025-06-21T18:27:23.000001", "%Y-%m-%dT%H:%M:%S.%f"), instrument = instrument, commandedPointing = {'rightAscension':8.48223045516, 'declination':8.48223045516, 'pointingAngle':64.8793517547}, filterWheelPosition = "Y", grismWheelPosition = "OPEN" ) ``` %% Cell type:code id: tags: ``` python image.commandedPointing ``` %% Output Pointing(rightAscension=8.48223045516, declination=8.48223045516, pointingAngle=64.8793517547) %% Cell type:code id: tags: ``` python image.commandedPointing.rightAscension ``` %% Output 8.48223045516 %% Cell type:code id: tags: ``` python image = NispRawFrame.objects.filter(commandedPointing_rightAscension__lte=8.48223045516)[0] ``` %% Cell type:code id: tags: ``` python d = NispDetector(detectorId = "11", gain = 1.0, readoutNoise = 0.0, rawFrame = image) ``` %% Cell type:code id: tags: ``` python it = image.imageType repr(it) it.to_dict() ``` %% Output {'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'} %% Cell type:code id: tags: ``` python from imagedb.serializers import NispRawFrameSerializer s = NispRawFrameSerializer() ``` %% Cell type:code id: tags: ``` python s.get_fields() ``` %% Output OrderedDict([('id', IntegerField(label='ID', read_only=True)), ('detectors', NispDetectorSerializer(many=True, read_only=True): id = IntegerField(label='ID', read_only=True) detectorId = ChoiceField(choices=[('11', '11'), ('12', '12'), ('13', '13'), ('14', '14'), ('21', '21'), ('22', '22'), ('23', '23'), ('24', '24'), ('31', '31'), ('32', '32'), ('33', '33'), ('34', '34'), ('41', '41'), ('42', '42'), ('43', '43'), ('44', '44')], label='DetectorId') gain = FloatField() readoutNoise = FloatField(label='ReadoutNoise')), ('exposureTime', FloatField(label='ExposureTime')), ('imgNumber', IntegerField(label='ImgNumber')), ('naxis1', IntegerField()), ('naxis2', IntegerField()), ('imageType_category', ChoiceField(choices=[('SCIENCE', 'SCIENCE'), ('CALIBRATION', 'CALIBRATION'), ('SIMULATION', 'SIMULATION')], label='ImageType category')), ('imageType_firstType', ChoiceField(choices=[('OBJECT', 'OBJECT'), ('STD', 'STD'), ('BIAS', 'BIAS'), ('DARK', 'DARK'), ('FLAT', 'FLAT'), ('LINEARITY', 'LINEARITY'), ('OTHER', 'OTHER')], label='ImageType firstType')), ('imageType_secondType', ChoiceField(choices=[('SKY', 'SKY'), ('LAMP', 'LAMP'), ('DOME', 'DOME'), ('OTHER', 'OTHER')], label='ImageType secondType')), ('observationDateTime', DateTimeField(label='ObservationDateTime')), ('commandedPointing_rightAscension', FloatField(label='CommandedPointing rightAscension')), ('commandedPointing_declination', FloatField(label='CommandedPointing declination')), ('commandedPointing_pointingAngle', FloatField(label='CommandedPointing pointingAngle')), ('filterWheelPosition', ChoiceField(choices=[('Y', 'Y'), ('J', 'J'), ('H', 'H'), ('OPEN', 'OPEN'), ('CLOSE', 'CLOSE')], label='FilterWheelPosition')), ('grismWheelPosition', ChoiceField(choices=[('BLUE0', 'BLUE0'), ('RED0', 'RED0'), ('RED90', 'RED90'), ('RED180OPENCLOSE', 'RED180OPENCLOSE')], label='GrismWheelPosition')), ('instrument', NestedSerializer(read_only=True): id = IntegerField(label='ID', read_only=True) instrumentName = CharField(label='InstrumentName', max_length=100) telescopeName = CharField(label='TelescopeName', max_length=100))]) %% Cell type:code id: tags: ``` python from composite_field.rest_framework_support import CompositeFieldSerializer c = CompositeFieldSerializer() ``` %% Cell type:code id: tags: ``` python c.to_representation(it) ``` %% Output {'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'} %% Cell type:code id: tags: ``` python m = NispRawFrameSerializer.Meta.model ``` %% Cell type:code id: tags: ``` python m._meta.concrete_model._meta.fields[15].serialize ``` %% Output False %% Cell type:code id: tags: ``` python type(p) ``` %% Output imagedb.models.Pointing %% Cell type:code id: tags: ``` python from composite_field import CompositeField ``` %% Cell type:code id: tags: ``` python isinstance(p, CompositeField) ``` %% Output True %% Cell type:code id: tags: ``` python ``` %% Cell type:code id: tags: ``` python ```