Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement reduction for DIPOL instrument #23

Merged
merged 168 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 167 commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
73664ae
refactor duplicated code
juanep97 Oct 10, 2023
04889bd
iop4.py: change print to logging info
juanep97 Oct 10, 2023
0967da4
enums.py: add DIPOL-1 instrument
juanep97 Oct 10, 2023
46048e9
telescope.py: classification of DIPOL fits
juanep97 Oct 10, 2023
0182fc3
iop4admin: site url now points to /iop4/
juanep97 Oct 10, 2023
eddf889
implement telescope kw check for DIPOL files
juanep97 Oct 11, 2023
ed648a7
remove unused code
juanep97 Oct 11, 2023
f11fc63
instrument-dependent gain, improve comment in source
juanep97 Oct 13, 2023
b8c099b
make_polarimetry_groups: account for instrument kw
juanep97 Oct 15, 2023
7bbc680
include tests for polarimetry groups (skipped atm)
juanep97 Oct 15, 2023
e218323
clean code, remove unused parts
juanep97 Oct 15, 2023
4a14907
add caha-t220 cafos tests
juanep97 Oct 15, 2023
c15dbf5
tests_cahat220.py: ci workaround with extra test
juanep97 Oct 15, 2023
6f5d717
test osnt090: add polarimetry check (not complete)
juanep97 Oct 15, 2023
05d76ed
iop4admin: allow filtering by instrument
juanep97 Oct 15, 2023
13f00ed
refactor instrument functionality in classes
juanep97 Oct 15, 2023
aff9c93
improve tests descriptions
juanep97 Oct 15, 2023
cee9479
iop4admin: improve browsability
juanep97 Oct 16, 2023
f23bf8b
tests: bump version, include polarimetry
juanep97 Oct 16, 2023
53e1361
iop4.py: add option to re-classify rawfits
juanep97 Oct 16, 2023
d4c36f1
instrument.py: add dipol to known instruments
juanep97 Oct 16, 2023
470ee02
dipol.py: add intrument_kw
juanep97 Oct 16, 2023
787cb39
dipol.py: improve classification
juanep97 Oct 16, 2023
41f0b71
ci.yml: fix command that was making tests fail
juanep97 Oct 16, 2023
e5aa216
iop4admin: show instrument in model admins
juanep97 Oct 16, 2023
4c257dc
iop4admin: fix bug
juanep97 Oct 16, 2023
9109b02
iop4admin: fix plot with only one pt
juanep97 Oct 16, 2023
b99c08d
dipol.py: continue on obsmode not implemented
juanep97 Oct 16, 2023
81f5cf2
ci.yml: try to keep cache httpdirfs to speed up CI
juanep97 Oct 16, 2023
1559a21
improve typehinting
juanep97 Oct 16, 2023
1398d7f
formatting
juanep97 Oct 16, 2023
163c746
type hinting
juanep97 Oct 16, 2023
d9b7bdc
set encoding to latin-1 in OSN ftp servers
juanep97 Oct 16, 2023
dd57009
add Telescope.list_remote_filelocs
juanep97 Oct 16, 2023
b096eb1
plot.py: tidy up a bit
juanep97 Oct 18, 2023
ebf8b47
config and telescopes: improve file name matching
juanep97 Oct 18, 2023
2ca3576
more changes for instrument class refactoring
juanep97 Oct 19, 2023
07f2536
dipol: classify obsmode, override header obj hint
juanep97 Oct 19, 2023
198dcfe
dipol: override build_wcs
juanep97 Oct 19, 2023
87e92e2
ci.yml: download test dataset specific version
juanep97 Oct 19, 2023
2e6d25c
ci.yml: typo
juanep97 Oct 19, 2023
7658788
ci.yml: attempt again caching astrometry files
juanep97 Oct 19, 2023
a8d4647
README.md: typo
juanep97 Oct 20, 2023
fab01fe
add support for darks and masterdarks frames
juanep97 Oct 20, 2023
fd763fd
ci.yml: fix typo
juanep97 Oct 20, 2023
313a039
ci.yml: comment caching index files bc not working
juanep97 Oct 20, 2023
11e5ef3
iop4admin: add filters to masters admins
juanep97 Oct 21, 2023
cbc5e44
instrument refactoring, dark frame support
juanep97 Oct 21, 2023
d71dd07
instrument.py: add docstrings
juanep97 Oct 21, 2023
e57a57d
iop4.py: fix bug
juanep97 Oct 22, 2023
76b2219
keep implementing darks
juanep97 Oct 22, 2023
44dccea
dipol.py: use full width masters in polarimetry
juanep97 Oct 22, 2023
97a80b1
iop4.py: improve cli
juanep97 Oct 22, 2023
6850e9d
andort150: fix instrument_kw
juanep97 Oct 22, 2023
f3831d6
customize iop4admin style, add debug warnings
juanep97 Oct 22, 2023
a363364
debug info only for logged users
juanep97 Oct 22, 2023
2858253
improve iop4 portal navigation
juanep97 Oct 22, 2023
54475d9
improve iop4 portal navigation
juanep97 Oct 22, 2023
18674a6
improve iop4 portal navigation
juanep97 Oct 22, 2023
66db9ab
iop4 portal fix header
juanep97 Oct 22, 2023
acb2d93
iop4.py: fix
juanep97 Oct 22, 2023
1df3f8e
epoch.py: improve exception msg
juanep97 Oct 22, 2023
7a5e3be
telescope.py: fix
juanep97 Oct 22, 2023
04019dd
move common ftp functionality to mixin class
juanep97 Oct 23, 2023
a97df45
fix flat classification case
juanep97 Oct 23, 2023
33ace47
fix debug msg position in iop4admin
juanep97 Oct 23, 2023
fa8f779
iop4admin: fix preview gui
juanep97 Oct 23, 2023
dacd9a7
astrometry: fix bug in border removal
juanep97 Oct 23, 2023
62a8742
dipol: fix get_header_objecthint
juanep97 Oct 24, 2023
ac3f707
dipol: fix get_astrometry_position_hint
juanep97 Oct 24, 2023
8c58ddf
dipol: fix has_pairs
juanep97 Oct 24, 2023
a1a9a19
dipol: fix get_header_hintcoord
juanep97 Oct 24, 2023
48b6c2a
epoch: do not stop build_masters if one margs fail
juanep97 Oct 24, 2023
f9b6109
plotting: imshow_w_sources add kwarg for r aper
juanep97 Oct 24, 2023
ce5f35b
sourcepairing.py: add d_min and d_max, x, y equivs
juanep97 Oct 24, 2023
c594369
astrometric calibration refactor, type hinting
juanep97 Oct 24, 2023
a7d02fc
astrometry, sourcepairing: add min, max, eps dists
juanep97 Oct 24, 2023
9fbbe89
dipol: custom shotgun parameters
juanep97 Oct 24, 2023
fa32332
improve Instrument and DIPOL build_wcs
juanep97 Oct 24, 2023
397112a
slightly improve fit detail view speed
juanep97 Oct 26, 2023
ecdb764
FitFileModel: add width and height properties
juanep97 Oct 26, 2023
654d18c
some renames
juanep97 Oct 26, 2023
c371949
AstroSource.get_sources_in_field: pass queryset
juanep97 Oct 27, 2023
fe5f23b
get_pairs_dxy: some args not required always
juanep97 Oct 27, 2023
3d90923
add get_simbad_sources and get_simbad_table
juanep97 Oct 27, 2023
2327839
Enable showing memory usage in logs
juanep97 Oct 27, 2023
4f6457e
improve docstrings
juanep97 Oct 27, 2023
b6358ca
reduction worker function fix
juanep97 Oct 27, 2023
e3487ba
add quad matching submodule
juanep97 Oct 29, 2023
de201be
add helper funcs to fit gaussians, and build wcs
juanep97 Oct 29, 2023
a0209ef
add dipol polarimetry astrocalibration with quads
juanep97 Oct 29, 2023
ca82447
add old method for dipol polarimetry astrocalib
juanep97 Oct 29, 2023
62f2787
dipol polarimetry: save astrometry extra info
juanep97 Oct 30, 2023
e218023
view_fitdetails: fix show astrometry_info
juanep97 Oct 30, 2023
0cf48e1
hash_juan: fix bug
juanep97 Oct 30, 2023
473159d
add find_linear_transformation
juanep97 Oct 30, 2023
312524b
fix DB row in the details view
juanep97 Oct 30, 2023
4a88dc5
iop4admin: fix link color
juanep97 Nov 1, 2023
f8f4ccf
iop4admin: show instrument in aperphotresults
juanep97 Nov 1, 2023
6b3000d
iop4admin: truncate astrometry_info values
juanep97 Nov 1, 2023
cf09c6b
iop4api plot: fix table
juanep97 Nov 1, 2023
bbd1380
iop4api plot: invert magnitude axes
juanep97 Nov 1, 2023
6ee0a57
iop4lib.utils: fix fit_gaussian
juanep97 Nov 1, 2023
c21f628
iop4lib.utils.plotting: fix
juanep97 Nov 1, 2023
10fb7d1
fix passing master files ReducedFit.create
juanep97 Nov 2, 2023
c6daf64
iop4api plot: fix table width
juanep97 Nov 3, 2023
cd85564
fix fit detail view flags
juanep97 Nov 3, 2023
951d95e
iop4admin: allow filtering epochs
juanep97 Nov 3, 2023
71042f7
fitfilemodel: remove unused log
juanep97 Nov 3, 2023
6650929
add DIPOL to iop4lib.instruments
juanep97 Nov 3, 2023
0431799
move estimate_common_apertures to Instrument
juanep97 Nov 3, 2023
de04b91
fix different style for IOP4 admin
juanep97 Nov 3, 2023
71444ad
fix header in iop4admin site
juanep97 Nov 3, 2023
0a7a532
fix bug
juanep97 Nov 3, 2023
bfbd63c
fix Instrument.estimate_common_apertures for tests
juanep97 Nov 3, 2023
f1bc367
dipol: fix flipstat kw handling
juanep97 Nov 7, 2023
5b2453a
photopolresult: add juliandate min and max fields
juanep97 Nov 7, 2023
5e097c5
iop4api plot: fix table size
juanep97 Nov 7, 2023
6e50662
andor_cameras.py: typo in comment, unused import
juanep97 Nov 7, 2023
fcf4038
cafos.py: typo in comment, unused import
juanep97 Nov 7, 2023
231135f
refactor building of summary images for astrometry
juanep97 Nov 7, 2023
cef024b
instrument.py: rm useless message, unused import
juanep97 Nov 7, 2023
6c42aa6
sourcedetection.py
juanep97 Nov 7, 2023
f18b278
iop4.py fix
juanep97 Nov 7, 2023
4170ed2
improve dipol quad matching astrometry
juanep97 Nov 7, 2023
5e274c3
improve dipol astrometry procedure
juanep97 Nov 7, 2023
1588943
dipol: implement relative polarimetry
juanep97 Nov 7, 2023
3d41548
dipol: fix missing gain_e_adu
juanep97 Nov 7, 2023
e8477c4
masterflat: fix missing materdark field
juanep97 Nov 7, 2023
ec13599
add utility script to build test dataset
juanep97 Nov 7, 2023
e35803c
iop4admin: show flags in photopolsresult
juanep97 Nov 9, 2023
0eac04e
iop4api: add api endpoint to set flags
juanep97 Nov 9, 2023
9455e79
photopolresult: add flag field
juanep97 Nov 9, 2023
9794b1c
iop4api base.css fix plot layout
juanep97 Nov 9, 2023
15db431
iop4api: use a better colormap
juanep97 Nov 9, 2023
f0fc681
iop4api: fix plot legend css and layout
juanep97 Nov 9, 2023
7af3e3c
iop4api: add flag support to plot
juanep97 Nov 9, 2023
9538ede
iop4api: add flag support to plot gui
juanep97 Nov 9, 2023
74a4625
iop4api: plot, flag GUI, data and logs
juanep97 Nov 11, 2023
2476c46
photopolresult admin: single link to all redfs
juanep97 Nov 11, 2023
6097d62
make_polarimetry_groups: fix bug
juanep97 Nov 12, 2023
e4f92cd
dipol shotgun params: constraint absolute distance
juanep97 Nov 12, 2023
7f2449b
small changes in reduced fit admin
juanep97 Nov 12, 2023
5a56cd3
BuildWCSResult: add __bool__ method
juanep97 Nov 12, 2023
cc07b29
iop4: fix
juanep97 Nov 13, 2023
f780433
add dipol astrometric calibration to tests
juanep97 Nov 13, 2023
6107183
do not run tests in github CI
juanep97 Nov 13, 2023
9da32e8
sourcedetection: convolve_fft for larger kernels
juanep97 Nov 13, 2023
1e9c954
dipol: convolve star images before calibration
juanep97 Nov 13, 2023
45ec0f8
auto build finding chart
juanep97 Nov 14, 2023
579a950
improve dipol astro calibration
juanep97 Nov 14, 2023
c8c8185
fix
juanep97 Nov 14, 2023
26c2b1d
reduce first photometry, then polarimetry
juanep97 Nov 14, 2023
b284936
process epochs in reverse order
juanep97 Nov 15, 2023
aa52fcb
fix
juanep97 Nov 15, 2023
c13eece
fix order
juanep97 Nov 15, 2023
11ac974
configurable timeout for parallel.py
juanep97 Nov 15, 2023
e7b2fcb
clear results before recomputing for each epoch
juanep97 Nov 15, 2023
e681c2d
fix iop4
juanep97 Nov 15, 2023
bcb2ca8
fixed aperture for bl lacertae
juanep97 Nov 15, 2023
2a792bc
fix dipol uncerts
juanep97 Nov 15, 2023
118955e
Fix dipol uncertainties, again
juanep97 Nov 15, 2023
b424035
invoke GC explictly
juanep97 Nov 15, 2023
ececc11
attempt to run tests in CI
juanep97 Nov 15, 2023
6514343
dipol tests: more tests for astro calibration
juanep97 Nov 15, 2023
2eef18c
bump test dataset version
juanep97 Nov 15, 2023
1dc5add
increase astrometry timeout in default config
juanep97 Nov 15, 2023
3f3276c
rename hash function
juanep97 Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,18 @@ jobs:
- name: Download test data
env:
TEST_DATA_PASSWORD: ${{ secrets.test_data_password }}
run: wget --post-data "pass=$TEST_DATA_PASSWORD" 'https://vhega.iaa.es/iop4/iop4testdata.tar.gz' -O $HOME/iop4testdata.tar.gz
run: |
export TESTDATA_MD5SUM=`grep 'TESTDATA_MD5SUM' ./tests/conftest.py | awk -F"'" '{print $2}' | tr -d '\n'`
wget --post-data "pass=$TEST_DATA_PASSWORD" "https://vhega.iaa.es/iop4/iop4testdata.tar.gz?md5sum=$TESTDATA_MD5SUM" -O $HOME/iop4testdata.tar.gz

- name: Run tests (with -o log_cli=true -o log_cli_level=DEBUG to debug CI actions)
run: pytest -o log_cli=true -o log_cli_level=DEBUG -vxs tests
run: pytest -o log_cli=true -o log_cli_level=DEBUG -vxs tests/

- name: Output some info for debugging
- name: Output some info for debugging
# | true so erros in this step are ignored
run: |
du -sh $HOME/.cache/httpdirfs/

df -h || true
du -sh $HOME/.cache/httpdirfs/ || true



Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ To run the tests, first follow the previous steps to configure IOP4. At the mome
```
If it is the first time executing IOP4, the astrometry index files will be downloaded to `astrometry_cache_path` (see `config/config.example.yaml`). This will take some time and a few tens of GB, depending on the exact version.

**Warning**: in some macOS systems, the process [might hang up](https://github.com/juanep97/iop4/issues/14#issuecomment-1748465276). Execute `export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES` or add that line to you shell init script.
**Warning**: in some macOS systems, the process [might hang up](https://github.com/juanep97/iop4/issues/14#issuecomment-1748465276). Execute `export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES` or add that line to your shell init script.

## Usage

Expand Down
54 changes: 43 additions & 11 deletions config/config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,75 @@
# This is an example of the config file, copy it to config/config.yaml and edit it.
# IOP4LIB will attempt to use config/config.yaml if it exists, otherwise it will use this one.

# GENERAL
###############
### GENERAL ###
###############

datadir: ~/.iop4data/ # <str> Path to iop4data data folder.
set_rawdata_readonly: False # <bool> True / False (sets raw fits file to readonly when downloading them or creating a RawFit object).
db_path: ~/.iop4data/iop4.db # Path to iop4 sqlite database file.
astrometry_cache_path: ~/.astrometry_cache/ # <tr> Path to store the astromery index files.
max_concurrent_threads: 4 # <int> Number of threads / processes to use (e.g. 4).
astrometry_timeout: 20 # <int> Timeout in minutes for astrometry solving.

###################
### RAY CLUSTER ###
###################

# RAY CLUSTER
ray_use_cluster: False # <bool> True/False (use ray for parallelization), let it to false if you have not configured it.
ray_cluster_address: null # <str> Aaddress for the cluster, needs ssh keys for current user; e.g. 'user@address'.
ray_cluster_config: null # <str> Path to ray cluster config file, e.g. /path/to/iop4/priv.rayconfig.yaml'.
ray_db_path: null # <str> Path in ray cluster, e.g. '~/iop4data/iop4.db'.
ray_datadir: null # <str> Path in ray cluster, e.g. '~/iop4data/'.

# GRAPHICS
################
### GRAPHICS ###
################

mplt_default_dpi: 100 # <int> dpi for matplotlib (e.g. 100)

# LOGGING
###############
### LOGGING ###
###############

log_fname: ~/.iop4data/iop4.log # </path/to/iop4.log>
log_date_format: '%Y-%m-%d %H:%M:%S' # <log date format>
log_format: '%(asctime)s - %(name)s [%(filename)s:%(lineno)d] - %(levelname)s - %(message)s' # <log format>
log_format: '%(asctime)s - %(name)s [%(filename)s:%(lineno)d] - %(levelname)s - %(message)s' # <log format> You can also add '%(process)d (%(proc_memory)s)' to the format to show pid and memory usage per process.
log_level: 20 # <int>. Possible values are: 10 (DEBUG), 20 (INFO), 30 (WARNING), 40 (ERROR), 50 (CRITICAL).

# CAHA
############
### CAHA ###
############

caha_address: null # <caha ftp address>
caha_password: null # <your caha password>
caha_user: null # <your caha user>

# OSN
###########
### OSN ###
###########

osn_t090_address: null # <osn t090 ftp archive ip address>
osn_t090_user: null # <yourosnuser>
osn_t090_password: null # <yourosnpassword>

osn_t150_address: null # <osn t150 ftp archive ip address>
osn_t150_user: null # <yourosnuser>
osn_t150_password: null # <yourosnpassword>

# List of names to download from OSN.
# The names will be introduced in osn_fnames_patterns as 'name.*\.fi?ts?$' (see below).

osn_source_list_path: null # <path/to/osn/source/list>
osn_fnames_patterns: # List of regex patterns. Files matching any of these patterns will be downloaded from OSN. For example, (^BLLac.*\.fits?$) will match file names starting with BLLac and ending in .fit or .fits. You can include your initials here, if you want to download only your files and the observers include it in the file name, e.g. (.*mfz.*\.fits?$) for files containing mfz in the name could belong to Menganito Fulano Zutano.
- (^Flat.*\.fits?$)
- (^Bias.*\.fits?$)
# osn_download_all_then_check_owner: null # <str> Alternatively, for OSN, just download all files (^.*\.fits?$) and then remove those that contain this word in the OBSERVER keyword in the header (except for files that contain 'bias' or 'flat' in the name). Leave null for default behaviour.

# List of (case insentitive) regex patterns.
# Files matching any of these patterns will be downloaded from OSN.
# For example, (^BLLac.*\.fits?$) will match file names starting with BLLac
# and ending in .fit, .fits, or .fts. You can include your initials here,
# If you want to download only your files and the observers include it in the
# filename, e.g. (.*mfz.*\.fits?$) for files containing mfz in the name
# could belong to Menganito Fulano Zutano. The re.IGNORECASE flag will be passed.

osn_fnames_patterns:
- (^Flat.*\.fi?ts?$)
- (^Bias.*\.fi?ts?$)
4 changes: 4 additions & 0 deletions docs/citations.bib
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ @article{dipol:2020
pages = "A46",
}

@online{astropy:ccd_data_reduction_guide,
title = {CCD Data Reduction Guide},
url = {https://www.astropy.org/ccd-reduction-and-photometry-guide/},
}
10 changes: 7 additions & 3 deletions iop4admin/modeladmins/aperphotresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@

class AdminAperPhotResult(admin.ModelAdmin):
model = AperPhotResult
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']
list_display = ['id', 'get_telescope', 'get_instrument', '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']
readonly_fields = [field.name for field in AperPhotResult._meta.fields]
search_fields = ['id', 'astrosource__name', 'astrosource__srctype', 'reducedfit__id']
list_filter = ['astrosource__srctype', 'reducedfit__epoch__telescope', 'reducedfit__obsmode']
search_fields = ['id', 'reducedfit__instrument', 'astrosource__name', 'astrosource__srctype', 'reducedfit__id']
list_filter = ['reducedfit__instrument', 'astrosource__srctype', 'reducedfit__epoch__telescope', 'reducedfit__obsmode']



@admin.display(description="TELESCOPE")
def get_telescope(self, obj):
return obj.reducedfit.epoch.telescope

@admin.display(description="INSTRUMENT")
def get_instrument(self, obj):
return obj.reducedfit.instrument

@admin.display(description="DATETIME")
def get_datetime(self, obj):
return Time(obj.reducedfit.juliandate, format='jd').strftime('%Y-%m-%d %H:%M:%S')
Expand Down
1 change: 1 addition & 0 deletions iop4admin/modeladmins/epoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AdminEpoch(admin.ModelAdmin):
search_fields = ['id', 'telescope', 'night']
readonly_fields = [field.name for field in Epoch._meta.fields]
ordering = ['-night','-telescope']
list_filter = ['telescope', 'night']



Expand Down
16 changes: 16 additions & 0 deletions iop4admin/modeladmins/fitfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@

class AdminFitFile(admin.ModelAdmin):

@admin.display(description='TELESCOPE', ordering='epoch__telescope')
def telescope(self, obj):
return obj.epoch.telescope

@admin.display(description='NIGHT', ordering='epoch__night')
def night(self, obj):
return obj.epoch.night

@admin.display(description='FILENAME', ordering='filename')
def filename(self, obj):
return obj.filename

@admin.display(description='STATUS')
def status(self, obj):
return ", ".join(obj.flag_labels)

def get_urls(self):
urls = super().get_urls()
my_urls = [
Expand Down
12 changes: 11 additions & 1 deletion iop4admin/modeladmins/masterbias.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@
logger = logging.getLogger(__name__)

class AdminMasterBias(AdminFitFile):

model = MasterBias
list_display = ['id', 'telescope', 'night', 'imgsize', 'get_built_from', 'options']

list_display = ['id', 'telescope', 'night', 'instrument', 'imgsize', 'get_built_from', 'options']

list_filter = (
RawFitIdFilter,
RawFitTelescopeFilter,
RawFitNightFilter,
RawFitInstrumentFilter,
RawFitFlagFilter,
"imgsize",
)


@admin.display(description='Options')
def options(self, obj):
Expand Down
58 changes: 58 additions & 0 deletions iop4admin/modeladmins/masterdark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from django.contrib import admin

from django.utils.html import format_html
from django.urls import reverse
from django.utils.safestring import mark_safe

from iop4api.filters import *
from iop4api.models import *
from .fitfile import AdminFitFile

import logging
logger = logging.getLogger(__name__)

class AdminMasterDark(AdminFitFile):

model = MasterDark

list_display = ['id', 'telescope', 'night', 'instrument', 'imgsize', 'exptime', 'get_masterbias', 'get_built_from', 'options']

list_filter = (
RawFitIdFilter,
RawFitTelescopeFilter,
RawFitNightFilter,
RawFitInstrumentFilter,
RawFitFlagFilter,
"imgsize",
)

@admin.display(description='Options')
def options(self, obj):
url_details = reverse('iop4admin:iop4api_masterdark_details', args=[obj.id])
url_viewer= reverse('iop4admin:iop4api_masterdark_details', args=[obj.id])
return format_html(rf'<a href="{url_details}">details</a> / <a href="{url_viewer}">advanced viewer</a>')

@admin.display(description='Telescope')
def telescope(self, obj):
return obj.epoch.telescope

@admin.display(description='Night')
def night(self, obj):
return obj.epoch.night

@admin.display(description='MasterBias')
def get_masterbias(self, obj):
self.allow_tags = True
if obj.masterbias is None:
return "-"
url = reverse('iop4admin:%s_%s_changelist' % (MasterBias._meta.app_label, MasterBias._meta.model_name)) + f"?id={obj.masterbias.id}"
return mark_safe(rf'<a href="{url}">{obj.masterbias.id}</a>')

@admin.display(description="Built from")
def get_built_from(self, obj):
self.allow_tags = True
link_L = list()
for rawfit in obj.rawfits.all():
url = reverse('iop4admin:%s_%s_changelist' % (RawFit._meta.app_label, RawFit._meta.model_name)) + f"?id={rawfit.id}"
link_L.append(rf'<a href="{url}">{rawfit.id}</a>')
return mark_safe(", ".join(link_L))
20 changes: 19 additions & 1 deletion iop4admin/modeladmins/masterflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@
logger = logging.getLogger(__name__)

class AdminMasterFlat(AdminFitFile):

model = MasterFlat
list_display = ['id', 'telescope', 'night', 'imgsize', 'band', 'obsmode', 'rotangle', 'exptime', 'masterbias', 'get_built_from', 'options']

list_display = ['id', 'telescope', 'night', 'instrument', 'imgsize', 'band', 'obsmode', 'rotangle', 'exptime', 'get_masterbias', 'get_built_from', 'options']

list_filter = (
RawFitIdFilter,
RawFitTelescopeFilter,
RawFitNightFilter,
RawFitInstrumentFilter,
RawFitFlagFilter,
"imgsize",
)


@admin.display(description='Options')
Expand All @@ -31,6 +41,14 @@ def telescope(self, obj):
def night(self, obj):
return obj.epoch.night

@admin.display(description='MasterBias')
def get_masterbias(self, obj):
self.allow_tags = True
if obj.masterbias is None:
return "-"
url = reverse('iop4admin:%s_%s_changelist' % (MasterBias._meta.app_label, MasterBias._meta.model_name)) + f"?id={obj.masterbias.id}"
return mark_safe(rf'<a href="{url}">{obj.masterbias.id}</a>')

@admin.display(description="Built from")
def get_built_from(self, obj):
self.allow_tags = True
Expand Down
18 changes: 11 additions & 7 deletions iop4admin/modeladmins/photopolresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class AdminPhotoPolResult(admin.ModelAdmin):
model = PhotoPolResult
list_display = ['id', 'get_telescope', 'get_juliandate', 'get_datetime', 'get_src_name', 'get_src_type', 'get_reducedfits', 'obsmode', 'band', 'exptime', 'get_mag', 'get_mag_err', 'get_p', 'get_p_err', 'get_chi', 'get_chi_err', 'modified']
list_display = ['id', 'get_telescope', 'get_juliandate', 'get_datetime', 'get_src_name', 'get_src_type', 'get_reducedfits', 'obsmode', 'band', 'exptime', 'get_mag', 'get_mag_err', 'get_p', 'get_p_err', 'get_chi', 'get_chi_err', 'get_flags', 'modified']
readonly_fields = [field.name for field in PhotoPolResult._meta.fields]
search_fields = ['id', 'astrosource__name', 'astrosource__srctype', 'epoch__night']
ordering = ['-juliandate']
Expand All @@ -42,11 +42,11 @@ def get_src_type(self, obj):
@admin.display(description="ReducedFits")
def get_reducedfits(self, obj):
self.allow_tags = True
link_L = list()
for reducedfit in obj.reducedfits.all():
url = reverse('iop4admin:%s_%s_changelist' % (ReducedFit._meta.app_label, ReducedFit._meta.model_name)) + f"?id={reducedfit.id}"
link_L.append(rf'<a href="{url}">{reducedfit.id}</a>')
return mark_safe(", ".join(link_L))

ids_str_L = [str(reducedfit.id) for reducedfit in obj.reducedfits.all()]
a_href = reverse('iop4admin:%s_%s_changelist' % (ReducedFit._meta.app_label, ReducedFit._meta.model_name)) + "?id__in=%s" % ",".join(ids_str_L)
a_text = ", ".join(ids_str_L)
return mark_safe(f'<a href="{a_href}">{a_text}</a>')

@admin.display(description="JD")
def get_juliandate(self, obj):
Expand Down Expand Up @@ -74,4 +74,8 @@ def get_chi(self, obj):

@admin.display(description="CHIERR [º]", ordering='-chi_err')
def get_chi_err(self, obj):
return f"{obj.chi_err:.2f}" if obj.chi_err is not None else None
return f"{obj.chi_err:.2f}" if obj.chi_err is not None else None

@admin.display(description='Status')
def get_flags(self, obj):
return ", ".join(list(obj.flag_labels))
32 changes: 12 additions & 20 deletions iop4admin/modeladmins/rawfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class AdminRawFit(AdminFitFile):
model = RawFit
list_display = ["id", 'filename', 'telescope', 'night', 'status', 'imgtype', 'imgsize', 'band', 'obsmode', 'rotangle', 'exptime', 'options']
list_display = ["id", 'filename', 'telescope', 'night', 'instrument', 'status', 'imgtype', 'imgsize', 'band', 'obsmode', 'rotangle', 'exptime', 'options']
readonly_fields = [field.name for field in RawFit._meta.fields]
search_fields = ['id', 'filename', 'epoch__telescope', 'epoch__night']
ordering = ['-epoch__night','-epoch__telescope']
Expand All @@ -24,36 +24,28 @@ class AdminRawFit(AdminFitFile):
RawFitTelescopeFilter,
RawFitNightFilter,
RawFitFilenameFilter,
RawFitInstrumentFilter,
RawFitFlagFilter,
"imgtype",
"obsmode",
"band",
"imgsize",
)



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

def night(self, obj):
return obj.epoch.night

@admin.display(description='STATUS')
def status(self, obj):
return ", ".join(obj.flag_labels)

@admin.display(description='OPTIONS')
def options(self, obj):
if obj.imgtype == IMGTYPES.LIGHT:
html_src = str()

if obj.imgtype == IMGTYPES.LIGHT and hasattr(obj, "reduced"):
url_reduced = reverse('iop4admin:%s_%s_changelist' % (ReducedFit._meta.app_label, ReducedFit._meta.model_name)) + f"?id={obj.reduced.id}"
url_details = reverse('iop4admin:iop4api_rawfit_details', args=[obj.id])
url_viewer= reverse('iop4admin:iop4api_rawfit_viewer', args=[obj.id])
return format_html(rf'<a href="{url_reduced}">reduced</a> / <a href="{url_details}">details</a> / <a href="{url_viewer}">advanced viewer</a>')
else:
url_details = reverse('iop4admin:iop4api_rawfit_details', args=[obj.id])
url_viewer= reverse('iop4admin:iop4api_rawfit_viewer', args=[obj.id])
return format_html(rf'<a href="{url_details}">details</a> / <a href="{url_viewer}">advanced viewer</a>')
html_src += rf'<a href="{url_reduced}">reduced</a> / '

url_details = reverse('iop4admin:iop4api_rawfit_details', args=[obj.id])
url_viewer= reverse('iop4admin:iop4api_rawfit_viewer', args=[obj.id])
html_src += rf'<a href="{url_details}">details</a> / <a href="{url_viewer}">advanced viewer</a>'

return format_html(html_src)

def image_preview(self, obj, allow_tags=True):
url_img_preview = reverse('iop4admin:iop4api_rawfit_preview', args=[obj.id])
Expand Down
Loading
Loading