Skip to content

Commit 4d0e7df

Browse files
authoredSep 14, 2023
Fix aperture estimation, use local bkg from an annulus for aperture photometry, add the web interface to explore the end results (#16)
* now aperture photometry uses local annulus bkg, add util func to estimate appropriate apertures * remove model admin permissions from iop4admin * fix wrong attribute name, code style in .gitignore * keep everything in the same dir (`~/.iop4data`) by default, including tests * add portal to iop4site to explore the data * several bug fixes
1 parent 07dec72 commit 4d0e7df

38 files changed

+2045
-165
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ priv.*
1111
# other files
1212
**/static/iop4admin/js9
1313
**/migrations
14+
1415
# IDE files
1516
.vscode/
1617

‎docs/iop4lib.rst

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ iop4lib reference
6363
.. automodule:: iop4lib.utils.astrometry
6464
:members:
6565

66+
.. automodule:: iop4lib.utils.parallel
67+
:members:
68+
6669
iop4lib.telescopes
6770
==================
6871
Telescope specific code.

‎iop4admin/modeladmins/aperphotresult.py

+42-6
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717

1818
class AdminAperPhotResult(admin.ModelAdmin):
1919
model = AperPhotResult
20-
list_display = ['id', 'get_telescope', 'get_datetime', 'get_src_name', 'get_src_type', 'aperpix', 'get_reducedfit', 'get_obsmode', 'pairs', 'get_rotangle', 'get_src_type', 'flux_counts', 'flux_counts_err', 'bkg_flux_counts', 'bkg_flux_counts_err', 'modified']
20+
list_display = ['id', 'get_telescope', 'get_datetime', 'get_src_name', 'get_src_type', 'get_fwhm', 'get_aperpix', 'get_reducedfit', 'get_obsmode', 'pairs', 'get_rotangle', 'get_src_type', 'get_flux_counts', 'get_flux_counts_err', 'get_bkg_flux_counts', 'get_bkg_flux_counts_err', 'modified']
2121
readonly_fields = [field.name for field in AperPhotResult._meta.fields]
2222
search_fields = ['id', 'astrosource__name', 'astrosource__srctype', 'reducedfit__id']
2323
list_filter = ['astrosource__srctype', 'reducedfit__epoch__telescope', 'reducedfit__obsmode']
2424

25-
def has_module_permission(self, *args, **kwargs):
26-
return True
27-
28-
def has_view_permission(self, *args, **kwargs):
29-
return True
25+
3026

3127
@admin.display(description="TELESCOPE")
3228
def get_telescope(self, obj):
@@ -58,3 +54,43 @@ def get_obsmode(self, obj):
5854
def get_rotangle(self, obj):
5955
return obj.reducedfit.rotangle
6056

57+
@admin.display(description="fwhm")
58+
def get_fwhm(self, obj):
59+
if obj.fwhm is None:
60+
return "-"
61+
return f"{obj.fwhm:.1f}"
62+
63+
@admin.display(description="aperpix")
64+
def get_aperpix(self, obj):
65+
if obj.aperpix is None:
66+
return "-"
67+
return f"{obj.aperpix:.1f}"
68+
69+
@admin.display(description="flux_counts")
70+
def get_flux_counts(self, obj):
71+
if obj.flux_counts is None:
72+
return "-"
73+
else:
74+
return f"{obj.flux_counts:.1f}"
75+
76+
@admin.display(description="flux_counts_err")
77+
def get_flux_counts_err(self, obj):
78+
if obj.flux_counts_err is None:
79+
return "-"
80+
else:
81+
return f"{obj.flux_counts_err:.1f}"
82+
83+
@admin.display(description="bkg_flux_counts")
84+
def get_bkg_flux_counts(self, obj):
85+
if obj.bkg_flux_counts is None:
86+
return "-"
87+
else:
88+
return f"{obj.bkg_flux_counts:.1f}"
89+
90+
@admin.display(description="bkg_flux_counts_err")
91+
def get_bkg_flux_counts_err(self, obj):
92+
if obj.bkg_flux_counts_err is None:
93+
return "-"
94+
else:
95+
return f"{obj.bkg_flux_counts_err:.1f}"
96+

‎iop4admin/modeladmins/astrosource.py

-18
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,6 @@ class AdminAstroSource(admin.ModelAdmin):
2727
list_display = ['name', 'other_name', 'ra_hms', 'dec_dms', 'srctype', 'get_last_reducedfit', 'get_details']
2828
search_fields = ['name', 'other_name', 'ra_hms', 'dec_dms', 'srctype', 'comment']
2929
list_filter = ('srctype',)
30-
31-
def has_module_permission(self, *args, **kwargs):
32-
return True
33-
34-
def has_view_permission(self, *args, **kwargs):
35-
return True
36-
37-
# # by default exclude calibrators and non-polarized stars
38-
# def get_queryset(self, request):
39-
# # Get the original queryset
40-
# queryset = super().get_queryset(request)
41-
42-
# # Check if the filter is not already applied by checking if the 'is_active' key is not in the request's GET parameters
43-
# if 'srctype__exact' not in request.GET:
44-
# # Apply the default filter
45-
# queryset = queryset.exclude(srctype=SRCTYPES.CALIBRATOR).exclude(srctype=SRCTYPES.UNPOLARIZED_FIELD_STAR)
46-
47-
# return queryset
4830

4931
@admin.display(description='CALIBRATES')
5032
def get_calibrates(self, obj):

‎iop4admin/modeladmins/epoch.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ class AdminEpoch(admin.ModelAdmin):
1818
readonly_fields = [field.name for field in Epoch._meta.fields]
1919
ordering = ['-night','-telescope']
2020

21-
def has_module_permission(self, *args, **kwargs):
22-
return True
23-
24-
def has_add_permission(self, *args, **kwargs):
25-
return True
21+
2622

2723
@admin.display(description='Status')
2824
def status(self, obj):

‎iop4admin/modeladmins/masterbias.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ class AdminMasterBias(AdminFitFile):
1414
model = MasterBias
1515
list_display = ['id', 'telescope', 'night', 'imgsize', 'get_built_from', 'options']
1616

17-
def has_module_permission(self, *args, **kwargs):
18-
return True
19-
20-
def has_view_permission(self, *args, **kwargs):
21-
return True
17+
2218

2319
@admin.display(description='Options')
2420
def options(self, obj):

‎iop4admin/modeladmins/masterflat.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ class AdminMasterFlat(AdminFitFile):
1515
model = MasterFlat
1616
list_display = ['id', 'telescope', 'night', 'imgsize', 'band', 'obsmode', 'rotangle', 'exptime', 'masterbias', 'get_built_from', 'options']
1717

18-
def has_module_permission(self, *args, **kwargs):
19-
return True
20-
21-
def has_view_permission(self, *args, **kwargs):
22-
return True
18+
2319

2420
@admin.display(description='Options')
2521
def options(self, obj):

‎iop4admin/modeladmins/photopolresult.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ class AdminPhotoPolResult(admin.ModelAdmin):
2121
ordering = ['-juliandate']
2222
list_filter = ['astrosource__srctype', 'epoch__telescope', 'obsmode']
2323

24-
def has_module_permission(self, *args, **kwargs):
25-
return True
26-
27-
def has_view_permission(self, *args, **kwargs):
28-
return True
24+
2925

3026
@admin.display(description="TELESCOPE")
3127
def get_telescope(self, obj):

‎iop4admin/modeladmins/rawfit.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ class AdminRawFit(AdminFitFile):
3131
"imgsize",
3232
)
3333

34-
def has_module_permission(self, *args, **kwargs):
35-
return True
36-
37-
def has_view_permission(self, *args, **kwargs):
38-
return True
34+
3935

4036
def telescope(self, obj):
4137
return obj.epoch.telescope

‎iop4admin/modeladmins/reducedfit.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ class AdminReducedFit(AdminFitFile):
3434
"imgsize",
3535
)
3636

37-
def has_module_permission(self, *args, **kwargs):
38-
return True
39-
40-
def has_view_permission(self, *args, **kwargs):
41-
return True
37+
4238

4339
@admin.display(description='OPTIONS')
4440
def options(self, obj):

0 commit comments

Comments
 (0)
Please sign in to comment.