Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
orm_example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
odmc
orm_example
Commits
2c5829f1
Commit
2c5829f1
authored
6 years ago
by
Marco Frailis
Browse files
Options
Downloads
Patches
Plain Diff
Updating jupyter notebook
parent
64ac7193
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
imagedb_objects.ipynb
+0
-207
0 additions, 207 deletions
imagedb_objects.ipynb
with
0 additions
and
207 deletions
imagedb_objects.ipynb
+
0
−
207
View file @
2c5829f1
...
...
@@ -114,213 +114,6 @@
"source": [
"d = NispDetector(detectorId = \"11\", gain = 1.0, readoutNoise = 0.0, rawFrame = image)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"it = image.imageType\n",
"repr(it)\n",
"it.to_dict()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from imagedb.serializers import NispRawFrameSerializer\n",
"\n",
"s = NispRawFrameSerializer()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"OrderedDict([('id', IntegerField(label='ID', read_only=True)),\n",
" ('detectors', NispDetectorSerializer(many=True, read_only=True):\n",
" id = IntegerField(label='ID', read_only=True)\n",
" 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')\n",
" gain = FloatField()\n",
" readoutNoise = FloatField(label='ReadoutNoise')),\n",
" ('exposureTime', FloatField(label='ExposureTime')),\n",
" ('imgNumber', IntegerField(label='ImgNumber')),\n",
" ('naxis1', IntegerField()),\n",
" ('naxis2', IntegerField()),\n",
" ('imageType_category',\n",
" ChoiceField(choices=[('SCIENCE', 'SCIENCE'), ('CALIBRATION', 'CALIBRATION'), ('SIMULATION', 'SIMULATION')], label='ImageType category')),\n",
" ('imageType_firstType',\n",
" ChoiceField(choices=[('OBJECT', 'OBJECT'), ('STD', 'STD'), ('BIAS', 'BIAS'), ('DARK', 'DARK'), ('FLAT', 'FLAT'), ('LINEARITY', 'LINEARITY'), ('OTHER', 'OTHER')], label='ImageType firstType')),\n",
" ('imageType_secondType',\n",
" ChoiceField(choices=[('SKY', 'SKY'), ('LAMP', 'LAMP'), ('DOME', 'DOME'), ('OTHER', 'OTHER')], label='ImageType secondType')),\n",
" ('observationDateTime',\n",
" DateTimeField(label='ObservationDateTime')),\n",
" ('commandedPointing_rightAscension',\n",
" FloatField(label='CommandedPointing rightAscension')),\n",
" ('commandedPointing_declination',\n",
" FloatField(label='CommandedPointing declination')),\n",
" ('commandedPointing_pointingAngle',\n",
" FloatField(label='CommandedPointing pointingAngle')),\n",
" ('filterWheelPosition',\n",
" ChoiceField(choices=[('Y', 'Y'), ('J', 'J'), ('H', 'H'), ('OPEN', 'OPEN'), ('CLOSE', 'CLOSE')], label='FilterWheelPosition')),\n",
" ('grismWheelPosition',\n",
" ChoiceField(choices=[('BLUE0', 'BLUE0'), ('RED0', 'RED0'), ('RED90', 'RED90'), ('RED180OPENCLOSE', 'RED180OPENCLOSE')], label='GrismWheelPosition')),\n",
" ('instrument', NestedSerializer(read_only=True):\n",
" id = IntegerField(label='ID', read_only=True)\n",
" instrumentName = CharField(label='InstrumentName', max_length=100)\n",
" telescopeName = CharField(label='TelescopeName', max_length=100))])"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s.get_fields()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"from composite_field.rest_framework_support import CompositeFieldSerializer\n",
"\n",
"c = CompositeFieldSerializer()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'category': 'SCIENCE', 'firstType': 'OBJECT', 'secondType': 'STD'}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.to_representation(it)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"m = NispRawFrameSerializer.Meta.model"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"m._meta.concrete_model._meta.fields[15].serialize"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"imagedb.models.Pointing"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(p)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"from composite_field import CompositeField"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isinstance(p, CompositeField)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
...
...
%% 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
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment