From 65ab5a17840f4fbbddb72d4be6536219775a0e21 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 9 Jun 2022 13:50:47 +0200 Subject: [PATCH 001/171] successfully merged changes from zodi branch --- commander3/config/config.ita_oneapi | 136 ++++++++++++++++++ .../tod_tools/commander_tod.py | 15 +- .../python/commander_tools/tod_tools/hfi.py | 51 ++++++- commander3/src/comm_tod_hfi_mod.f90 | 7 +- commander3/src/comm_tod_mapmaking_mod.f90 | 3 + commander3/src/comm_tod_pointing_mod.f90 | 2 +- commander3/todscripts/hfi/hfitohdf5.py | 58 ++++++-- 7 files changed, 252 insertions(+), 20 deletions(-) create mode 100644 commander3/config/config.ita_oneapi diff --git a/commander3/config/config.ita_oneapi b/commander3/config/config.ita_oneapi new file mode 100644 index 000000000..c7458ebef --- /dev/null +++ b/commander3/config/config.ita_oneapi @@ -0,0 +1,136 @@ +# Config file for a generic GCC based compile, +# Using the reference LAPACK/Blas and assuming +# both LAPACK and CFITSIO are in /usr/local. + + +# =============== Installation =================== + +# Final install location. This defaults to a +# subdirectory of the top-level directory called +# install_$COMMANDER. +#export INSTALL := /usr/local + + +# =============== System Tools =================== + +# The defaults should be fine for any normal +# GNU/Linux operating system... + +# Here you can override the make version to use +#export MAKE := gmake + +# How to make a tar.gz file +#export CTAR := tar czvf + +# The archive command +#export AR := ar + +# Archive options to create a library +#export ARFLAGS := crv + +# The ranlib command +#export RANLIB := ranlib + + +# ================= Compilers ==================== + +# Serial Fortran 90 compiler. Default is "f90". +export F90 := ifx + +# MPI Fortran 90 compiler. Default is "mpif90". +export MPF90 := mpiifort + +# MPI Fortran 77 compiler. Default is "mpif77". +export MPF77 := mpiifort + +# MPI C++ compiler. Default is "mpicxx". +export MPCC := mpiicc + + +# =========== Compiler Optimizations ============= +#main +# +#export F90FLAGS := -fpe0 -march=native -g -O2 -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -xHost +#export F90FLAGS := -g -O2 -traceback +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -prof-gen=srcpos -prof-dir=/mn/stornext/u3/hke/xsan/commander3/BP9/prof +export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel + +#debug +# +#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv + + +#export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv +#export F90FLAGS := -check bounds -CB -check format -check pointers -check uninit -check output_conversion -assume byterecl -traceback -heap-arrays 16384 -fpe0 -O0 -g -traceback -assume byterecl -heap-arrays 16384 -qopenmp +#export F90FLAGS := -check all -O0 -g -traceback -assume byterecl -heap-arrays 16384 -qopenmp -ftrapuv -debug all -diag-disable 406 + +# Fortran 77 compiler flags +export FFLAGS := -O2 + +# C compiler flags. +export CFLAGS := -O3 + +# Extra flags used for linking +export LDFLAGS := -qopt-matmul -lm -qopenmp -cxxlib -parallel -mkl #-prof-file prof.dat -prof-dir . -profile-functions -profile-loops=all + + +# ============== Language Mixing ================= + +export MPFCLIBS := -qopenmp + + +# ============== Fortran Features ================ + +# Set this variable to 1 if the fortran compiler +# produces module files with capitalization (*.MOD) +# instead of lowercase (*.mod). +#export FORTRAN_UPPER := 1 + +export LOCAL=../../build/install + +# =============== CFITSIO Linking ================ + +# The include and linking commands for cfitsio. +export CFITSIO_INCLUDE := +export CFITSIO_LINK := -L$(LOCAL)/lib -lcfitsio + +# =============== SHARP Linking ================ + +# The include and linking commands for cfitsio. +export SHARP_INCLUDE := +export SHARP_LINK := -L$(LOCAL)/lib/ -lsharp +#export SHARP_LINK := + + +# =============== LAPACK Linking ================= + +# The include and linking commands for LAPACK. +MKLPATH := $(MKLROOT) +export LAPACK_INCLUDE := +export LAPACK_LINK := -shared-intel -Wl,-rpath,$(MKLPATH)/lib/intel64 -L$(MKLPATH)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread + + + +# ================ Healpix linking ================ +#export HEALPIX := /mn/stornext/u3/hke/owl/local/src/dagsshealpix +export HEALPIX := $(LOCAL)/healpix +export HEALPIX_INCLUDE := -I$(HEALPIX)/include +export HEALPIX_LINK := -L$(HEALPIX)/lib -lhealpix +#export HEALPIX_INCLUDE := -I/usit/titan/u1/sigurdkn/local/include +#export HEALPIX_LINK := -L/usit/titan/u1/sigurdkn/local/lib -lhealpix +#export HEALPIX_INCLUDE := -I$(LOCAL)/include +#export HEALPIX_LINK := -L$(LOCAL)/lib -lhealpix +#export HEALPIX_INCLUDE := -I/usit/titan/u1/hke/local/src/Healpix_2.10/src/f90/mod +#export HEALPIX_LINK := -L/usit/titan/u1/hke/local/src/Healpix_2.10/src/f90/mod -lhealpix + + +# =============== HDF ============================ +#export LOCAL=/mn/stornext/u3/hke/owl/local +export HDF_LINK := -L$(LOCAL)/lib/shared -lhdf5_fortran -lhdf5 -lhdf5_f90cstub +export HDF_LINK_CPP := -L$(LOCAL)/lib -lhdf5_cpp -lhdf5 +export HDF_INCLUDE := -I$(LOCAL)/include/shared + +# =============== CAMB ============================ +export CAMB_LINK := -L$(LOCAL)/local/lib #-lcamb +export CAMB_INCLUDE := -I$(LOCAL)/mod + diff --git a/commander3/python/commander_tools/tod_tools/commander_tod.py b/commander3/python/commander_tools/tod_tools/commander_tod.py index 3bc7a7fff..013277d44 100644 --- a/commander3/python/commander_tools/tod_tools/commander_tod.py +++ b/commander3/python/commander_tools/tod_tools/commander_tod.py @@ -29,12 +29,12 @@ import sys class commander_tod: - - def __init__(self, outPath, name, version=None, dicts=None, overwrite=False): + + def __init__(self, outPath, experiment, version=None, dicts=None, overwrite=False): self.outPath = outPath self.filelists = dicts self.version = version - self.name = name + self.experiment = experiment #TODO: something with the version number self.overwrite = overwrite @@ -49,17 +49,14 @@ def init_file(self, freq, od, mode='r'): self.od = od self.freq = freq - if self.name.lower() == 'planck': + if self.name.lower() == 'lfi': sfreq = str(freq).zfill(3) else: sfreq = str(freq) if not self.od: - if not self.name: - self.outName = os.path.join(self.outPath, sfreq + '.h5') - else: - self.outName = os.path.join(self.outPath, self.name+ '_' + sfreq + '.h5') + self.outName = os.path.join(self.outPath, self.experiment+ '_' + sfreq + '.h5') else: - self.outName = os.path.join(self.outPath, self.name+ '_' + sfreq + '_' + str(od).zfill(6) + '.h5') + self.outName = os.path.join(self.outPath, self.experiment+ '_' + sfreq + '_' + str(od).zfill(6) + '.h5') self.exists = False diff --git a/commander3/python/commander_tools/tod_tools/hfi.py b/commander3/python/commander_tools/tod_tools/hfi.py index a3699745f..96b31ac7b 100644 --- a/commander3/python/commander_tools/tod_tools/hfi.py +++ b/commander3/python/commander_tools/tod_tools/hfi.py @@ -26,7 +26,6 @@ import healpy as hp import random import math - class hfi(object): freqs = [100, 143, 217, 353, 545, 857] @@ -100,6 +99,56 @@ def get_extra_flags(times, det, flags): outFlags[np.logical_and(times > entry[0],times < entry[1])] = 128 return outFlags + #computes the pre-differencing gains from the insturment calibration params + #at a given time + #heavily based on https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/preproc_modules/transf1_nodemod.py + + def compute_l1_gain(detector, time, hsk): + if(type(time) == np.int64): + time = np.array([time]) + params = hsk[detector.encode()] # python 3 + + # Fixed IMO params + GC_bc = params[b'GC_bc'] + F1_bc = params[b'F1_bc'] + HFI_REU_ETAL = params[b'HFI_REU_ETAL'] + REU_bc_offset = params[b'REU_bc_offset'] + + gamp = hfi.expand_hsk(hsk, params[b'gamp'], time) + nsamp = hfi.expand_hsk(hsk, params[b'nsamp'], time) + nblanck = hfi.expand_hsk(hsk, params[b'nblanck'], time) + + nsamp[nsamp == 0] = 45 + nsamp[nsamp == 1] = 40 + nsamp[nsamp == 2] = 36 + nsamp[nsamp == 3] = 45 + + #print(GC_bc, F1_bc, HFI_REU_ETAL, REU_bc_offset) + #print(gamp, nsamp, nblanck) + + return F1_bc * GC_bc[gamp] * (nsamp - nblanck).astype(np.float64)/GC_bc[HFI_REU_ETAL], (nsamp - nblanck).astype(np.float64) * REU_bc_offset + + #produces a housekeeping estimate at time(s) t + def expand_hsk(hsk, field, time): + grp, obj = field.split(b'/') + t, x = hsk[grp][obj] + + i0 = len(time) // 2 + + if time[i0] < 1e10: + # from nanoseconds to seconds + tt = t.astype(np.float64) * 1e-9 + elif time[i0] < 1e18: + # from nanoseconds to OBT ticks + tt = t.astype(np.float64) * 1e-9 * 2.**16. + else: + tt = t + + # interpolate + + ind = np.searchsorted(tt, time) + return x[ind - 1] + @staticmethod def instrument_filename(version): return 'HFI_instrument_v' + str(version) + '.h5' diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 0a78d61e4..73677c9f6 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -125,7 +125,7 @@ function constructor(cpar, id_abs, info, tod_type) constructor%correct_sl = .false. constructor%orb_4pi_beam = .false. constructor%symm_flags = .false. - constructor%chisq_threshold = 1000.d0 !20.d0 ! 9.d0 + constructor%chisq_threshold = 1500.d0 !20.d0 ! 9.d0 constructor%nmaps = info%nmaps constructor%ndet = num_tokens(cpar%ds_tod_dets(id_abs), "," ) constructor%ntime = 1 @@ -369,6 +369,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if end if + if(self%scans(i)%chunk_num == 25083) then + write(*,*) "gain:", self%scans(i)%d(1)%gain + write(*,*) sd%tod(1:1000, 1) + end if + ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index 4789b40e5..751cd168e 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -513,6 +513,9 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) rms%map(i, 1) = sqrt(A_inv)*scale do k = 1, tod%output_n_maps binmap%outmaps(k)%p%map(i, 1) = b_tot(k, 1, i)/A_inv*scale + if(i == 1234) then + write(*,*) "binmap", binmap%outmaps(k)%p%map(i, 1), b_tot(k, 1, i), A_inv, scale + end if end do end do diff --git a/commander3/src/comm_tod_pointing_mod.f90 b/commander3/src/comm_tod_pointing_mod.f90 index 589141079..4bcfcde7d 100644 --- a/commander3/src/comm_tod_pointing_mod.f90 +++ b/commander3/src/comm_tod_pointing_mod.f90 @@ -62,7 +62,7 @@ subroutine project_sky(tod, map, pix, psi, flag, pmask, scan_id, & & map(2,p,det) * tod%cos2psi(psi(i,det)) + & & map(3,p,det) * tod%sin2psi(psi(i,det)) else if (nmap == 1) then - s_sky(i,det) = map(1,p,det) ! HFI 545 thing + s_sky(i,det) = map(1,p,det) ! Unpolarized channel end if diff --git a/commander3/todscripts/hfi/hfitohdf5.py b/commander3/todscripts/hfi/hfitohdf5.py index eb61859ae..4be1608f6 100644 --- a/commander3/todscripts/hfi/hfitohdf5.py +++ b/commander3/todscripts/hfi/hfitohdf5.py @@ -36,6 +36,10 @@ import cProfile import glob from scipy.spatial.transform import Rotation as rot +import pickle +import codecs + +import matplotlib.pyplot as plt def main(): @@ -51,6 +55,9 @@ def main(): parser.add_argument('--extra-flags', type=str, action='store', help='path to extra flagging in txt file', default='/mn/stornext/d16/cmbco/bp/HFI/aux/hfi_bad_intervals_15s_elephants.txt') + #https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/preproc_modules/transf1_nodemod.py + parser.add_argument('--calib-params', type=str, action='store', help='hash dump of HFI housekeeping imo from npipe', default='/mn/stornext/d16/cmbco/bp/HFI/aux/hficalibparams.dat') + parser.add_argument('--out-dir', type=str, action='store', default=os.getcwd(), help='path to output data structure you want to generate') parser.add_argument('--num-procs', type=int, action='store', default=1, help='number of processes to use') @@ -101,7 +108,14 @@ def main(): def make_od(comm_tod, freq, od, args): try: - + + #load housekeeping imo from file + calibfile = open(args.calib_params, mode='r') + calibparams = calibfile.read() + calibfile.close() + calibparams = bytes(calibparams, encoding='utf-8') + hsk = pickle.loads(codecs.decode(bytes(calibparams), 'base64'), fix_imports=True, encoding='bytes') + nside = hfi.nsides[freq] comm_tod.init_file(freq, od, mode='w') @@ -281,16 +295,37 @@ def make_od(comm_tod, freq, od, args): r_total = r_boresight * r_det #convert to theta, phi, psi - angs = r_total.as_euler('zxz') # could also be 'ZXZ' if we are supposed to be using intrinsic rotations instead of extrinsic + angs = r_total.as_euler('ZYZ') # could also be 'ZXZ' if we are supposed to be using intrinsic rotations instead of extrinsic # idk what the difference is - theta_array = angs[:,0] - phi_array = angs[:,1] + phi_array = angs[:,0] + theta_array = angs[:,1] psi_array = angs[:,2] + + r = hp.rotator.Rotator(coord=['E', 'G'], deg=False) galTheta, galPhi = r(theta_array, phi_array) + pixels = hp.pixelfunc.ang2pix(nside, galTheta, galPhi) + if(pid == 25083): + + x = np.arange(0, 20000) + + theta_, phi_ = hp.pix2ang(nside, pixels) + + plt.plot(x, theta_[-20000:], label='theta') + plt.plot(x, phi_[-20000:], label='phi') + plt.plot(x, quat_x[-20000:], label='x') + plt.plot(x, quat_y[-20000:], label='y') + plt.plot(x, quat_z[-20000:], label='z') + plt.plot(x, quat_s[-20000:], label='s') + plt.legend(loc='best') + + plt.savefig('quat_test.pdf') + #sys.exit() + + if len(pixels > 0): #compute average outer product outAng = hfi.ring_outer_product(galTheta, galPhi) @@ -327,17 +362,23 @@ def make_od(comm_tod, freq, od, args): gainFile = fits.open(os.path.join(args.gains_dir, 'npipe5_gains_' + str(freq) + '.fits')) gain = gainFile[gainFile.index_of(str(freq) +'-' + det)].data[0][0] - + gain1, offset = hfi.compute_l1_gain(str(freq) + '-' + det, exFile[1].data['obt'][pid_start:pid_end], hsk) + + + #print(gain, gain1, offset, gain/gain1) + + gain = gain/gain1[0] + #make white noise sigma0 = rimo[1].data.field('net')[rimo_i][0] * math.sqrt(fsamp) #make f_knee #fknee = rimo[1].data.field('f_knee')[rimo_i][0] - fknee = 0.5 + fknee = 0.5 #make 1/f noise exponent #alpha = rimo[1].data.field('alpha')[rimo_i][0] - alpha = -1 + alpha = -1 #print(gain, sigma0, fknee, alpha) comm_tod.add_field(prefix + '/scalars', np.array([gain, sigma0, fknee, alpha]).flatten()) @@ -346,7 +387,8 @@ def make_od(comm_tod, freq, od, args): #make psd noise #make tod data - tod = exFile[exFile.index_of(str(freq)+'-' + det)].data.field('signal')[pid_start:pid_end] + tod = exFile[exFile.index_of(str(freq)+'-' + det)].data.field('signal')[pid_start:pid_end] - offset + #compArray = [hfi.todDtype, hfi.rice] compArray = [hfi.todDtype, hfi.huffTod] if(args.no_compress): From ddc21a5cfdc1c994da352f5d666a023d5f7d12c7 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 16 Jun 2022 16:39:58 +0200 Subject: [PATCH 002/171] new working version of HFI loop, maps still undifferenced --- .../parameter_files/defaults/HFI_tod.defaults | 2 +- .../defaults/bands/HFI/HFI_545_TOD.defaults | 1 + .../tod_tools/commander_tod.py | 2 +- commander3/src/comm_data_mod.f90 | 11 +++++---- commander3/src/comm_diffuse_comp_smod.f90 | 13 ++++++---- commander3/src/comm_huffman_mod.f90 | 2 +- commander3/src/comm_param_mod.f90 | 11 +++++++-- commander3/src/comm_tod_hfi_mod.f90 | 1 + commander3/src/comm_tod_mapmaking_mod.f90 | 4 ++-- commander3/src/comm_tod_mod.f90 | 24 +++++++++++++------ 10 files changed, 48 insertions(+), 23 deletions(-) diff --git a/commander3/parameter_files/defaults/HFI_tod.defaults b/commander3/parameter_files/defaults/HFI_tod.defaults index bd7074954..c6c3cbfb3 100644 --- a/commander3/parameter_files/defaults/HFI_tod.defaults +++ b/commander3/parameter_files/defaults/HFI_tod.defaults @@ -9,7 +9,7 @@ SAMPLE_SPECTRAL_INDICES = .true. SAMPLE_POWSPEC = .false. ENABLE_TOD_ANALYSIS = .true. -TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER = 10 +TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER = -1 TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER = 10 TOD_INCLUDE_ZODI = .false. FFTW3_MAGIC_NUMBERS = fft3_magic_numbers_230810.txt diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index cae2243a7..750c37c24 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -32,6 +32,7 @@ BAND_DEFAULT_GAIN&&& = 1. BAND_DEFAULT_BP_DELTA&&& = 0. BAND_DEFAULT_NOISEAMP&&& = 1. BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_LEVEL&&& = L1 BAND_TOD_TYPE&&& = HFI BAND_TOD_BP_INIT_PROP&&& = none diff --git a/commander3/python/commander_tools/tod_tools/commander_tod.py b/commander3/python/commander_tools/tod_tools/commander_tod.py index 013277d44..6a4811cfd 100644 --- a/commander3/python/commander_tools/tod_tools/commander_tod.py +++ b/commander3/python/commander_tools/tod_tools/commander_tod.py @@ -49,7 +49,7 @@ def init_file(self, freq, od, mode='r'): self.od = od self.freq = freq - if self.name.lower() == 'lfi': + if self.experiment.lower() == 'lfi': sfreq = str(freq).zfill(3) else: sfreq = str(freq) diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index a906dce34..6ee244876 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -251,20 +251,23 @@ subroutine initialize_data_mod(cpar, handle) allocate(data(n)%bp(0:data(n)%ndet)) do j = 1, data(n)%ndet if (j==1) then - data(n)%bp(j)%p => comm_bp(cpar, n, i, detlabel=data(n)%tod%label(j)) + data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=data(n)%tod%label(j)) else ! Check if bandpass already exists in detector list call read_bandpass(trim(cpar%datadir) // '/' // cpar%ds_bpfile(i), & & data(n)%tod%label(j), & - & 0.d0, & + & data(n)%bp(1)%p%threshold, & & n_dummy, & & nu_dummy, & & tau_dummy) do k=1, j - if (all(tau_dummy==data(n)%bp(k)%p%tau0)) then + if(size(tau_dummy)==size(data(n)%bp(k)%p%tau0)) then + if (all(tau_dummy==data(n)%bp(k)%p%tau0)) then data(n)%bp(j)%p => data(n)%bp(k)%p ! If bp exists, point to existing object exit - else if (k==j-1) then + end if + end if + if(k==j) then !if we got through the whole loop above data(n)%bp(j)%p => comm_bp(cpar, n, i, detlabel=data(n)%tod%label(j)) end if end do diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index bc839c0df..b382ba434 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -223,14 +223,17 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%F_null(i,j) = .false. else do k=1, j - if (all(data(i)%bp(k)%p%tau0==data(i)%bp(j)%p%tau0)) then + if(size(data(i)%bp(k)%p%tau0) == size(data(i)%bp(j)%p%tau0)) then + if (all(data(i)%bp(k)%p%tau0==data(i)%bp(j)%p%tau0)) then self%F(i,j)%p => self%F(i,k)%p self%F_null(i,j) = .false. exit - else if (k==j-1) then - self%F(i,j)%p => comm_map(info) - self%F_null(i,j) = .false. - end if + end if + end if + if (k==j) then !if we got through the whole loop above + self%F(i,j)%p => comm_map(info) + self%F_null(i,j) = .false. + end if end do end if end do diff --git a/commander3/src/comm_huffman_mod.f90 b/commander3/src/comm_huffman_mod.f90 index 9c23f023e..8e11e4280 100644 --- a/commander3/src/comm_huffman_mod.f90 +++ b/commander3/src/comm_huffman_mod.f90 @@ -77,7 +77,7 @@ subroutine huffman_decode2_int(hcode, x_in, x_out, imod) end if end do !call hcode%get_symbol(node, buf) - !x_out(k) = buf + !x_out(k) = buf x_out(k) = hcode%int_symbs(node) if (k > 1) x_out(k) = x_out(k-1) + x_out(k) if (present(imod)) x_out(k) = iand(x_out(k),imod) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 973c711e1..1772e17f5 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -2429,7 +2429,7 @@ subroutine validate_params(cpar) type(comm_params), intent(inout) :: cpar integer(i4b) :: i, j - character(len=512) :: datadir, chaindir + character(len=512) :: datadir, chaindir, filename, filename1 logical(lgt) :: exist datadir = trim(cpar%datadir) // '/' @@ -2506,7 +2506,14 @@ subroutine validate_params(cpar) call validate_file(trim(datadir)//trim(cpar%cs_mask(i))) if (trim(cpar%cs_indmask(i)) /= 'fullsky') & call validate_file(trim(datadir)//trim(cpar%cs_indmask(i))) - + if (trim(cpar%cs_mono_prior(i)) /= 'none') then + filename = get_token(cpar%cs_mono_prior(i), ":", 2) + filename1 = get_token(filename, ",", 1) + call validate_file(trim(datadir)//trim(filename1)) + end if + + + select case (trim(cpar%cs_type(i))) case ('power_law') if (trim(cpar%cs_input_ind(1,i)) /= 'default') & diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 73677c9f6..0e5c8e550 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -121,6 +121,7 @@ function constructor(cpar, id_abs, info, tod_type) ! Initialize instrument-specific parameters constructor%samprate_lowres = 1.d0 ! Lowres samprate in Hz constructor%nhorn = 1 + constructor%ndiode = 1 constructor%compressed_tod = .true. constructor%correct_sl = .false. constructor%orb_4pi_beam = .false. diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index 751cd168e..bbf561d61 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -512,7 +512,7 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) end if rms%map(i, 1) = sqrt(A_inv)*scale do k = 1, tod%output_n_maps - binmap%outmaps(k)%p%map(i, 1) = b_tot(k, 1, i)/A_inv*scale + binmap%outmaps(k)%p%map(i, 1) = b_tot(k, 1, i)*A_inv*scale if(i == 1234) then write(*,*) "binmap", binmap%outmaps(k)%p%map(i, 1), b_tot(k, 1, i), A_inv, scale end if @@ -934,4 +934,4 @@ subroutine run_bicgstab(tod, handle, bicg_sol, npix, nmaps, num_cg_iters, epsil, end subroutine run_bicgstab -end module comm_tod_mapmaking_mod \ No newline at end of file +end module comm_tod_mapmaking_mod diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 5e895ce8c..3136c12f6 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -821,9 +821,9 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio character(len=*), dimension(:), intent(in) :: detlabels character(len=*), dimension(:,:), intent(in) :: diode_names - integer(i4b) :: i,j,k,l, n, m, ext(1) + integer(i4b) :: i,j,k,l, n, m, ext(1), setsize(1) real(sp) :: nu - real(dp) :: scalars(4) + real(dp) :: scalars(4), time character(len=6) :: slabel character(len=128) :: field type(hdf_file) :: file @@ -859,8 +859,15 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio ! Read common scan data call read_hdf(file, slabel // "/common/vsun", self%v_sun, opt=.true.) - call read_hdf(file, slabel // "/common/time", self%t0) - ! HKE: LFI files should be regenerated with (x,y,z) info + + call get_size_hdf(file, slabel // "/common/time", setsize) + + if(setsize(1) == 3) then + call read_hdf(file, slabel // "/common/time", self%t0) + else + call read_hdf(file, slabel // "/common/time", time) + self%t0(2) = time + end if call read_hdf(file, slabel // "/common/satpos", self%satpos, opt=.true.) ! Read detector scans @@ -991,10 +998,11 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio if (tod%compressed_tod) then !!$ call read_alloc_hdf(file, slabel // "/common/todsymb", hsymb) !!$ call read_alloc_hdf(file, slabel // "/common/todtree", htree) - call read_alloc_hdf(file, slabel // "/common/huffsymb2", hsymb_sp) + !TODO: this needs to be generalized to work for both floats and ints + call read_alloc_hdf(file, slabel // "/common/huffsymb2", hsymb) call read_alloc_hdf(file, slabel // "/common/hufftree2", htree) - call hufmak_precomp_sp(hsymb_sp,htree,self%todkey) - deallocate(hsymb_sp, htree) + call hufmak_precomp_int(hsymb,htree,self%todkey) + deallocate(hsymb, htree) end if ! Read instrument-specific infomation @@ -2282,6 +2290,8 @@ subroutine decompress_tod(self, scan, det, tod) allocate(tod_int(size(tod))) + !write(*,*) self%scans(scan)%d(det)%label, self%scans(scan)%chunk_num, size(self%scans(scan)%d(det)%ztod) + call huffman_decode2_int(self%scans(scan)%todkey, self%scans(scan)%d(det)%ztod, tod_int) tod = real(tod_int, sp) From 91cebc0c66bce54c52f28db87272cb3d4a18e2f7 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 30 Jun 2022 17:24:58 +0200 Subject: [PATCH 003/171] demodulate hfi data, added new template cosmic ray class --- cmake/projects/commander3.cmake | 1 + .../components/dust/dust_HFI.defaults | 59 ++++++++++++++ commander3/src/Makefile | 8 +- commander3/src/comm_data_mod.f90 | 4 +- commander3/src/comm_diffuse_comp_smod.f90 | 4 +- commander3/src/comm_timing_mod.f90 | 7 ++ commander3/src/comm_tod_cray_mod.f90 | 77 +++++++++++++++++++ commander3/src/comm_tod_driver_mod.f90 | 1 + commander3/src/comm_tod_hfi_mod.f90 | 32 +++++++- commander3/src/comm_tod_mod.f90 | 14 +++- 10 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 commander3/parameter_files/defaults/components/dust/dust_HFI.defaults create mode 100644 commander3/src/comm_tod_cray_mod.f90 diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index dc289f475..18b6929f2 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -122,6 +122,7 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_status_mod.f90 ${COMMANDER3_SOURCE_DIR}/locate_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_conviqt_mod.f90 + ${COMMANDER3_SOURCE_DIR}/comm_tod_cray_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_map_mod.f90 ${COMMANDER3_SOURCE_DIR}/math_tools.f90 ${COMMANDER3_SOURCE_DIR}/comm_cr_mod.f90 diff --git a/commander3/parameter_files/defaults/components/dust/dust_HFI.defaults b/commander3/parameter_files/defaults/components/dust/dust_HFI.defaults new file mode 100644 index 000000000..cfdbb8507 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_HFI.defaults @@ -0,0 +1,59 @@ +# Thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBB +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .true. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 1024 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 3000 +COMP_LMIN_AMP&& = 0 +COMP_LMAX_AMP&& = 3000 +COMP_LMAX_IND&& = -1 # Use input map as is +COMP_OUTPUT_FWHM&& = 10 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_dust_beta_BP8_10deg_HKE.fits +COMP_CL_TYPE&& = gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 +COMP_DEFAULT_BETA&& = 1.56 1.68 1.55 +COMP_PRIOR_UNI_BETA_LOW&& = 0.4 +COMP_PRIOR_UNI_BETA_HIGH&& = 3.0 +COMP_PRIOR_GAUSS_BETA_MEAN&& = 1.56 +COMP_PRIOR_GAUSS_BETA_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 3 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_DEFAULT_T&& = 18. +COMP_PRIOR_UNI_T_LOW&& = 10. +COMP_PRIOR_UNI_T_HIGH&& = 35. +COMP_PRIOR_GAUSS_T_MEAN&& = 18.5 +COMP_PRIOR_GAUSS_T_RMS&& = 0. +COMP_T_SMOOTHING_SCALE&& = 0 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_INPUT_AMP_MAP&& = dust_c0001_k000008_n1024.fits +COMP_PRIOR_AMP_MAP&& = none +COMP_INPUT_BETA_MAP&& = dust_beta_c0001_k000008_n1024.fits +COMP_INPUT_T_MAP&& = dust_T_c0001_k000008_n1024.fits +COMP_BETA_NU_MIN&& = 20 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_T_NU_MIN&& = 150 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + diff --git a/commander3/src/Makefile b/commander3/src/Makefile index 5f09730b6..a641986f0 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -109,6 +109,7 @@ F90SOURCES=hashtbl.f90 \ comm_camb_mod.f90 \ comm_tod_adc_mod.f90 comm_tod_adc_smod.f90 \ comm_timing_mod.f90 \ + comm_tod_cray_mod.f90 \ commander.f90 all: commander @@ -153,6 +154,7 @@ comm_cmb_comp_mod.o : comm_param_mod.o comm_comp_mod.o comm_diffuse_comp comm_cmb_relquad_comp_mod.o : comm_param_mod.o comm_comp_mod.o comm_template_comp_mod.o comm_f_int_mod.o comm_f_int_0d_mod.o comm_data_mod.o comm_bp_utils.o comm_comp_mod.o : comm_param_mod.o comm_bp_utils.o comm_bp_mod.o comm_map_mod.o comm_cr_utils.o comm_data_mod.o comm_hdf_mod.o comm_conviqt_mod.o : sharp.o comm_map_mod.o comm_utils.o comm_shared_arr_mod.o comm_param_mod.o +comm_tod_cray_mod.o : comm_param_mod.o comm_cr_mod.o : comm_comp_mod.o comm_data_mod.o comm_param_mod.o comm_diffuse_comp_mod.o comm_ptsrc_comp_mod.o comm_template_comp_mod.o comm_cr_utils.o comm_cr_precond_mod.o math_tools.o comm_output_mod.o comm_cr_precond_mod.o : comm_utils.o comm_cr_utils.o : comm_utils.o @@ -195,7 +197,7 @@ comm_task_mod.o : comm_utils.o comm_template_comp_mod.o : math_tools.o comm_param_mod.o comm_comp_mod.o comm_f_int_mod.o comm_data_mod.o comm_hdf_mod.o comm_cr_utils.o comm_cr_precond_mod.o locate_mod.o spline_1d_mod.o comm_tod_adc_mod.o : math_tools.o spline_1d_mod.o comm_tod_mod.o comm_map_mod.o comm_param_mod.o invsamp_mod.o comm_hdf_mod.o comm_tod_bandpass_mod.o : comm_tod_mod.o comm_utils.o -comm_tod_driver_mod.o : comm_tod_mod.o comm_tod_gain_mod.o comm_tod_noise_mod.o comm_tod_pointing_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_simulations_mod.o comm_tod_mapmaking_mod.o comm_zodi_mod.o comm_shared_arr_mod.o +comm_tod_driver_mod.o : comm_tod_mod.o comm_tod_gain_mod.o comm_tod_noise_mod.o comm_tod_pointing_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_simulations_mod.o comm_tod_mapmaking_mod.o comm_zodi_mod.o comm_shared_arr_mod.o comm_tod_cray_mod.o comm_tod_gain_mod.o : comm_tod_mod.o comm_tod_noise_mod.o comm_utils.o comm_fft_mod.o math_tools.o comm_tod_gain_smod.o : comm_tod_gain_mod.o comm_tod_jump_mod.o : comm_utils.o @@ -205,7 +207,7 @@ comm_tod_lfi_smod.o : comm_tod_lfi_mod.o comm_tod_quiet_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o comm_conviqt_mod.o comm_huffman_mod.o comm_hdf_mod.o comm_fft_mod.o comm_shared_arr_mod.o spline_1d_mod.o comm_4d_map_mod.o comm_tod_driver_mod.o comm_utils.o comm_tod_quiet_smod.o : comm_tod_quiet_mod.o comm_tod_mapmaking_mod.o : comm_tod_mod.o comm_utils.o comm_shared_arr_mod.o comm_map_mod.o comm_param_mod.o -comm_tod_mod.o : comm_utils.o comm_param_mod.o comm_hdf_mod.o comm_map_mod.o comm_fft_mod.o comm_huffman_mod.o comm_conviqt_mod.o comm_zodi_mod.o comm_tod_orbdipole_mod.o comm_tod_noise_psd_mod.o +comm_tod_mod.o : comm_utils.o comm_param_mod.o comm_hdf_mod.o comm_map_mod.o comm_fft_mod.o comm_huffman_mod.o comm_conviqt_mod.o comm_zodi_mod.o comm_tod_orbdipole_mod.o comm_tod_noise_psd_mod.o comm_tod_cray_mod.o comm_tod_noise_mod.o : comm_tod_mod.o comm_utils.o comm_fft_mod.o invsamp_mod.o comm_tod_noise_psd_mod.o comm_tod_noise_psd_mod.o : comm_utils.o comm_tod_orbdipole_mod.o : comm_utils.o comm_defs.o comm_map_mod.o spline_1d_mod.o @@ -215,7 +217,7 @@ comm_tod_spider_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o com comm_tod_spider_smod.o : comm_tod_spider_mod.o comm_tod_wmap_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o comm_conviqt_mod.o comm_huffman_mod.o comm_hdf_mod.o comm_fft_mod.o spline_1d_mod.o comm_4d_map_mod.o comm_zodi_mod.o comm_tod_mapmaking_mod.o comm_tod_pointing_mod.o comm_tod_gain_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_driver_mod.o comm_utils.o comm_tod_dirbe_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o comm_conviqt_mod.o comm_huffman_mod.o comm_hdf_mod.o comm_fft_mod.o spline_1d_mod.o comm_4d_map_mod.o comm_zodi_mod.o comm_tod_mapmaking_mod.o comm_tod_pointing_mod.o comm_tod_gain_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_driver_mod.o comm_utils.o -comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_shared_arr_mod.o comm_conviqt_mod.o +comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_shared_arr_mod.o comm_conviqt_mod.o comm_tod_cray_mod.o comm_utils.o : comm_system_mod.o comm_defs.o sort_utils.o spline_1d_mod.o comm_mpi_mod.o comm_zodi_mod.o : comm_utils.o comm_param_mod.o invsamp_mod.o : spline_1d_mod.o diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 6ee244876..a7afb0d1c 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -260,14 +260,14 @@ subroutine initialize_data_mod(cpar, handle) & n_dummy, & & nu_dummy, & & tau_dummy) - do k=1, j + do k=1, j-1 if(size(tau_dummy)==size(data(n)%bp(k)%p%tau0)) then if (all(tau_dummy==data(n)%bp(k)%p%tau0)) then data(n)%bp(j)%p => data(n)%bp(k)%p ! If bp exists, point to existing object exit end if end if - if(k==j) then !if we got through the whole loop above + if(k==j-1) then !if we got through the whole loop above data(n)%bp(j)%p => comm_bp(cpar, n, i, detlabel=data(n)%tod%label(j)) end if end do diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index b382ba434..dd11b2b8c 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -222,7 +222,7 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%F(i,j)%p => comm_map(info) self%F_null(i,j) = .false. else - do k=1, j + do k=1, j-1 if(size(data(i)%bp(k)%p%tau0) == size(data(i)%bp(j)%p%tau0)) then if (all(data(i)%bp(k)%p%tau0==data(i)%bp(j)%p%tau0)) then self%F(i,j)%p => self%F(i,k)%p @@ -230,7 +230,7 @@ module subroutine initDiffuse(self, cpar, id, id_abs) exit end if end if - if (k==j) then !if we got through the whole loop above + if (k==j-1) then !if we got through the whole loop above self%F(i,j)%p => comm_map(info) self%F_null(i,j) = .false. end if diff --git a/commander3/src/comm_timing_mod.f90 b/commander3/src/comm_timing_mod.f90 index 33e83d3cd..5659fb874 100644 --- a/commander3/src/comm_timing_mod.f90 +++ b/commander3/src/comm_timing_mod.f90 @@ -211,6 +211,13 @@ subroutine comm_timer_dumpASCII(self, labels, filename) write(unit,*) write(unit,*) ' Channel = ', trim(labels(band)) write(unit,fmt='(a,f12.3,"h")') ' TOD initialization = ', t(b+TOD_INIT) + write(*,*) t(b+TOD_SL_PRE), self%numsamp, T(b+TOD_TOT) + + if(T(b+TOD_TOT) == 0.d0) then !if we never used timing mod + close(unit) + return + end if + write(unit,fmt='(a,f12.3,"h",f10.2,"%")') ' TOD sidelobe precomputation = ', t(b+TOD_SL_PRE) / self%numsamp, 100*t(b+TOD_SL_PRE)/T(b+TOD_TOT) write(unit,fmt='(a,f12.3,"h",f10.2,"%")') ' TOD sidelobe interpolation = ', t(b+TOD_SL_INT) / self%numsamp, 100*t(b+TOD_SL_INT)/T(b+TOD_TOT) write(unit,fmt='(a,f12.3,"h",f10.2,"%")') ' TOD sky-to-tod projection = ', t(b+TOD_PROJECT) / self%numsamp, 100*t(b+TOD_PROJECT)/T(b+TOD_TOT) diff --git a/commander3/src/comm_tod_cray_mod.f90 b/commander3/src/comm_tod_cray_mod.f90 new file mode 100644 index 000000000..2d70b037c --- /dev/null +++ b/commander3/src/comm_tod_cray_mod.f90 @@ -0,0 +1,77 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University +! of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ +module comm_tod_cray_mod + use comm_param_mod + implicit none + + private + public comm_cray, cray_ptr + + type :: comm_cray + real(dp), allocatable, dimension(:,:) :: templates + integer(i4b) :: ntemps + contains + procedure :: build_cray_templates + procedure :: fit_cray_amplitudes + end type comm_cray + + interface comm_cray + procedure constructor + end interface comm_cray + + type cray_ptr + class(comm_cray), pointer :: p => null() + end type cray_ptr + +contains + + ! Constructor + + function constructor(ntemps) + implicit none + integer(i4b), intent(in) :: ntemps + + + class(comm_cray), pointer :: constructor + + allocate(constructor) + + constructor%ntemps = ntemps + + end function constructor + + ! builds a set of templates for cosmic ray response from the TOD + subroutine build_cray_templates(self) + implicit none + class(comm_cray), intent(inout) :: self + + + end subroutine build_cray_templates + + ! fits the constructed templates to the cosmic rays in the timestreams + subroutine fit_cray_amplitudes(self) + implicit none + class(comm_cray), intent(inout) :: self + + end subroutine fit_cray_amplitudes + +end module comm_tod_cray_mod diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 3f237f5fb..a68864a01 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -8,6 +8,7 @@ module comm_tod_driver_mod use comm_tod_simulations_mod use comm_tod_mapmaking_mod use comm_zodi_mod + use comm_tod_cray_mod use comm_shared_arr_mod use omp_lib implicit none diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 0e5c8e550..873207cd4 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -109,12 +109,14 @@ function constructor(cpar, id_abs, info, tod_type) allocate(constructor%xi_n_P_rms(constructor%n_xi)) ! just so that it actually runs - constructor%xi_n_P_uni(2,:) = [0.010d0, 0.45d0] ! fknee + constructor%xi_n_P_uni(2,:) = [0.10d0, 1.0d0] ! fknee constructor%xi_n_P_uni(3,:) = [-2.5d0, -0.4d0] ! alpha constructor%xi_n_nu_fit = [0.d0, 1.225d0] ! I took it from freq=30 for LFI, so not true constructor%xi_n_P_rms = [-1.d0, 0.1d0, 0.2d0] ! [sigma0, fknee, alpha]; sigma0 is not used + constructor%n_cray_temps = 3 + ! Initialize common parameters call constructor%tod_constructor(cpar, id_abs, info, tod_type) @@ -130,8 +132,8 @@ function constructor(cpar, id_abs, info, tod_type) constructor%nmaps = info%nmaps constructor%ndet = num_tokens(cpar%ds_tod_dets(id_abs), "," ) constructor%ntime = 1 - constructor%HFI_flag = .true. constructor%partner = -1 + constructor%n_cray_temps = 3 nside_beam = 512 nmaps_beam = 3 @@ -323,7 +325,27 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m else call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if + allocate(s_buf(sd%ntod,sd%ndet)) + + ! demodulate the data + s_buf = sd%tod * (1 - (iand(sd%flag, self%flag0))) + do j=1, sd%ndet + if (.not. self%scans(i)%d(j)%accept) cycle + sd%tod(:,j) = sd%tod(:,j) - sum(s_buf(:,j))/sum((1 - (iand(sd%flag(:,j),self%flag0)))) + do k=1, sd%ntod + if (sd%tod(k,j) < 0.d0) then + sd%tod(k,j) = - sd%tod(k,j) + end if + end do + end do + + ! remove cosmic rays + do j=1, sd%ndet + call self%cray(j)%p%build_cray_templates() + call self%cray(j)%p%fit_cray_amplitudes() + end do + ! Calling Simulation Routine if (self%enable_tod_simulations) then @@ -370,10 +392,14 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if end if + open(123, file="todtest.txt") if(self%scans(i)%chunk_num == 25083) then write(*,*) "gain:", self%scans(i)%d(1)%gain - write(*,*) sd%tod(1:1000, 1) + do k=1, self%scans(i)%ntod + write(123,*) sd%tod(k, 1) + end do end if + close(123) ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 3136c12f6..c13f5d948 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -27,6 +27,7 @@ module comm_tod_mod use comm_huffman_mod use comm_conviqt_mod use comm_zodi_mod + use comm_tod_cray_mod use comm_tod_orbdipole_mod use comm_tod_noise_psd_mod USE ISO_C_BINDING @@ -109,7 +110,8 @@ module comm_tod_mod integer(i4b) :: flag0 integer(i4b) :: n_xi ! Number of noise parameters integer(i4b) :: ntime ! Number of time values - + integer(i4b) :: n_cray_temps ! number of classes of cosmic rays we have + real(dp) :: central_freq !Central frequency real(dp) :: samprate, samprate_lowres ! Sample rate in Hz real(dp) :: chisq_threshold ! Quality threshold in sigma @@ -118,7 +120,6 @@ module comm_tod_mod logical(lgt) :: apply_inst_corr logical(lgt) :: sample_abs_bp logical(lgt) :: symm_flags - logical(lgt) :: HFI_flag class(comm_orbdipole), pointer :: orb_dp real(dp), allocatable, dimension(:) :: gain0 ! Mean gain real(dp), allocatable, dimension(:) :: polang ! Detector polarization angle @@ -167,6 +168,7 @@ module comm_tod_mod class(comm_mapinfo), pointer :: slinfo => null() ! Sidelobe map info class(map_ptr), allocatable, dimension(:) :: slbeam, mbeam ! Sidelobe beam data (ndet) class(conviqt_ptr), allocatable, dimension(:) :: slconv ! SL-convolved maps (ndet) + class(cray_ptr), allocatable, dimension(:) :: cray ! cosmic ray templates real(dp), allocatable, dimension(:,:) :: bp_delta ! Bandpass parameters (0:ndet, npar) real(dp), allocatable, dimension(:,:) :: spinaxis ! For load balancing integer(i4b), allocatable, dimension(:) :: pix2ind, ind2pix, ind2sl @@ -433,6 +435,14 @@ subroutine tod_constructor(self, cpar, id_abs, info, tod_type) !allocate(self%orb_dp) !self%orb_dp => comm_orbdipole(self%mbeam) + ! Init cosmic ray template removal + if(self%n_cray_temps > 0) then + allocate(self%cray(self%ndet)) + do i = 1, self%ndet + self%cray(i)%p => comm_cray(self%n_cray_temps) + end do + end if + end subroutine tod_constructor subroutine precompute_lookups(self) From 79d9fa5dae5d381b4117bce21948022a6efd0228 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Fri, 5 Aug 2022 12:13:58 +0200 Subject: [PATCH 004/171] minor change to cray template class --- commander3/src/comm_tod_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index c13f5d948..19118a8dd 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -110,7 +110,7 @@ module comm_tod_mod integer(i4b) :: flag0 integer(i4b) :: n_xi ! Number of noise parameters integer(i4b) :: ntime ! Number of time values - integer(i4b) :: n_cray_temps ! number of classes of cosmic rays we have + integer(i4b) :: n_cray_temps = 0 ! number of classes of cosmic rays we have real(dp) :: central_freq !Central frequency real(dp) :: samprate, samprate_lowres ! Sample rate in Hz From 7c97e4e5bbf194134cdc8b665e7374064bfb8f00 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 19 Sep 2022 16:21:18 +0200 Subject: [PATCH 005/171] fixed issue with unsigned integer in flags --- .../commander_tools/tod_tools/commander_tod.py | 17 ++++++++++++++++- commander3/todscripts/hfi/hfitohdf5.py | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/commander3/python/commander_tools/tod_tools/commander_tod.py b/commander3/python/commander_tools/tod_tools/commander_tod.py index 6a4811cfd..147858990 100644 --- a/commander3/python/commander_tools/tod_tools/commander_tod.py +++ b/commander3/python/commander_tools/tod_tools/commander_tod.py @@ -152,10 +152,25 @@ def add_field(self, fieldName, data, compression=None): dictNum = compArr[1]['dictNum'] if dictNum not in self.huffDict.keys(): self.huffDict[dictNum] = {} + + #check for uint issue before differencing + #np.diff maintains data types so this was a mess for uints + if(np.issubdtype(data.dtype, np.unsignedinteger)): + dtypestr = str(data.dtype) + + dsize = int(dtypestr[4:]) + dsize *= 2 + dtypestr = 'int' + str(dsize) + #print("Converting unsigned Huffman field " + fieldName + " from " + str(data.dtype) + " to " + dtypestr) + data = data.astype(dtypestr) + delta = np.diff(data) delta = np.insert(delta, 0, data[0]) self.huffDict[dictNum][fieldName] = delta - #print("adding " + fieldName + " to dict, contents ", delta[delta != 0], data[data != 0]) + #if('flag' in fieldName): + # for i in range(len(data)): + # print(data[i], delta[i], ",", end='') + #print("adding " + fieldName + " to dict, contents ", delta[delta!=0]) self.add_attribute(fieldName, 'huffmanDictNumber', dictNum) writeField = False diff --git a/commander3/todscripts/hfi/hfitohdf5.py b/commander3/todscripts/hfi/hfitohdf5.py index 4be1608f6..c98d677f8 100644 --- a/commander3/todscripts/hfi/hfitohdf5.py +++ b/commander3/todscripts/hfi/hfitohdf5.py @@ -195,6 +195,7 @@ def make_od(comm_tod, freq, od, args): #per pid for dbentry in c.execute("SELECT * FROM ring_times_hfi WHERE stop_time >= '{0}' AND start_time < '{1}'".format(starttime, endtime)): pid = dbentry[0] + start_time = dbentry[2] end_time = dbentry[3] @@ -269,7 +270,10 @@ def make_od(comm_tod, freq, od, args): if(det == '353-1'): ex_flags = extraFlagsFile[str(pid).zfill(6) + '/flags_extra_353-1'] flagArray += ex_flags - + + #with np.printoptions(threshold=np.inf): + # print(flagArray) + if (len(flagArray) > 0): comm_tod.add_field(prefix + '/flag', flagArray, compArr) From 3a169b19d73adfbdc35872e8c861ab7705a7060a Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Wed, 21 Sep 2022 13:04:33 +0200 Subject: [PATCH 006/171] removed correlated noise sampling --- commander3/src/comm_tod_hfi_mod.f90 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 873207cd4..d3d1c56f1 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -355,22 +355,24 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if ! Sample correlated noise - call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) + !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) + + sd%n_corr = 0.d0 ! Compute noise spectrum parameters - call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + !call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) ! Compute chisquare do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle - call self%compute_chisq(i, j, sd%mask(:,j), sd%s_sky(:,j), sd%s_sl(:,j) + sd%s_orb(:,j), sd%n_corr(:,j), tod=sd%tod(:, j)) + !call self%compute_chisq(i, j, sd%mask(:,j), sd%s_sky(:,j), sd%s_sl(:,j) + sd%s_orb(:,j), sd%n_corr(:,j), tod=sd%tod(:, j)) end do ! Select data - if (select_data) call remove_bad_data(self, i, sd%flag) + !if (select_data) call remove_bad_data(self, i, sd%flag) ! Compute chisquare for bandpass fit - if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) + !if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) ! Compute binned map allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) From 7a7cdcb98134dcdb97f4cbd9efbd7db18a8139cf Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 4 Nov 2022 13:11:33 +0100 Subject: [PATCH 007/171] Fixed HFI bandpass bug --- .../defaults/bands/HFI/HFI_545_TOD.defaults | 12 ++++++------ .../tod_tools/commander_instrument.py | 9 +++++++++ commander3/src/comm_tod_hfi_mod.f90 | 16 ++++++++-------- commander3/todscripts/hfi/hfiinstrument.py | 6 ++++-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index 750c37c24..18139ac9b 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -5,7 +5,7 @@ BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 BAND_LMAX&&& = 4000 -BAND_UNIT&&& = uK_cmb +BAND_UNIT&&& = K_cmb BAND_NOISE_FORMAT&&& = rms BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 1 BAND_MASKFILE&&& = fullsky @@ -15,11 +15,11 @@ BAND_BEAM_B_L_FILE&&& = Bl_npipe6v19_545GHzx545GHz.fits BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. -BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 545 BAND_SAMP_BANDPASS&&& = .false. -BAND_BANDPASSFILE&&& = HFI_instrument_v1.h5 +BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. BAND_GAIN_PRIOR_RMS&&& = 0.1 @@ -39,7 +39,7 @@ BAND_TOD_BP_INIT_PROP&&& = none BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 3 BAND_TOD_END_SCANID&&& = 53724 -BAND_TOD_TOT_NUMSCAN&&& = 53721 +BAND_TOD_TOT_NUMSCAN&&& = 53724 BAND_TOD_FLAG&&& = 0 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 @@ -52,10 +52,10 @@ BAND_REG_NOISEFILE&&& = npipe6v20_545_wcov.fits BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_545_wcov.fits BAND_NOISE_RMS&&&_SMOOTH02 = npipe6v20_545_wcov.fits BAND_NOISE_RMS&&&_SMOOTH03 = npipe6v20_545_wcov.fits -BAND_BANDPASSFILE&&& = HFI_instrument_v1.h5 +BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits -BAND_TOD_RIMO&&& = HFI_instrument_v1.h5 +BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 BAND_TOD_FILELIST&&& = filelist_545_v1.txt diff --git a/commander3/python/commander_tools/tod_tools/commander_instrument.py b/commander3/python/commander_tools/tod_tools/commander_instrument.py index eae57f08f..454a1d608 100644 --- a/commander3/python/commander_tools/tod_tools/commander_instrument.py +++ b/commander3/python/commander_tools/tod_tools/commander_instrument.py @@ -60,6 +60,15 @@ def add_bandpass(self, det, freqs, response): self.add_field(det + '/bandpassx', freqs) self.add_field(det + '/bandpass', response) + + #add bandpass data for detector det + def add_hfi_bandpass(self, det, freqs, response): + if len(freqs) != len(response): + raise ValueError('Bandpass frequency x and f(x) must be the same length, len(freqs): ' + str(len(freqs)) + ' len(f(x)): ' + str(len(response))) + det = self.parse_det(det) + + self.add_field(det + '/bandpassx', freqs * 1e-7 * 299792458.) + self.add_field(det + '/bandpass', response) def add_alms(self, det, almType, lmax, mmax, T, E, B): diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 873207cd4..f4efbe534 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -392,14 +392,14 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if end if - open(123, file="todtest.txt") - if(self%scans(i)%chunk_num == 25083) then - write(*,*) "gain:", self%scans(i)%d(1)%gain - do k=1, self%scans(i)%ntod - write(123,*) sd%tod(k, 1) - end do - end if - close(123) +!!$ open(123, file="todtest.txt") +!!$ if(self%scans(i)%chunk_num == 25083) then +!!$ write(*,*) "gain:", self%scans(i)%d(1)%gain +!!$ do k=1, self%scans(i)%ntod +!!$ write(123,*) sd%tod(k, 1) +!!$ end do +!!$ end if +!!$ close(123) ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) diff --git a/commander3/todscripts/hfi/hfiinstrument.py b/commander3/todscripts/hfi/hfiinstrument.py index 59e3fce77..d160d3541 100644 --- a/commander3/todscripts/hfi/hfiinstrument.py +++ b/commander3/todscripts/hfi/hfiinstrument.py @@ -25,7 +25,9 @@ import numpy as np import math import argparse +import sys from astropy.io import fits +sys.path.insert(0, "/mn/stornext/u3/hke/git/Commander_hfi/commander3/python") from commander_tools.tod_tools.hfi import hfi from commander_tools.tod_tools.lfi import lfi from commander_tools.tod_tools import commander_instrument as inst @@ -52,12 +54,12 @@ def main(): for freq in hfi.freqs: bandNo = rimo.index_of('BANDPASS_F' + str(freq)) - inst_file.add_bandpass(freq, rimo[bandNo].data.field('WAVENUMBER'), rimo[bandNo].data.field('TRANSMISSION')) + inst_file.add_hfi_bandpass(freq, rimo[bandNo].data.field('WAVENUMBER'), rimo[bandNo].data.field('TRANSMISSION')) for det in hfi.dets[freq]: prefix = str(freq) + '-' + det bandNo = rimo.index_of('bandpass_' + str(freq) + '-' + det) - inst_file.add_bandpass(prefix, rimo[bandNo].data.field('wavenumber'), rimo[bandNo].data.field('transmission')) + inst_file.add_hfi_bandpass(prefix, rimo[bandNo].data.field('wavenumber'), rimo[bandNo].data.field('transmission')) beamData, mmax_b = hp.read_alm(os.path.join(args.beam_dir, 'blm_' + str(freq) + '-' + det + '.fits'), return_mmax=True) From fe03f8924d06e044f0595f141bed07d8b0123264 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 4 Nov 2022 13:12:05 +0100 Subject: [PATCH 008/171] Fixed HFI bandpass bug --- commander3/todscripts/hfi/hfiinstrument.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/todscripts/hfi/hfiinstrument.py b/commander3/todscripts/hfi/hfiinstrument.py index d160d3541..f4933b38d 100644 --- a/commander3/todscripts/hfi/hfiinstrument.py +++ b/commander3/todscripts/hfi/hfiinstrument.py @@ -27,7 +27,7 @@ import argparse import sys from astropy.io import fits -sys.path.insert(0, "/mn/stornext/u3/hke/git/Commander_hfi/commander3/python") +#sys.path.insert(0, "/mn/stornext/u3/hke/git/Commander_hfi/commander3/python") from commander_tools.tod_tools.hfi import hfi from commander_tools.tod_tools.lfi import lfi from commander_tools.tod_tools import commander_instrument as inst From b22e703978c9f4daa44703c04cf0b91c831e3918 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 9 Nov 2022 13:14:25 +0100 Subject: [PATCH 009/171] Added HFI placeholders for baseline fitting and demodulation --- commander3/config/config.ita_oneapi | 4 +- .../defaults/bands/HFI/HFI_545_TOD.defaults | 3 +- commander3/src/comm_tod_hfi_mod.f90 | 152 ++++++++++++++---- commander3/src/comm_tod_mod.f90 | 2 +- commander3/todscripts/hfi/hfitohdf5.py | 18 ++- 5 files changed, 142 insertions(+), 37 deletions(-) diff --git a/commander3/config/config.ita_oneapi b/commander3/config/config.ita_oneapi index c7458ebef..5833677be 100644 --- a/commander3/config/config.ita_oneapi +++ b/commander3/config/config.ita_oneapi @@ -53,11 +53,11 @@ export MPCC := mpiicc #export F90FLAGS := -fpe0 -march=native -g -O2 -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -xHost #export F90FLAGS := -g -O2 -traceback #export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -prof-gen=srcpos -prof-dir=/mn/stornext/u3/hke/xsan/commander3/BP9/prof -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel #debug # -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv +export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index 18139ac9b..1ecff5afc 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -42,7 +42,8 @@ BAND_TOD_END_SCANID&&& = 53724 BAND_TOD_TOT_NUMSCAN&&& = 53724 BAND_TOD_FLAG&&& = 0 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. -BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 +#BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 +BAND_TOD_DETECTOR_LIST&&& = 545-2 BAND_TOD_INIT_FROM_HDF&&& = default #TODO: make these paths into real defaults in the Oslo legacy archive diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index f4efbe534..5026cfa88 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -51,11 +51,11 @@ module comm_tod_HFI_mod type, extends(comm_tod) :: comm_HFI_tod contains - procedure :: process_tod => process_HFI_tod - procedure :: read_tod_inst => read_tod_inst_HFI - procedure :: read_scan_inst => read_scan_inst_HFI - procedure :: initHDF_inst => initHDF_HFI - procedure :: dumpToHDF_inst => dumpToHDF_HFI + procedure :: process_tod => process_HFI_tod + procedure :: read_tod_inst => read_tod_inst_HFI + procedure :: read_scan_inst => read_scan_inst_HFI + procedure :: initHDF_inst => initHDF_HFI + procedure :: dumpToHDF_inst => dumpToHDF_HFI end type comm_HFI_tod interface comm_HFI_tod @@ -250,7 +250,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m nmaps = map_out%info%nmaps npix = 12*nside**2 self%output_n_maps = 3 - if (self%output_aux_maps > 0) then + if (self%output_aux_maps > 0 .or. .true.) then if (mod(iter-1,self%output_aux_maps) == 0) self%output_n_maps = 7 end if @@ -262,7 +262,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Distribute maps allocate(map_sky(nmaps,self%nobs,0:self%ndet,ndelta)) - call distribute_sky_maps(self, map_in, 1.e-6, map_sky) ! uK to K + call distribute_sky_maps(self, map_in, 1.e0, map_sky) ! already in K_cmb ! Distribute processing masks allocate(m_buf(0:npix-1,nmaps), procmask(0:npix-1), procmask2(0:npix-1)) @@ -270,6 +270,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call self%procmask2%bcast_fullsky_map(m_buf); procmask2 = m_buf(:,1) deallocate(m_buf) + call map_in(1,1)%p%writeFITS(trim(self%outdir) // "/input_sky_model_"//trim(self%label(1))//".fits") + +! call mpi_finalize(ierr) +! stop + ! Precompute far sidelobe Conviqt structures !if (self%correct_sl) then ! if (self%myid == 0) write(*,*) 'Precomputing sidelobe convolved sky' @@ -326,19 +331,34 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if + ! Estimate ADC corrections + ! Not implemented yet + + ! Estimate baselines; separate for odd and even samples + call sample_hfi_baselines(sd, self, i) + + ! Demodulate TOD + call demodulate_tod(sd, self, i) + + allocate(s_buf(sd%ntod,sd%ndet)) ! demodulate the data - s_buf = sd%tod * (1 - (iand(sd%flag, self%flag0))) - do j=1, sd%ndet - if (.not. self%scans(i)%d(j)%accept) cycle - sd%tod(:,j) = sd%tod(:,j) - sum(s_buf(:,j))/sum((1 - (iand(sd%flag(:,j),self%flag0)))) - do k=1, sd%ntod - if (sd%tod(k,j) < 0.d0) then - sd%tod(k,j) = - sd%tod(k,j) - end if - end do - end do +!!$ s_buf = sd%tod * (1 - (iand(sd%flag, self%flag0))) +!!$ do j=1, sd%ndet +!!$ if (.not. self%scans(i)%d(j)%accept) cycle +!!$ sd%tod(:,j) = sd%tod(:,j) - sum(s_buf(:,j))/sum((1 - (iand(sd%flag(:,j),self%flag0)))) +!!$ do k=1, sd%ntod +!!$ !if (sd%tod(k,j) < 0.d0) then +!!$ if (mod(k,2) == 0) then +!!$ sd%tod(k,j) = - sd%tod(k,j) +!!$ end if +!!$ end do +!!$ end do + +!!$ write(*,*) sd%tod(1:6,1) +!!$ call mpi_finalize(ierr) +!!$ stop ! remove cosmic rays do j=1, sd%ndet @@ -355,10 +375,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if ! Sample correlated noise - call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) + !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) + sd%n_corr = 0. ! Compute noise spectrum parameters - call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + !call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) ! Compute chisquare do j = 1, sd%ndet @@ -367,7 +388,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end do ! Select data - if (select_data) call remove_bad_data(self, i, sd%flag) + !if (select_data) call remove_bad_data(self, i, sd%flag) ! Compute chisquare for bandpass fit if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) @@ -392,14 +413,14 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if end if -!!$ open(123, file="todtest.txt") -!!$ if(self%scans(i)%chunk_num == 25083) then -!!$ write(*,*) "gain:", self%scans(i)%d(1)%gain -!!$ do k=1, self%scans(i)%ntod -!!$ write(123,*) sd%tod(k, 1) -!!$ end do -!!$ end if -!!$ close(123) + if(self%scans(i)%chunk_num == 3) then + open(123, file="testhke.txt", recl=1024) + write(*,*) "gain:", self%scans(i)%d(1)%gain + do k=1, self%scans(i)%ntod + write(123,*) k, sd%s_sky(k,1), d_calib(:,k,1) + end do + close(123) + end if ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) @@ -429,15 +450,15 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call synchronize_binmap(binmap, self) if (sample_rel_bandpass) then if (self%nmaps > 1) then - call finalize_binned_map(self, binmap, rms_out, 1.d6, chisq_S=chisq_S, mask=procmask2) + call finalize_binned_map(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2) else - call finalize_binned_map_unpol(self, binmap, rms_out, 1.d6, chisq_S=chisq_s, mask=procmask2) + call finalize_binned_map_unpol(self, binmap, rms_out, 1.d0, chisq_S=chisq_s, mask=procmask2) end if else if(self%nmaps > 1) then - call finalize_binned_map(self, binmap, rms_out, 1.d6) + call finalize_binned_map(self, binmap, rms_out, 1.d0) else - call finalize_binned_map_unpol(self, binmap, rms_out, 1.d6) + call finalize_binned_map_unpol(self, binmap, rms_out, 1.d0) end if end if map_out%map = binmap%outmaps(1)%p%map @@ -475,6 +496,73 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end subroutine process_HFI_tod + + subroutine sample_hfi_baselines(self, tod, scan) + ! + ! Estimates baselines for MODULATED data, separate for odd and even samples (ARTEM) + ! + ! Arguments: + ! ---------- + ! self: derived class (comm_scandata) + ! HFI-specific TOD object + ! tod: comm_tod derived type + ! contains TOD-specific information + ! scan: scan ID + ! + ! + ! Returns + ! ---------- + ! None, but updates tod%scans(scan)%d(:)%baseline (for odd samples) + ! tod%scans(scan)%d(:)%baseline2 (for even samples) + ! + implicit none + class(comm_scandata), intent(in) :: self + class(comm_tod), intent(inout) :: tod + integer(i4b), intent(in) :: scan + + integer(i4b) :: i + + do i = 1, tod%ndet + tod%scans(scan)%d(i)%baseline = 0. + tod%scans(scan)%d(i)%baseline2 = 0. + end do + + end subroutine sample_hfi_baselines + + + subroutine demodulate_tod(self, tod, scan) + ! + ! Demodulate HFI TOD + ! + ! Arguments: + ! ---------- + ! self: derived class (comm_scandata) + ! HFI-specific TOD object + ! tod: comm_tod derived type + ! contains TOD-specific information + ! scan: Scan ID + ! + ! Returns + ! ---------- + ! None, but updates self%tod + ! + implicit none + class(comm_scandata), intent(inout) :: self + class(comm_tod), intent(in) :: tod + integer(i4b), intent(in) :: scan + + integer(i4b) :: i + + do i = 1, tod%ndet + ! Subtract baselines + + ! Flip sign of even samples + + ! Make sure that the Galactic plane signal is positive; if not, switch sign + end do + + end subroutine demodulate_tod + subroutine read_tod_inst_HFI(self, file) ! diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 19118a8dd..1410f7e81 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -45,7 +45,7 @@ module comm_tod_mod real(dp) :: chisq real(dp) :: chisq_prop real(dp) :: chisq_masked - real(sp) :: baseline + real(sp) :: baseline, baseline2 logical(lgt) :: accept class(comm_noise_psd), pointer :: N_psd ! Noise PSD object real(sp), allocatable, dimension(:) :: tod ! Detector values in time domain, (ntod) diff --git a/commander3/todscripts/hfi/hfitohdf5.py b/commander3/todscripts/hfi/hfitohdf5.py index c98d677f8..b2aae13db 100644 --- a/commander3/todscripts/hfi/hfitohdf5.py +++ b/commander3/todscripts/hfi/hfitohdf5.py @@ -286,6 +286,9 @@ def make_od(comm_tod, freq, od, args): phi = math.radians(rimo[1].data.field('phi_uv')[rimo_i]) theta = math.radians(rimo[1].data.field('theta_uv')[rimo_i]) psi = math.radians(rimo[1].data.field('psi_uv')[rimo_i] + rimo[1].data.field('psi_pol')[rimo_i]) - phi + #print(phi) + #print(theta) + #print(psi) det_s = np.cos(0.5 * theta) * np.cos(0.5 * (phi + psi)) # vector part @@ -295,7 +298,11 @@ def make_od(comm_tod, freq, od, args): #convert from boresight pointing to per detector pointing r_det = rot.from_quat([det_x, det_y, det_z, det_s]) + #print r_det + #print r_boresight + #print + #print("Disabling focal plane") r_total = r_boresight * r_det #convert to theta, phi, psi @@ -391,7 +398,16 @@ def make_od(comm_tod, freq, od, args): #make psd noise #make tod data - tod = exFile[exFile.index_of(str(freq)+'-' + det)].data.field('signal')[pid_start:pid_end] - offset + tod = exFile[exFile.index_of(str(freq)+'-' + det)].data.field('signal')[pid_start:pid_end] #- offset + + #fout1 = open("output.dat","w") + #for i in range(len(tod)): + # fout1.write(str(tod[i])+"\n") + #fout1.close() + + #print(tod) + #print(offset) + #ghj #compArray = [hfi.todDtype, hfi.rice] compArray = [hfi.todDtype, hfi.huffTod] From 9d142b4999cd2fb442497b337538ed156f27de45 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 14 Nov 2022 12:57:09 +0100 Subject: [PATCH 010/171] Added HFI placeholders --- commander3/src/comm_tod_hfi_mod.f90 | 77 +++++++++++++---------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 5026cfa88..718dd14d6 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -331,34 +331,39 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if +!!$ ! Calling Simulation Routine +!!$ if (self%enable_tod_simulations) then +!!$ call simulate_tod(self, i, sd%s_tot, sd%n_corr, handle) +!!$ call sd%dealloc +!!$ cycle +!!$ end if + + ! ************************************************************************************ + ! Perform low-level TOD processing; raw modulated TOD -> clean demodulated TOD + ! ************************************************************************************ + ! Estimate ADC corrections ! Not implemented yet + ! Apply ADC corrections to raw self%tod + ! Not implemented yet + ! Estimate baselines; separate for odd and even samples call sample_hfi_baselines(sd, self, i) ! Demodulate TOD call demodulate_tod(sd, self, i) + if (self%first_call) then + ! Search for jumps + ! Not implemented yet + end if + + ! Apply jump corrections + ! Not implemented yet - allocate(s_buf(sd%ntod,sd%ndet)) - - ! demodulate the data -!!$ s_buf = sd%tod * (1 - (iand(sd%flag, self%flag0))) -!!$ do j=1, sd%ndet -!!$ if (.not. self%scans(i)%d(j)%accept) cycle -!!$ sd%tod(:,j) = sd%tod(:,j) - sum(s_buf(:,j))/sum((1 - (iand(sd%flag(:,j),self%flag0)))) -!!$ do k=1, sd%ntod -!!$ !if (sd%tod(k,j) < 0.d0) then -!!$ if (mod(k,2) == 0) then -!!$ sd%tod(k,j) = - sd%tod(k,j) -!!$ end if -!!$ end do -!!$ end do - -!!$ write(*,*) sd%tod(1:6,1) -!!$ call mpi_finalize(ierr) -!!$ stop + ! Fit and subtract dark bolometer signal; should this come before or after cosmic rays..? + ! Not implemented yet ! remove cosmic rays do j=1, sd%ndet @@ -366,13 +371,17 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call self%cray(j)%p%fit_cray_amplitudes() end do + ! Fit and subtract 4K lines + ! Not implemented yet + + ! Fit and deconvolve bolometer transfer function + ! Not implemented yet + - ! Calling Simulation Routine - if (self%enable_tod_simulations) then - call simulate_tod(self, i, sd%s_tot, sd%n_corr, handle) - call sd%dealloc - cycle - end if + + ! ************************************************************************************ + ! Perform high-level TOD processing; clean demodulated TOD -> maps + ! ************************************************************************************ ! Sample correlated noise !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) @@ -393,26 +402,10 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Compute chisquare for bandpass fit if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) - ! Compute binned map + ! Compute calibrated TOD for mapmaking allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) call compute_calibrated_data(self, i, sd, d_calib) - ! Output 4D map; note that psi is zero-base in 4D maps, and one-base in Commander - if (self%output_4D_map > 0) then - if (mod(iter-1,self%output_4D_map) == 0) then - allocate(sigma0(sd%ndet)) - do j = 1, sd%ndet - sigma0(j) = self%scans(i)%d(j)%N_psd%sigma0/self%scans(i)%d(j)%gain - end do - call output_4D_maps_hdf(trim(chaindir) // '/tod_4D_chain'//ctext//'_proc' // myid_text // '.h5', & - & samptext, self%scanid(i), self%nside, self%npsi, & - & self%label, self%horn_id, real(self%polang*180/pi,sp), sigma0, & - & sd%pix(:,:,1), sd%psi(:,:,1)-1, d_calib(1,:,:), iand(sd%flag,self%flag0), & - & self%scans(i)%d(:)%accept) - deallocate(sigma0) - end if - end if - if(self%scans(i)%chunk_num == 3) then open(123, file="testhke.txt", recl=1024) write(*,*) "gain:", self%scans(i)%d(1)%gain @@ -437,7 +430,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Clean up call sd%dealloc - deallocate(s_buf, d_calib) + deallocate(d_calib) end do From cee43f354e9464854eb8e43cc722e50021f9ed12 Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Mon, 28 Nov 2022 16:13:41 +0100 Subject: [PATCH 011/171] added demodulation --- .gitignore | 6 ++ commander3/src/comm_tod_hfi_mod.f90 | 155 ++++++++++++++++++++++++++-- commander3/src/math_tools.f90 | 61 ++++++++++- install_ita.sh | 4 +- 4 files changed, 214 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 96a26a8a8..de70e53d5 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,9 @@ Thumbs.db commander3/todscripts/quiet/quiet_qband_beam_effective_v1.fits commander3/todscripts/quiet/quiet_qband_bandpass_v1.txt commander3/todscripts/quiet/quiet_qband_beam_instrumental_v1.fits + + +param_*.txt +myoutput.dat +run_commander.sh +chains/ diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 5026cfa88..5fd2a5665 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -335,7 +335,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Not implemented yet ! Estimate baselines; separate for odd and even samples - call sample_hfi_baselines(sd, self, i) + call sample_hfi_baselines(sd, self, i, handle) ! Demodulate TOD call demodulate_tod(sd, self, i) @@ -497,7 +497,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end subroutine process_HFI_tod - subroutine sample_hfi_baselines(self, tod, scan) + subroutine sample_hfi_baselines(self, tod, scan, handle) ! ! Estimates baselines for MODULATED data, separate for odd and even samples (ARTEM) ! @@ -508,6 +508,10 @@ subroutine sample_hfi_baselines(self, tod, scan) ! tod: comm_tod derived type ! contains TOD-specific information ! scan: scan ID + ! handle: planck_rng derived type + ! Healpix definition for random number generation + ! so that the same sequence can be resumed later on from that same + ! point ! ! ! Returns @@ -519,14 +523,133 @@ subroutine sample_hfi_baselines(self, tod, scan) class(comm_scandata), intent(in) :: self class(comm_tod), intent(inout) :: tod integer(i4b), intent(in) :: scan + type(planck_rng), intent(inout) :: handle + + real(sp) :: sigma_0 + integer(i4b) :: i, j + real(sp), allocatable, dimension(:,:) :: T, even, uneven, tod_inv_N, matrix_buf, A, A_sqrt, s_tot_inv_N + real(sp), allocatable, dimension(:) :: B, eta, X - integer(i4b) :: i + + ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] + ! sd = self --- self%s_tot - sky signal model + ! self%s_tot(self%ntod, self%ndet) - how s_tot structured + + + allocate(s_tot_inv_N(self%ntod, tod%ndet)) + allocate(tod_inv_N(self%ntod, tod%ndet)) + allocate(even(self%ntod, tod%ndet), uneven(self%ntod, tod%ndet)) + + s_tot_inv_N = self%s_tot + tod_inv_N = self%tod do i = 1, tod%ndet - tod%scans(scan)%d(i)%baseline = 0. - tod%scans(scan)%d(i)%baseline2 = 0. + sigma_0 = tod%scans(scan)%d(i)%N_psd%sigma0 + + do j = 1, self%ntod + even(j,i) = 0.0/sigma_0/sigma_0 + uneven(j,i) = 1.0/sigma_0/sigma_0 + s_tot_inv_N(j,i) = s_tot_inv_N(j,i)/sigma_0/sigma_0 + tod_inv_N(j,i) = tod_inv_N(j,i)/sigma_0/sigma_0 + end do end do + !call multiply_inv_N(tod, scan, s_tot_inv_N) + !call multiply_inv_N(tod, scan, tod_inv_N) + !call multiply_inv_N(tod, scan, even) + !call multiply_inv_N(tod, scan, uneven) + + + do i = 1, tod%ndet + + allocate(T(self%ntod,3)) + allocate(matrix_buf(self%ntod,3)) + allocate(A(3,3), A_sqrt(3,3)) + allocate(B(3), eta(3), X(3)) + + + ! fill the matrix T and flip every other sample + do j = 1, self%ntod + if (mod(j,2) /= 0) then + T(j,1) = -1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain + T(j,2) = 0.0 + T(j,3) = 1.0 + else + T(j,1) = 1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain + T(j,2) = 1.0 + T(j,3) = 0.0 + end if + end do + + ! multiply matrices (N^-1 x T) + do j = 1, self%ntod + if (mod(j,2) /= 0) then + matrix_buf(j,1) = -1.0 * s_tot_inv_N(j,i) + matrix_buf(j,2) = even(j,i) + matrix_buf(j,3) = uneven(j,i) + else + matrix_buf(j,1) = 1.0 * s_tot_inv_N(j,i) + matrix_buf(j,2) = uneven(j,i) + matrix_buf(j,3) = even(j,i) + end if + end do + + + ! multiply matrices T^t x N^-1 x T + do j = 1, 3 + A(1,j) = sum(T(:,1)*matrix_buf(:,j)) + A(2,j) = sum(T(:,2)*matrix_buf(:,j)) + A(3,j) = sum(T(:,3)*matrix_buf(:,j)) + + ! preparing A_sqrt + A_sqrt(1,j) = A(1,j) + A_sqrt(2,j) = A(2,j) + A_sqrt(3,j) = A(3,j) + + end do + + + ! multiply T^t x N^-1 x d + do j = 1, 3 + B(j) = sum(T(:,j)*tod_inv_N(:,i)) + end do + + !do j = 1,3 + ! write(*,*) A(j,1), " ", A(j,2), " ", A(j,3) + !end do + + + call compute_hermitian_root_sp(A_sqrt, 0.5) + + ! fill random gaussian N(0,1) eta + do j = 1, 3 + eta(j) = rand_gauss(handle) + end do + + + ! multiply ((T^t x N^-1) x T)^0.5 eta + do j = 1, 3 + B(j) = B(j) + sum(A_sqrt(j,:)*eta(:)) + end do + + ! solving the linear system + call solve_system_real_sp(A, X, B) + + + write(*,*) "X=", X(1), " ", X(2), " ", X(3) + ! saving the offset to the tod object + tod%scans(scan)%d(i)%baseline = X(2) + tod%scans(scan)%d(i)%baseline2 = X(3) + + + deallocate(T, matrix_buf, A, A_sqrt) + deallocate(B, eta, X) + + end do + + + deallocate(s_tot_inv_N, tod_inv_N, even, uneven) + end subroutine sample_hfi_baselines @@ -551,14 +674,28 @@ subroutine demodulate_tod(self, tod, scan) class(comm_tod), intent(in) :: tod integer(i4b), intent(in) :: scan - integer(i4b) :: i + integer(i4b) :: i, j do i = 1, tod%ndet - ! Subtract baselines + ! Subtract baselines and Flip sign of even samples + do j = 1, self%ntod + if (mod(j,2) /= 0) then + self%tod(j,i) = -(self%tod(j,i) - tod%scans(scan)%d(i)%baseline) + else + self%tod(j,i) = (self%tod(j,i) - tod%scans(scan)%d(i)%baseline2) + end if + end do - ! Flip sign of even samples - ! Make sure that the Galactic plane signal is positive; if not, switch sign + if (i == 1) then + write(*,*) "it's output file time" + open(58, file="myoutput.dat", status="new") + do j = 1, self%ntod + write(58,*) j, self%tod(j,i), self%s_tot(j, i) + end do + close(58) + end if + end do end subroutine demodulate_tod diff --git a/commander3/src/math_tools.f90 b/commander3/src/math_tools.f90 index dc2dceabd..aa5e50d4c 100644 --- a/commander3/src/math_tools.f90 +++ b/commander3/src/math_tools.f90 @@ -662,6 +662,65 @@ subroutine compute_hermitian_root(A, pow, trunc) end subroutine compute_hermitian_root + subroutine compute_hermitian_root_sp(A, pow, trunc) + implicit none + + real(sp), intent(in) :: pow + real(sp), dimension(1:,1:), intent(inout) :: A + logical(lgt), intent(in), optional :: trunc + + integer(i8b) :: i, n, liwork, lwork, lda, ldb, info + character(len=1) :: job, uplo + real(sp), allocatable, dimension(:,:) :: V + real(dp), allocatable, dimension(:) :: W, work + integer(i4b), allocatable, dimension(:) :: iwork + + job = 'v' + uplo = 'l' + n = size(A(1,:)) + lda = n + ldb = n + liwork = 5*n + 3 + lwork = 2*n**2 + 6*n + 1 + + ! Perform eigenvalue decomposition + allocate(work(lwork)) + allocate(iwork(liwork)) + allocate(V(n,n)) + allocate(W(n)) + V = A + call dsyevd(job, uplo, n, V, lda, W, work, lwork, iwork, liwork, info) + + if (present(trunc)) then + where (W < 0.d0) + W = 0.d0 + end where + else + if (any(W <= 0.d0)) then +! write(*,*) 'W = ', W + A(1,1) = -1.30 + deallocate(V) + deallocate(W) + deallocate(work) + deallocate(iwork) + return + end if + end if + + ! Re-compose matrix + do i = 1, n + A(i,:) = W(i)**pow * V(:,i) + end do + A = matmul(V, A) + + deallocate(V) + deallocate(W) + deallocate(work) + deallocate(iwork) + + end subroutine compute_hermitian_root_sp + + subroutine compute_hermitian_root_with_mask(A, pow, A2, pow2) implicit none @@ -807,7 +866,7 @@ subroutine invert_singular_matrix(matrix, threshold) integer(i4b) :: myid, i, n real(dp) :: maxeigenval - myid = 1000 + myid = 1000 ! ??? n = size(matrix(1,:)) allocate(matrix2(n,n)) allocate(eigenvals(n)) diff --git a/install_ita.sh b/install_ita.sh index 6cf159a4c..cd8a3a2fb 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -7,7 +7,7 @@ # Compiler Toolchain to use # Possible values: nvidia, flang, gnu, intel, oneapi toolchain="oneapi" -buildtype="Release" #"Debug" #"Release" #"RelWithDebInfo" +buildtype="Debug" #"Debug" #"Release" #"RelWithDebInfo" #------------------------------------------------------------------------------ # Absolute path to Commander3 root directory comm3_root_dir="$(pwd)" @@ -236,4 +236,4 @@ then cmake --build $comm3_root_dir/$build_dir --target install -j $physicalCpuCount #-v else printf "TERMINATING: NOT ON ITA MACHINE!" -fi \ No newline at end of file +fi From a1e68d11a4273be8f9a715d862f3cab8ea192969 Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Tue, 13 Dec 2022 12:40:32 +0100 Subject: [PATCH 012/171] updated baseline subtraction --- .gitignore | 2 +- .../defaults/bands/HFI/HFI_545_TOD.defaults | 2 +- commander3/src/comm_tod_hfi_mod.f90 | 49 +++++++++++++------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index de70e53d5..8796225dd 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,6 @@ commander3/todscripts/quiet/quiet_qband_beam_instrumental_v1.fits param_*.txt -myoutput.dat +myoutput*.dat run_commander.sh chains/ diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index 1ecff5afc..a3ee800df 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -58,5 +58,5 @@ BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 -BAND_TOD_FILELIST&&& = filelist_545_v1.txt +BAND_TOD_FILELIST&&& = filelist_545_Artem.txt diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 713b23f57..40f656603 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -565,34 +565,34 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) do j = 1, self%ntod if (mod(j,2) /= 0) then T(j,1) = -1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain - T(j,2) = 0.0 - T(j,3) = 1.0 - else - T(j,1) = 1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain T(j,2) = 1.0 T(j,3) = 0.0 + else + T(j,1) = 1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain + T(j,2) = 0.0 + T(j,3) = 1.0 end if end do - ! multiply matrices (N^-1 x T) + ! multiply matrices (N^-1 x T) possibly (T^t x N^-1) do j = 1, self%ntod if (mod(j,2) /= 0) then matrix_buf(j,1) = -1.0 * s_tot_inv_N(j,i) - matrix_buf(j,2) = even(j,i) - matrix_buf(j,3) = uneven(j,i) + matrix_buf(j,2) = uneven(j,i) + matrix_buf(j,3) = even(j,i) else matrix_buf(j,1) = 1.0 * s_tot_inv_N(j,i) - matrix_buf(j,2) = uneven(j,i) - matrix_buf(j,3) = even(j,i) + matrix_buf(j,2) = even(j,i) + matrix_buf(j,3) = uneven(j,i) end if end do ! multiply matrices T^t x N^-1 x T do j = 1, 3 - A(1,j) = sum(T(:,1)*matrix_buf(:,j)) - A(2,j) = sum(T(:,2)*matrix_buf(:,j)) - A(3,j) = sum(T(:,3)*matrix_buf(:,j)) + A(1,j) = sum(matrix_buf(:,1) * T(:,j)) !sum(T(:,1)*matrix_buf(:,j)) + A(2,j) = sum(matrix_buf(:,2) * T(:,j)) !sum(T(:,2)*matrix_buf(:,j)) + A(3,j) = sum(matrix_buf(:,3) * T(:,j)) !sum(T(:,3)*matrix_buf(:,j)) ! preparing A_sqrt A_sqrt(1,j) = A(1,j) @@ -604,7 +604,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! multiply T^t x N^-1 x d do j = 1, 3 - B(j) = sum(T(:,j)*tod_inv_N(:,i)) + B(j) = sum(matrix_buf(:,j)* self%tod(:,i)) !sum(T(:,j)*tod_inv_N(:,i)) end do !do j = 1,3 @@ -668,8 +668,11 @@ subroutine demodulate_tod(self, tod, scan) integer(i4b), intent(in) :: scan integer(i4b) :: i, j + logical :: exists do i = 1, tod%ndet + + ! Subtract baselines and Flip sign of even samples do j = 1, self%ntod if (mod(j,2) /= 0) then @@ -677,18 +680,34 @@ subroutine demodulate_tod(self, tod, scan) else self%tod(j,i) = (self%tod(j,i) - tod%scans(scan)%d(i)%baseline2) end if + end do + ! flip the sign if all negative + !if (all(check_negative)) then + ! do j = 1, self%ntod + ! self%tod(j,i) = - self%tod(j,i) + ! end do + !end if + + if (i == 1) then - write(*,*) "it's output file time" - open(58, file="myoutput.dat", status="new") + + inquire(file="myoutput.dat", exist=exists) + if (exists) then + open(58, file="myoutput.dat", status="old", position="append") + else + open(58, file="myoutput.dat", status="new") + end if + do j = 1, self%ntod write(58,*) j, self%tod(j,i), self%s_tot(j, i) end do close(58) end if + end do end subroutine demodulate_tod From f2242bfe033847b5397394920e3efb3e68e1a7ce Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Mon, 14 Aug 2023 12:02:18 +0200 Subject: [PATCH 013/171] updated comm_tod_hfi with demodulation --- .gitignore | 6 +- .../defaults/bands/HFI/HFI_545_TOD.defaults | 2 +- commander3/src/comm_tod_driver_mod.f90 | 1 + commander3/src/comm_tod_hfi_mod.f90 | 135 +++++++++--------- commander3/src/comm_tod_mod.f90 | 3 +- commander3/src/comm_tod_pointing_mod.f90 | 6 +- 6 files changed, 83 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index 8796225dd..405eff233 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,8 @@ commander3/todscripts/quiet/quiet_qband_beam_instrumental_v1.fits param_*.txt myoutput*.dat run_commander.sh -chains/ +chains*/ +testhke.txt +*.dat + + diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index a3ee800df..fa6d8c660 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -58,5 +58,5 @@ BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 -BAND_TOD_FILELIST&&& = filelist_545_Artem.txt +BAND_TOD_FILELIST&&& = filelist_545_Artem_full.txt diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index a68864a01..1b1318eb3 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -253,6 +253,7 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas if (tod%sample_mono) self%s_tot(:,j) = self%s_tot(:,j) + self%s_mono(:,j) if (tod%apply_inst_corr) self%s_tot(:,j) = self%s_tot(:,j) + self%s_inst(:,j) end do + !call update_status(status, "todinit_stot") end subroutine init_scan_data_singlehorn diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 40f656603..01cf337c4 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -142,7 +142,7 @@ function constructor(cpar, id_abs, info, tod_type) ! Get detector labels call get_tokens(cpar%ds_tod_dets(id_abs), ",", constructor%label) - + ! Read the actual TOD call constructor%read_tod(constructor%label) @@ -406,14 +406,6 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) call compute_calibrated_data(self, i, sd, d_calib) - if(self%scans(i)%chunk_num == 3) then - open(123, file="testhke.txt", recl=1024) - write(*,*) "gain:", self%scans(i)%d(1)%gain - do k=1, self%scans(i)%ntod - write(123,*) k, sd%s_sky(k,1), d_calib(:,k,1) - end do - close(123) - end if ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) @@ -434,6 +426,25 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end do + + ! calculate gain as a median of all scans + !do j = 1, self%ndet + ! allocate(temp(self%nscan)) + + ! do i = 1, self%nscan + ! temp(i) = self%scans(i)%d(j)%gain + ! end do + + ! gain_median = median(temp) + + ! do i = 1, self%nscan + ! self%scans(i)%d(j)%gain = gain_median + ! end do + + ! deallocate(temp) + !end do + + if (self%myid == 0) write(*,*) ' --> Finalizing maps, bp' ! Output latest scan list with new timing information @@ -492,7 +503,7 @@ end subroutine process_HFI_tod subroutine sample_hfi_baselines(self, tod, scan, handle) ! - ! Estimates baselines for MODULATED data, separate for odd and even samples (ARTEM) + ! Estimates baselines for MODULATED data, separate for odd and even samples ! ! Arguments: ! ---------- @@ -511,6 +522,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! ---------- ! None, but updates tod%scans(scan)%d(:)%baseline (for odd samples) ! tod%scans(scan)%d(:)%baseline2 (for even samples) + ! tod%scans(scan)%d(:)%gain (temporary solution) ! implicit none class(comm_scandata), intent(in) :: self @@ -518,11 +530,12 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) integer(i4b), intent(in) :: scan type(planck_rng), intent(inout) :: handle - real(sp) :: sigma_0 + real(dp) :: sigma_0 integer(i4b) :: i, j - real(sp), allocatable, dimension(:,:) :: T, even, uneven, tod_inv_N, matrix_buf, A, A_sqrt, s_tot_inv_N - real(sp), allocatable, dimension(:) :: B, eta, X - + real(dp), allocatable, dimension(:,:) :: T, even, uneven, tod_inv_N, matrix_buf, A, A_sqrt, s_tot_inv_N + real(dp), allocatable, dimension(:) :: B, eta, X + real(dp), allocatable, dimension(:) :: temp + real(dp) :: gain_median ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] ! sd = self --- self%s_tot - sky signal model @@ -536,12 +549,13 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) s_tot_inv_N = self%s_tot tod_inv_N = self%tod + ! preparing utility and noise matrices, where noise is assumed constant do i = 1, tod%ndet sigma_0 = tod%scans(scan)%d(i)%N_psd%sigma0 do j = 1, self%ntod - even(j,i) = 0.0/sigma_0/sigma_0 - uneven(j,i) = 1.0/sigma_0/sigma_0 + even(j,i) = 0.d0 !/sigma_0/sigma_0 + uneven(j,i) = 1.d0/sigma_0/sigma_0 s_tot_inv_N(j,i) = s_tot_inv_N(j,i)/sigma_0/sigma_0 tod_inv_N(j,i) = tod_inv_N(j,i)/sigma_0/sigma_0 end do @@ -564,24 +578,25 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! fill the matrix T and flip every other sample do j = 1, self%ntod if (mod(j,2) /= 0) then - T(j,1) = -1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain - T(j,2) = 1.0 - T(j,3) = 0.0 + T(j,1) = -1.d0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain + T(j,2) = 1.d0 + T(j,3) = 0.d0 else - T(j,1) = 1.0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain - T(j,2) = 0.0 - T(j,3) = 1.0 + T(j,1) = 1.d0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain + T(j,2) = 0.d0 + T(j,3) = 1.d0 end if + end do ! multiply matrices (N^-1 x T) possibly (T^t x N^-1) do j = 1, self%ntod if (mod(j,2) /= 0) then - matrix_buf(j,1) = -1.0 * s_tot_inv_N(j,i) + matrix_buf(j,1) = -1.d0 * s_tot_inv_N(j,i) matrix_buf(j,2) = uneven(j,i) matrix_buf(j,3) = even(j,i) else - matrix_buf(j,1) = 1.0 * s_tot_inv_N(j,i) + matrix_buf(j,1) = 1.d0 * s_tot_inv_N(j,i) matrix_buf(j,2) = even(j,i) matrix_buf(j,3) = uneven(j,i) end if @@ -590,11 +605,11 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! multiply matrices T^t x N^-1 x T do j = 1, 3 - A(1,j) = sum(matrix_buf(:,1) * T(:,j)) !sum(T(:,1)*matrix_buf(:,j)) - A(2,j) = sum(matrix_buf(:,2) * T(:,j)) !sum(T(:,2)*matrix_buf(:,j)) - A(3,j) = sum(matrix_buf(:,3) * T(:,j)) !sum(T(:,3)*matrix_buf(:,j)) + A(1,j) = sum(T(:,1)*matrix_buf(:,j)) + A(2,j) = sum(T(:,2)*matrix_buf(:,j)) + A(3,j) = sum(T(:,3)*matrix_buf(:,j)) - ! preparing A_sqrt + ! preparing for A_sqrt calculation A_sqrt(1,j) = A(1,j) A_sqrt(2,j) = A(2,j) A_sqrt(3,j) = A(3,j) @@ -604,37 +619,54 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! multiply T^t x N^-1 x d do j = 1, 3 - B(j) = sum(matrix_buf(:,j)* self%tod(:,i)) !sum(T(:,j)*tod_inv_N(:,i)) + B(j) = sum(T(:,j)*tod_inv_N(:,i)) end do - !do j = 1,3 - ! write(*,*) A(j,1), " ", A(j,2), " ", A(j,3) - !end do + call compute_hermitian_root(A_sqrt, 0.5d0) - call compute_hermitian_root_sp(A_sqrt, 0.5) ! fill random gaussian N(0,1) eta do j = 1, 3 eta(j) = rand_gauss(handle) end do - ! multiply ((T^t x N^-1) x T)^0.5 eta do j = 1, 3 B(j) = B(j) + sum(A_sqrt(j,:)*eta(:)) end do ! solving the linear system - call solve_system_real_sp(A, X, B) + call solve_system_real(A, X, B) - write(*,*) "X=", X(1), " ", X(2), " ", X(3) - ! saving the offset to the tod object + !write(*,*) "X=", X(1), " ", X(2), " ", X(3) + ! saving the offset (and gain) to the tod object + tod%scans(scan)%d(i)%gain = X(1) tod%scans(scan)%d(i)%baseline = X(2) tod%scans(scan)%d(i)%baseline2 = X(3) + ! calculate gain as a median of all scans + ! (a temporary solution, before a proper sampling established) + if (scan == tod%nscan) then + allocate(temp(tod%nscan)) + + do j = 1, tod%nscan + temp(j) = tod%scans(j)%d(i)%gain + end do + + gain_median = median(temp) + + do j = 1, tod%nscan + tod%scans(j)%d(i)%gain = gain_median + end do + + deallocate(temp) + end if + + + deallocate(T, matrix_buf, A, A_sqrt) deallocate(B, eta, X) @@ -672,42 +704,15 @@ subroutine demodulate_tod(self, tod, scan) do i = 1, tod%ndet - - ! Subtract baselines and Flip sign of even samples + ! Subtract baselines and flip sign of even samples do j = 1, self%ntod if (mod(j,2) /= 0) then self%tod(j,i) = -(self%tod(j,i) - tod%scans(scan)%d(i)%baseline) else self%tod(j,i) = (self%tod(j,i) - tod%scans(scan)%d(i)%baseline2) end if - end do - - ! flip the sign if all negative - !if (all(check_negative)) then - ! do j = 1, self%ntod - ! self%tod(j,i) = - self%tod(j,i) - ! end do - !end if - - - if (i == 1) then - - inquire(file="myoutput.dat", exist=exists) - if (exists) then - open(58, file="myoutput.dat", status="old", position="append") - else - open(58, file="myoutput.dat", status="new") - end if - - do j = 1, self%ntod - write(58,*) j, self%tod(j,i), self%s_tot(j, i) - end do - close(58) - end if - - end do end subroutine demodulate_tod diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 1410f7e81..2f362e7d0 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -45,7 +45,7 @@ module comm_tod_mod real(dp) :: chisq real(dp) :: chisq_prop real(dp) :: chisq_masked - real(sp) :: baseline, baseline2 + real(dp) :: baseline, baseline2 logical(lgt) :: accept class(comm_noise_psd), pointer :: N_psd ! Noise PSD object real(sp), allocatable, dimension(:) :: tod ! Detector values in time domain, (ntod) @@ -544,6 +544,7 @@ subroutine load_instrument_file(self, nside_beam, nmaps_beam, pol_beam, comm_cha integer(i4b) :: lmax_beam, lmax_sl, i type(comm_mapinfo), pointer :: info_beam + if(len(trim(self%instfile)) == 0) then write(*,*) "Cannot open instrument file with empty name for tod: " // self%tod_type end if diff --git a/commander3/src/comm_tod_pointing_mod.f90 b/commander3/src/comm_tod_pointing_mod.f90 index 4bcfcde7d..46cac9c1e 100644 --- a/commander3/src/comm_tod_pointing_mod.f90 +++ b/commander3/src/comm_tod_pointing_mod.f90 @@ -46,6 +46,8 @@ subroutine project_sky(tod, map, pix, psi, flag, pmask, scan_id, & ! T - temperature; Q, U - Stoke's parameters ! if (tod%myid == 78) write(*,*) 'c611', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires + + nmap = SIZE(map, 1) do det = 1, tod%ndet if (.not. tod%scans(scan_id)%d(det)%accept) then @@ -63,8 +65,7 @@ subroutine project_sky(tod, map, pix, psi, flag, pmask, scan_id, & & map(3,p,det) * tod%sin2psi(psi(i,det)) else if (nmap == 1) then s_sky(i,det) = map(1,p,det) ! Unpolarized channel - end if - + end if !if (tod%myid == 78 .and. p == 7863) write(*,*) 'c61122', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires, i, p tmask(i,det) = pmask(pix(i,det)) @@ -92,6 +93,7 @@ subroutine project_sky(tod, map, pix, psi, flag, pmask, scan_id, & end do end if + end subroutine project_sky ! Sky signal template From dcb6947042721ad4a58810503fdad7aa812ab1c5 Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Wed, 16 Aug 2023 16:34:35 +0200 Subject: [PATCH 014/171] added comm_tod_cr_mod for cosmic rays --- cmake/projects/commander3.cmake | 1 + commander3/src/Makefile | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 18b6929f2..cb5a6c77a 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -63,6 +63,7 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_tod_lfi_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_lfi_smod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_hfi_mod.f90 + ${COMMANDER3_SOURCE_DIR}/comm_tod_cr_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_gain_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_gain_smod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_noise_mod.f90 diff --git a/commander3/src/Makefile b/commander3/src/Makefile index a641986f0..95f7b1eed 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -106,6 +106,7 @@ F90SOURCES=hashtbl.f90 \ comm_tod_lb_mod.f90 \ comm_tod_dirbe_mod.f90 \ comm_tod_hfi_mod.f90 \ + comm_tod_cr_mod.f90 \ comm_camb_mod.f90 \ comm_tod_adc_mod.f90 comm_tod_adc_smod.f90 \ comm_timing_mod.f90 \ @@ -218,6 +219,7 @@ comm_tod_spider_smod.o : comm_tod_spider_mod.o comm_tod_wmap_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o comm_conviqt_mod.o comm_huffman_mod.o comm_hdf_mod.o comm_fft_mod.o spline_1d_mod.o comm_4d_map_mod.o comm_zodi_mod.o comm_tod_mapmaking_mod.o comm_tod_pointing_mod.o comm_tod_gain_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_driver_mod.o comm_utils.o comm_tod_dirbe_mod.o : comm_tod_mod.o comm_param_mod.o comm_map_mod.o comm_conviqt_mod.o comm_huffman_mod.o comm_hdf_mod.o comm_fft_mod.o spline_1d_mod.o comm_4d_map_mod.o comm_zodi_mod.o comm_tod_mapmaking_mod.o comm_tod_pointing_mod.o comm_tod_gain_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_driver_mod.o comm_utils.o comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_shared_arr_mod.o comm_conviqt_mod.o comm_tod_cray_mod.o +comm_tod_cr_mod.o : comm_tod_mod.o comm_utils.o comm_utils.o : comm_system_mod.o comm_defs.o sort_utils.o spline_1d_mod.o comm_mpi_mod.o comm_zodi_mod.o : comm_utils.o comm_param_mod.o invsamp_mod.o : spline_1d_mod.o From 692a9b5928acbd12a44cf097812e5767c45a6efa Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Wed, 16 Aug 2023 16:46:31 +0200 Subject: [PATCH 015/171] cosmic rays mod --- commander3/src/comm_tod_cr_mod.f90 | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 commander3/src/comm_tod_cr_mod.f90 diff --git a/commander3/src/comm_tod_cr_mod.f90 b/commander3/src/comm_tod_cr_mod.f90 new file mode 100644 index 000000000..19ce41042 --- /dev/null +++ b/commander3/src/comm_tod_cr_mod.f90 @@ -0,0 +1,66 @@ +!=============================================================================== +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University +! of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!=============================================================================== + +! This module handles cosmic rays correction to time ordered data + +module comm_tod_cr_mod + use comm_tod_mod + use comm_utils + implicit none + + private + public comm_cr + + type :: comm_cr + real(dp) :: amplitude, tau ! parameters to fit a template + + contains + procedure :: find_cosmic_rays + procedure :: fit_template + procedure :: cr_subtraction + + end type comm_cr + +interface + + module subroutine find_cosmic_rays(self) + implicit none + class(comm_cr), intent(inout) :: self + end subroutine find_cosmic_rays + + module subroutine fit_template(self) + implicit none + class(comm_cr), intent(inout) :: self + end subroutine fit_template + + module subroutine cr_subtraction(self) + implicit none + class(comm_cr), intent(inout) :: self + end subroutine cr_subtraction + + +end interface + +end module comm_tod_cr_mod + + + From bae03c7e3fe8ba324873ff4e4c7cefcfca23aa45 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 18 Apr 2024 17:13:31 +0200 Subject: [PATCH 016/171] fixed zodi output crash --- commander3/src/comm_tod_driver_mod.f90 | 2 +- commander3/src/comm_zodi_mod.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index fd383341d..1b7d562c7 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -965,7 +965,7 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) if ((tod%output_n_maps > 7) .and. allocated(sd%s_inst)) d_calib(8,:,j) = (sd%s_inst(:,j) - sum(real(sd%s_inst(:,j),dp)/sd%ntod)) * inv_gain ! instrument specific if ((tod%output_n_maps > 8) .and. allocated(sd%s_zodi_scat) .and. allocated(sd%s_zodi_therm)) then do i = 1, size(sd%s_zodi_therm, dim=2) - write(*,*) 'b',j,i, tod%scanid(scan), any(sd%s_zodi_scat(:,i:i,j)/=sd%s_zodi_scat(:,i:i,j)), any(sd%s_zodi_therm(:,i:i,j)/=sd%s_zodi_therm(:,i:i,j)) + !write(*,*) 'b',j,i, tod%scanid(scan), any(sd%s_zodi_scat(:,i:i,j)/=sd%s_zodi_scat(:,i:i,j)), any(sd%s_zodi_therm(:,i:i,j)/=sd%s_zodi_therm(:,i:i,j)) call get_s_zodi(tod%id, sd%s_zodi_therm(:, i:i, j), sd%s_zodi_scat(:, i:i, j), d_calib(8 + i, :, j), comp_id=i) end do end if diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 964225781..157374842 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -761,7 +761,7 @@ subroutine get_s_zodi(band, s_therm, s_scat, s_zodi, comp_id) al = zodi_model%comps(i)%c%albedo(band) em = zodi_model%comps(i)%c%emissivity(band) !write(*,*) i, em, al, any(s_scat(:,i)/=s_scat(:,i)), any(s_therm(:,i)/=s_therm(:,i)) - s_zodi = s_zodi + ((s_scat(:,i) * al) + (1. - al) * em * s_therm(:,i)) + s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + (1. - al) * em * s_therm(:,i-first+1)) end do end subroutine get_s_zodi From a09b56d409d6b3de47e80fdc6a9e1537c52781db Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Fri, 19 Apr 2024 17:19:50 +0200 Subject: [PATCH 017/171] added 143 --- .../defaults/bands/HFI/HFI_545_TOD.defaults | 8 +- commander3/src/comm_hdf_mod.f90 | 5363 ----------------- install_ita.sh | 8 +- 3 files changed, 7 insertions(+), 5372 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index fa6d8c660..d91a3db36 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -37,9 +37,9 @@ BAND_TOD_LEVEL&&& = L1 BAND_TOD_TYPE&&& = HFI BAND_TOD_BP_INIT_PROP&&& = none BAND_TOD_HALFRING&&& = 0 -BAND_TOD_START_SCANID&&& = 3 -BAND_TOD_END_SCANID&&& = 53724 -BAND_TOD_TOT_NUMSCAN&&& = 53724 +BAND_TOD_START_SCANID&&& = 700 # 3 +BAND_TOD_END_SCANID&&& = 18300 #53724 +BAND_TOD_TOT_NUMSCAN&&& = 18338 #53724 BAND_TOD_FLAG&&& = 0 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. #BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 @@ -58,5 +58,5 @@ BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 -BAND_TOD_FILELIST&&& = filelist_545_Artem_full.txt +BAND_TOD_FILELIST&&& = filelist_545_Artem_full_pointing_DPC.txt #filelist_545_Artem_full.txt diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index 24d9dd428..e69de29bb 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -1,5363 +0,0 @@ -!================================================================================ -! -! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. -! -! This file is part of Commander3. -! -! Commander3 is free software: you can redistribute it and/or modify -! it under the terms of the GNU General Public License as published by -! the Free Software Foundation, either version 3 of the License, or -! (at your option) any later version. -! -! Commander3 is distributed in the hope that it will be useful, -! but WITHOUT ANY WARRANTY; without even the implied warranty of -! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -! GNU General Public License for more details. -! -! You should have received a copy of the GNU General Public License -! along with Commander3. If not, see . -! -!================================================================================ -! Due to the extreme amount of redundancy in hdf_mod, it is now generated -! by using the handy tempita template language. All the machinery for -! doing this is included in the repository, so this should just work. -module comm_hdf_mod - use healpix_types - use comm_utils - use hdf5 - implicit none - - type hdf_file - character(len=512) :: filename, setname - integer(hid_t) :: filehandle, sethandle - integer :: status - end type hdf_file - - type :: byte_pointer - byte, allocatable, dimension(:) :: p - ! contains - ! final :: dealloc_byte_pointer - end type byte_pointer - - interface read_hdf - module procedure read_hdf_0d_dp - module procedure read_hdf_0d_sp - module procedure read_hdf_0d_int - module procedure read_hdf_0d_char - module procedure read_hdf_1d_dp - module procedure read_hdf_1d_sp - module procedure read_hdf_1d_int - module procedure read_hdf_1d_char - module procedure read_hdf_2d_dp - module procedure read_hdf_2d_sp - module procedure read_hdf_2d_int - module procedure read_hdf_2d_char - module procedure read_hdf_3d_dp - module procedure read_hdf_3d_sp - module procedure read_hdf_3d_int - module procedure read_hdf_3d_char - module procedure read_hdf_4d_dp - module procedure read_hdf_4d_sp - module procedure read_hdf_4d_int - module procedure read_hdf_4d_char - module procedure read_hdf_5d_dp - module procedure read_hdf_5d_sp - module procedure read_hdf_5d_int - module procedure read_hdf_5d_char - module procedure read_hdf_6d_dp - module procedure read_hdf_6d_sp - module procedure read_hdf_6d_int - module procedure read_hdf_6d_char - module procedure read_hdf_7d_dp - module procedure read_hdf_7d_sp - module procedure read_hdf_7d_int - module procedure read_hdf_7d_char - module procedure read_hdf_slice_0d_dp - module procedure read_hdf_slice_0d_sp - module procedure read_hdf_slice_0d_int - module procedure read_hdf_slice_0d_char - module procedure read_hdf_slice_1d_dp - module procedure read_hdf_slice_1d_sp - module procedure read_hdf_slice_1d_int - module procedure read_hdf_slice_1d_char - module procedure read_hdf_slice_2d_dp - module procedure read_hdf_slice_2d_sp - module procedure read_hdf_slice_2d_int - module procedure read_hdf_slice_2d_char - module procedure read_hdf_slice_3d_dp - module procedure read_hdf_slice_3d_sp - module procedure read_hdf_slice_3d_int - module procedure read_hdf_slice_3d_char - module procedure read_hdf_slice_4d_dp - module procedure read_hdf_slice_4d_sp - module procedure read_hdf_slice_4d_int - module procedure read_hdf_slice_4d_char - module procedure read_hdf_slice_5d_dp - module procedure read_hdf_slice_5d_sp - module procedure read_hdf_slice_5d_int - module procedure read_hdf_slice_5d_char - module procedure read_hdf_slice_6d_dp - module procedure read_hdf_slice_6d_sp - module procedure read_hdf_slice_6d_int - module procedure read_hdf_slice_6d_char - module procedure read_hdf_slice_7d_dp - module procedure read_hdf_slice_7d_sp - module procedure read_hdf_slice_7d_int - module procedure read_hdf_slice_7d_char - end interface - - interface read_alloc_hdf - module procedure read_alloc_hdf_1d_dp - module procedure read_alloc_hdf_1d_sp - module procedure read_alloc_hdf_1d_int - module procedure read_alloc_hdf_1d_char - module procedure read_alloc_hdf_2d_dp - module procedure read_alloc_hdf_2d_sp - module procedure read_alloc_hdf_2d_int - module procedure read_alloc_hdf_2d_char - module procedure read_alloc_hdf_3d_dp - module procedure read_alloc_hdf_3d_sp - module procedure read_alloc_hdf_3d_int - module procedure read_alloc_hdf_3d_char - module procedure read_alloc_hdf_4d_dp - module procedure read_alloc_hdf_4d_sp - module procedure read_alloc_hdf_4d_int - module procedure read_alloc_hdf_4d_char - module procedure read_alloc_hdf_5d_dp - module procedure read_alloc_hdf_5d_sp - module procedure read_alloc_hdf_5d_int - module procedure read_alloc_hdf_5d_char - module procedure read_alloc_hdf_6d_dp - module procedure read_alloc_hdf_6d_sp - module procedure read_alloc_hdf_6d_int - module procedure read_alloc_hdf_6d_char - module procedure read_alloc_hdf_7d_dp - module procedure read_alloc_hdf_7d_sp - module procedure read_alloc_hdf_7d_int - module procedure read_alloc_hdf_7d_char - end interface - - interface write_hdf - module procedure write_hdf_0d_dp - module procedure write_hdf_0d_sp - module procedure write_hdf_0d_int - module procedure write_hdf_0d_char - module procedure write_hdf_1d_dp - module procedure write_hdf_1d_sp - module procedure write_hdf_1d_int - module procedure write_hdf_1d_char - module procedure write_hdf_2d_dp - module procedure write_hdf_2d_sp - module procedure write_hdf_2d_int - module procedure write_hdf_2d_char - module procedure write_hdf_3d_dp - module procedure write_hdf_3d_sp - module procedure write_hdf_3d_int - module procedure write_hdf_3d_char - module procedure write_hdf_4d_dp - module procedure write_hdf_4d_sp - module procedure write_hdf_4d_int - module procedure write_hdf_4d_char - module procedure write_hdf_5d_dp - module procedure write_hdf_5d_sp - module procedure write_hdf_5d_int - module procedure write_hdf_5d_char - module procedure write_hdf_6d_dp - module procedure write_hdf_6d_sp - module procedure write_hdf_6d_int - module procedure write_hdf_6d_char - module procedure write_hdf_7d_dp - module procedure write_hdf_7d_sp - module procedure write_hdf_7d_int - module procedure write_hdf_7d_char - module procedure write_hdf_slice_0d_dp - module procedure write_hdf_slice_0d_sp - module procedure write_hdf_slice_0d_int - module procedure write_hdf_slice_0d_char - module procedure write_hdf_slice_1d_dp - module procedure write_hdf_slice_1d_sp - module procedure write_hdf_slice_1d_int - module procedure write_hdf_slice_1d_char - module procedure write_hdf_slice_2d_dp - module procedure write_hdf_slice_2d_sp - module procedure write_hdf_slice_2d_int - module procedure write_hdf_slice_2d_char - module procedure write_hdf_slice_3d_dp - module procedure write_hdf_slice_3d_sp - module procedure write_hdf_slice_3d_int - module procedure write_hdf_slice_3d_char - module procedure write_hdf_slice_4d_dp - module procedure write_hdf_slice_4d_sp - module procedure write_hdf_slice_4d_int - module procedure write_hdf_slice_4d_char - module procedure write_hdf_slice_5d_dp - module procedure write_hdf_slice_5d_sp - module procedure write_hdf_slice_5d_int - module procedure write_hdf_slice_5d_char - module procedure write_hdf_slice_6d_dp - module procedure write_hdf_slice_6d_sp - module procedure write_hdf_slice_6d_int - module procedure write_hdf_slice_6d_char - module procedure write_hdf_slice_7d_dp - module procedure write_hdf_slice_7d_sp - module procedure write_hdf_slice_7d_int - module procedure write_hdf_slice_7d_char - end interface - - interface slice - module procedure slice_0d - module procedure slice_1d - module procedure slice_2d - module procedure slice_3d - module procedure slice_4d - module procedure slice_5d - module procedure slice_6d - module procedure slice_7d - end interface - -contains - - ! ***************************************************** - ! Initialization and cleanup routines - ! ***************************************************** - subroutine initialize_comm_hdf_mod - implicit none - logical(lgt), save :: initialized = .false. - integer(i4b) :: status - if(initialized) return - call h5open_f(status) - call assert(status==0, 'comm_hdf_mod: Could not initialize hdf module') - initialized = .true. - end subroutine initialize_comm_hdf_mod - - subroutine cleanup_comm_hdf_mod - implicit none - integer(i4b) :: status - call h5close_f(status) - call assert(status==0, 'comm_hdf_mod: Could not close hdf module') - end subroutine cleanup_comm_hdf_mod - - subroutine copy_hdf_struct(file_in, file_out) - implicit none - type(hdf_file), intent(in) :: file_in - type(hdf_file), intent(out) :: file_out - - file_out%filename = file_in%filename - file_out%setname = file_in%setname - file_out%filehandle = file_in%filehandle - file_out%sethandle = file_in%sethandle - file_out%status = file_in%status - - end subroutine copy_hdf_struct - - - ! ***************************************************** - ! Basic file open and close routines - ! ***************************************************** - subroutine open_hdf_file(filename, file, mode) - implicit none - character(len=*), intent(in) :: filename - character(len=1), intent(in) :: mode - type(hdf_file) :: file - - ! Initialize - call initialize_comm_hdf_mod - - ! Open file in either read or write mode - file%filename = filename - file%status = 0 - if (mode == 'r') then - call h5fopen_f(file%filename, H5F_ACC_RDONLY_F, file%filehandle, file%status) - else if (mode == 'w') then - call h5fcreate_f(file%filename, H5F_ACC_TRUNC_F, file%filehandle, file%status) - else if (mode == 'b') then - call h5fopen_f(file%filename, H5F_ACC_RDWR_F, file%filehandle, file%status) - else - write(*,*) 'comm_hdf_mod: Unknown hdf file mode =', mode - stop - end if - - ! Initalize sethandle to empty value - file%setname = '' - file%sethandle = -1 - end subroutine open_hdf_file - - subroutine close_hdf_file(file) - implicit none - type(hdf_file) :: file - call close_hdf_set(file) - call h5fclose_f(file%filehandle, file%status) - call assert(file%status>=0, 'comm_hdf_mod: Could not close file') - end subroutine close_hdf_file - - subroutine open_hdf_set(file, setname) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - if (trim(file%setname) == trim(setname)) return - call close_hdf_set(file) - file%setname = setname - call h5dopen_f(file%filehandle, file%setname, file%sethandle, file%status) - end subroutine open_hdf_set - - subroutine close_hdf_set(file) - implicit none - type(hdf_file) :: file - if (file%sethandle == -1) return - call h5dclose_f(file%sethandle, file%status) - call assert(file%status>=0, 'comm_hdf_mod: Could not close set') - file%sethandle = -1 - file%setname = '' - end subroutine close_hdf_set - - ! ***************************************************** - ! Query operations - ! ***************************************************** - function get_rank_hdf(file, setname) result(rank) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) :: rank - integer(hid_t) :: space - call open_hdf_set(file, setname) - call h5dget_space_f(file%sethandle, space, file%status) - call h5sget_simple_extent_ndims_f(space, rank, file%status) - call h5sclose_f(space, file%status) - end function - - subroutine get_size_hdf(file, setname, ext) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(out) :: ext(:) - integer(i4b) :: rank - integer(hid_t) :: space, n - integer(hsize_t), allocatable, dimension(:) :: ext_hdf, mext_hdf - call open_hdf_set(file, setname) - call h5dget_space_f(file%sethandle, space, file%status) - call h5sget_simple_extent_ndims_f(space, rank, file%status) - allocate(ext_hdf(rank), mext_hdf(rank)) - call h5sget_simple_extent_dims_f(space, ext_hdf, mext_hdf, file%status) - call h5sclose_f(space, file%status) - n = min(size(ext),rank) - ext(:n) = int(ext_hdf(:n),i4b) - deallocate(ext_hdf, mext_hdf) - end subroutine get_size_hdf - -!!$ function hdf_group_exist(file, group) -!!$ implicit none -!!$ type(hdf_file) :: file -!!$ character(len=*), intent(in) :: group -!!$ type(hf -!!$ -!!$ -!!$ -!!$ end function hdf_group_exist - - ! ***************************************************** - ! Set read operations - ! ***************************************************** - - subroutine read_hdf_dp_2d_buffer(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - real(dp), dimension(:,:), intent(out) :: val - real(dp), dimension(:,:), allocatable :: buffer - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - return - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - call get_size_hdf(file, setname, ext) - allocate(buffer(ext(1),ext(2))) - ext2 = ext - ! Validate that sizes are consistent - !call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, buffer, ext2, file%status) - val = buffer(1:s(1),1:s(2)) - deallocate(buffer) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_int_2d_buffer(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - integer(i4b), dimension(:,:), intent(out) :: val - integer(i4b), dimension(:,:), allocatable :: buffer - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - return - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - call get_size_hdf(file, setname, ext) - allocate(buffer(ext(1),ext(2))) - ext2 = ext - ! Validate that sizes are consistent - !call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, buffer, ext2, file%status) - val = buffer(1:s(1),1:s(2)) - deallocate(buffer) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_0d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(0), ext2(0) - integer(i4b) :: ext(0) - real(dp) , intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_0d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(0), ext2(0) - integer(i4b) :: ext(0) - real(sp) , intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_0d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(0), ext2(0) - integer(i4b) :: ext(0) - integer(i4b) , intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_0d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(0), ext2(0) - integer(i4b) :: ext(0) - character(len=*) , intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_1d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(1), ext2(1) - integer(i4b) :: ext(1) - real(dp) ,dimension(:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_1d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(1), ext2(1) - integer(i4b) :: ext(1) - real(sp) ,dimension(:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_1d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(1), ext2(1) - integer(i4b) :: ext(1) - integer(i4b) ,dimension(:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_1d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(1), ext2(1) - integer(i4b) :: ext(1) - character(len=*) ,dimension(:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_2d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - real(dp) ,dimension(:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_2d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - real(sp) ,dimension(:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_2d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - integer(i4b) ,dimension(:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_2d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(2), ext2(2) - integer(i4b) :: ext(2) - character(len=*) ,dimension(:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_3d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(3), ext2(3) - integer(i4b) :: ext(3) - real(dp) ,dimension(:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_3d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(3), ext2(3) - integer(i4b) :: ext(3) - real(sp) ,dimension(:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_3d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(3), ext2(3) - integer(i4b) :: ext(3) - integer(i4b) ,dimension(:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_3d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(3), ext2(3) - integer(i4b) :: ext(3) - character(len=*) ,dimension(:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_4d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(4), ext2(4) - integer(i4b) :: ext(4) - real(dp) ,dimension(:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_4d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(4), ext2(4) - integer(i4b) :: ext(4) - real(sp) ,dimension(:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_4d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(4), ext2(4) - integer(i4b) :: ext(4) - integer(i4b) ,dimension(:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_4d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(4), ext2(4) - integer(i4b) :: ext(4) - character(len=*) ,dimension(:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_5d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(5), ext2(5) - integer(i4b) :: ext(5) - real(dp) ,dimension(:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_5d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(5), ext2(5) - integer(i4b) :: ext(5) - real(sp) ,dimension(:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_5d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(5), ext2(5) - integer(i4b) :: ext(5) - integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_5d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(5), ext2(5) - integer(i4b) :: ext(5) - character(len=*) ,dimension(:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_6d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(6), ext2(6) - integer(i4b) :: ext(6) - real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_6d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(6), ext2(6) - integer(i4b) :: ext(6) - real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_6d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(6), ext2(6) - integer(i4b) :: ext(6) - integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_6d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(6), ext2(6) - integer(i4b) :: ext(6) - character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_7d_dp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(7), ext2(7) - integer(i4b) :: ext(7) - real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_7d_sp(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(7), ext2(7) - integer(i4b) :: ext(7) - real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_7d_int(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(7), ext2(7) - integer(i4b) :: ext(7) - integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_hdf_7d_char(file, setname, val, opt) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - logical(lgt), intent(in), optional :: opt - TYPE(h5o_info_t) :: object_info - integer(i4b) :: hdferr, v(100) - integer(hsize_t) :: s(7), ext2(7) - integer(i4b) :: ext(7) - character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: val - logical(lgt) :: opt_ - - if(.not. present(opt)) then - opt_ = .false. - else - opt_ = opt - end if - call h5eset_auto_f(0, hdferr) - call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) - if (hdferr /= 0) then - if(.not. opt_) then - write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) - else - return - end if - end if - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_1d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:), allocatable, intent(out) :: val - integer(i4b) :: n(1) - integer(hsize_t) :: s(1) - integer(i4b) :: ext(1) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_1d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:), allocatable, intent(out) :: val - integer(i4b) :: n(1) - integer(hsize_t) :: s(1) - integer(i4b) :: ext(1) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_1d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:), allocatable, intent(out) :: val - integer(i4b) :: n(1) - integer(hsize_t) :: s(1) - integer(i4b) :: ext(1) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_1d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:), allocatable, intent(out) :: val - integer(i4b) :: n(1) - integer(hsize_t) :: s(1) - integer(i4b) :: ext(1) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_2d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:), allocatable, intent(out) :: val - integer(i4b) :: n(2) - integer(hsize_t) :: s(2) - integer(i4b) :: ext(2) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_2d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:), allocatable, intent(out) :: val - integer(i4b) :: n(2) - integer(hsize_t) :: s(2) - integer(i4b) :: ext(2) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_2d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:), allocatable, intent(out) :: val - integer(i4b) :: n(2) - integer(hsize_t) :: s(2) - integer(i4b) :: ext(2) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_2d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:), allocatable, intent(out) :: val - integer(i4b) :: n(2) - integer(hsize_t) :: s(2) - integer(i4b) :: ext(2) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_3d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(3) - integer(hsize_t) :: s(3) - integer(i4b) :: ext(3) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_3d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(3) - integer(hsize_t) :: s(3) - integer(i4b) :: ext(3) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_3d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(3) - integer(hsize_t) :: s(3) - integer(i4b) :: ext(3) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_3d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(3) - integer(hsize_t) :: s(3) - integer(i4b) :: ext(3) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_4d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(4) - integer(hsize_t) :: s(4) - integer(i4b) :: ext(4) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_4d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(4) - integer(hsize_t) :: s(4) - integer(i4b) :: ext(4) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_4d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(4) - integer(hsize_t) :: s(4) - integer(i4b) :: ext(4) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_4d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(4) - integer(hsize_t) :: s(4) - integer(i4b) :: ext(4) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_5d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(5) - integer(hsize_t) :: s(5) - integer(i4b) :: ext(5) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_5d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(5) - integer(hsize_t) :: s(5) - integer(i4b) :: ext(5) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_5d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(5) - integer(hsize_t) :: s(5) - integer(i4b) :: ext(5) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_5d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(5) - integer(hsize_t) :: s(5) - integer(i4b) :: ext(5) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_6d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(6) - integer(hsize_t) :: s(6) - integer(i4b) :: ext(6) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_6d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(6) - integer(hsize_t) :: s(6) - integer(i4b) :: ext(6) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_6d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(6) - integer(hsize_t) :: s(6) - integer(i4b) :: ext(6) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_6d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(6) - integer(hsize_t) :: s(6) - integer(i4b) :: ext(6) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_7d_dp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(dp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(7) - integer(hsize_t) :: s(7) - integer(i4b) :: ext(7) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_7d_sp(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - real(sp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(7) - integer(hsize_t) :: s(7) - integer(i4b) :: ext(7) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_7d_int(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(7) - integer(hsize_t) :: s(7) - integer(i4b) :: ext(7) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - subroutine read_alloc_hdf_7d_char(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val - integer(i4b) :: n(7) - integer(hsize_t) :: s(7) - integer(i4b) :: ext(7) - if(allocated(val)) deallocate(val) - call get_size_hdf(file, setname, n) - allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) - call open_hdf_set(file, setname) - s = int(shape(val)) - ! Validate that sizes are consistent - call get_size_hdf(file, setname, ext) - if (any(ext /= s)) then - write(*,*) 'HDF error -- inconsistent array sizes' - write(*,*) ' Filename = ', trim(file%filename) - write(*,*) ' Setname = ', trim(setname) - write(*,*) ' HDF size = ', ext - write(*,*) ' Requested size = ', int(s,i4b) - !write(*,*) opt_, 'Optional parameter' - end if - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) - end subroutine - - - subroutine read_hdf_opaque(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - byte, allocatable, dimension(:), target, intent(out) :: val - !byte, dimension(:), pointer, intent(out) :: val - - integer(hid_t) :: dtype - integer(size_t) :: len, numint - type(c_ptr) :: f_ptr - call open_hdf_set(file, setname) - call h5dget_type_f(file%sethandle, dtype, file%status) - call h5tget_size_f(dtype, len, file%status) - numint = len - allocate(val(numint)) - f_ptr = c_loc(val) - call h5dread_f(file%sethandle, dtype, f_ptr, file%status) - call h5tclose_f(dtype, file%status) - end subroutine read_hdf_opaque - - subroutine read_hdf_vlen(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - type(byte_pointer), dimension(:), intent(inout) :: val - - INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles - INTEGER :: hdferr - INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims - INTEGER :: i, j - integer, dimension(:), pointer :: ptr_r - - ! vl data - TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures - TYPE(C_PTR) :: f_ptr - !type(byte_pointer), allocatable, dimension(:) :: r_ptr - byte, pointer, dimension(:) :: r_ptr - - call open_hdf_set(file, setname) - call h5dget_type_f(file%sethandle, filetype, hdferr) - CALL h5dget_space_f(file%sethandle, space, hdferr) - - CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) - - allocate(rdata(dims(1))) - - CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) - ! Get address of the C pointer corresponding - ! to the first element of our data - f_ptr = C_LOC(rdata(1)) - CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) - ! - ! Write the variable-length data to the fortran array - ! - allocate(r_ptr(dims(1))) - DO i = 1, dims(1) - !WRITE(*,'(A,"(",I0,"):",/,"{")', ADVANCE="no") setname,i - !CALL c_f_pointer(rdata(i)%p, r_ptr(i)%p, [rdata(i)%len] ) - CALL c_f_pointer(rdata(i)%p, r_ptr, [rdata(i)%len] ) - !allocate(val(i)%p(size(r_ptr(i)%p))) - allocate(val(i)%p(size(r_ptr))) - !val(i)%p(:) = r_ptr(i)%p(:) - val(i)%p(:) = r_ptr - - !DO j = 1, rdata(i)%len - ! WRITE(*,'(1X,I0)', ADVANCE='no') val(i)%p(j) - ! IF ( j .LT. rdata(i)%len) WRITE(*,'(",")', ADVANCE='no') - !ENDDO - !WRITE(*,'( " }")') - - ENDDO - ! - ! Close and release resources. Note the use of H5Dvlen_reclaim - ! removes the need to manually deallocate the previously allocated - ! data. - ! - ! Not clear if this line is good or not. It could be de-allocating the read - ! memory that we are now pointing to, but I am not sure - CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) - CALL h5dclose_f(dset , hdferr) - CALL h5sclose_f(space, hdferr) - CALL h5tclose_f(filetype, hdferr) - call close_hdf_set(file) - CALL h5tclose_f(memtype, hdferr) - !deallocate(r_ptr, rdata) - deallocate(rdata) - ! deallocate(rdata) - - end subroutine read_hdf_vlen - - subroutine get_hdf_vlen_ext(file, setname, ext) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), dimension(:), intent(out) :: ext - - INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles - INTEGER :: hdferr - INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims - INTEGER :: i, j - integer, dimension(:), pointer :: ptr_r - - ! vl data - TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures - TYPE(C_PTR) :: f_ptr - - call open_hdf_set(file, setname) - call h5dget_type_f(file%sethandle, filetype, hdferr) - CALL h5dget_space_f(file%sethandle, space, hdferr) - CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) - - allocate(rdata(dims(1))) - CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) - f_ptr = C_LOC(rdata(1)) - CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) - ext(:) = rdata(:)%len - - CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) - CALL h5dclose_f(dset , hdferr) - CALL h5sclose_f(space, hdferr) - CALL h5tclose_f(filetype, hdferr) - call close_hdf_set(file) - CALL h5tclose_f(memtype, hdferr) - deallocate(rdata) - - end subroutine get_hdf_vlen_ext - - subroutine read_hdf_string(file, setname, val) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*), intent(out) :: val - - integer(i4b), parameter :: mlen=10000 - integer(hid_t) :: filetype, space - integer(size_t), dimension(1) :: len - integer(hsize_t), dimension(1:2) :: data_dims - integer :: hdferr - character(mlen), allocatable, dimension(:) :: rdata - - call open_hdf_set(file, setname) - CALL H5Dget_type_f(file%sethandle, filetype, hdferr) - CALL H5Dget_space_f(file%sethandle, space, hdferr) - ALLOCATE(rdata(1)) - len=mlen - data_dims = [mlen,1] - CALL h5dread_vl_f(file%sethandle, filetype, rdata, data_dims, len, hdferr, space) - val = rdata(1) - DEALLOCATE(rdata) - call close_hdf_set(file) - CALL h5sclose_f(space, hdferr) - CALL H5Tclose_f(filetype, hdferr) - - end subroutine read_hdf_string - - - subroutine read_hdf_string2(file, setname, val, n) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - character(len=*), intent(out) :: val - integer(i4b), intent(out) :: n - - integer(i4b), parameter :: mlen=100000 - integer(hid_t) :: filetype, space - INTEGER(SIZE_T) :: size - !integer(size_t), dimension(1) :: len - !integer(hsize_t), dimension(1:2) :: data_dims - INTEGER(HSIZE_T), DIMENSION(1:1) :: dims = (/mlen/) - INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims - integer :: hdferr - !character(len=mlen), dimension(1) :: rdata - character(len=mlen) :: rdata - - call open_hdf_set(file, setname) - CALL H5Dget_type_f(file%sethandle, filetype, hdferr) - CALL H5Tget_size_f(filetype, size, hdferr) - CALL H5Dget_space_f(file%sethandle, space, hdferr) - CALL H5Sget_simple_extent_dims_f(space, dims, maxdims, hdferr) - - call h5dread_f(file%sethandle, filetype, rdata, dims, hdferr, H5S_ALL_F, H5S_ALL_F, H5P_DEFAULT_F) - val = rdata(1:size) - n = int(size,i4b) - - call close_hdf_set(file) - CALL h5sclose_f(space, hdferr) - CALL H5Tclose_f(filetype, hdferr) - - end subroutine read_hdf_string2 - - ! ***************************************************** - ! Set write operations - ! ***************************************************** - - subroutine write_hdf_0d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) , intent(in) :: val - real(dp), allocatable :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_0d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) , intent(in) :: val - real(sp), allocatable :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_0d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) , intent(in) :: val - integer(i4b), allocatable :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_0d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) , intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_1d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:), intent(in) :: val - real(dp), allocatable ,dimension(:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_1d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:), intent(in) :: val - real(sp), allocatable ,dimension(:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_1d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:), intent(in) :: val - integer(i4b), allocatable ,dimension(:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_1d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_2d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_2d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_2d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_2d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_3d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_3d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_3d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_3d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_4d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:,:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_4d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:,:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_4d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:,:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_4d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:,:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_5d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:,:,:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_5d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:,:,:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_5d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_5d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:,:,:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_6d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_6d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_6d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_6d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - subroutine write_hdf_7d_dp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val - real(dp), allocatable ,dimension(:,:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_7d_sp(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val - real(sp), allocatable ,dimension(:,:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_7d_int(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: i - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: val - integer(i4b), allocatable ,dimension(:,:,:,:,:,:,:) :: v - - allocate(ext_hdf(size(shape(val)))) - allocate(v, source=val) - ext_hdf = int(shape(val), hsize_t) - - call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf, v) - - end subroutine - - subroutine write_hdf_7d_char(file, setname, val) - - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: val - integer(hid_t) :: str_dtype - integer :: hdferr - - allocate(ext_hdf(size(shape(val)))) - ext_hdf = int(shape(val), hsize_t) - - call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) - call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) - - call create_hdf_set(file, setname, shape(val), str_dtype) - call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") - deallocate(ext_hdf) - - end subroutine - - - ! ***************************************************** - ! Sliced set operations. - ! These are like read/write, but the dataset is - ! indexed with a slice. Note that the dataset must - ! exist beforehand. Use create_hdf_set for this. - ! ***************************************************** - - subroutine read_hdf_slice_0d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) , intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_0d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) , intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_0d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) , intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_0d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) , intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_1d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_1d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_1d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_1d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_2d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_2d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_2d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_2d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_3d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_3d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_3d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_3d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_4d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_4d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_4d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_4d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_5d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_5d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_5d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_5d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_6d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_6d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_6d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_6d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_7d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_7d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_7d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine read_hdf_slice_7d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_0d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) , intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_0d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) , intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_0d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) , intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_0d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) , intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(0) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_1d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_1d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_1d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_1d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(1) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_2d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_2d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_2d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_2d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(2) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_3d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_3d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_3d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_3d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(3) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_4d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_4d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_4d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_4d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(4) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_5d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_5d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_5d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_5d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(5) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_6d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_6d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_6d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_6d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(6) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_7d_dp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_7d_sp(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_7d_int(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - subroutine write_hdf_slice_7d_char(file, setname, slice, arr) - implicit none - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), intent(in) :: slice(:,:) - character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr - integer(hid_t) :: dspace, mspace - integer(i4b), allocatable :: ext(:) - integer(hsize_t) :: hslice(3,size(slice,2)) - integer(hsize_t) :: s(7) - ! Set up data spaces for memory and disk - s = int(shape(arr)) - call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) - call open_hdf_set(file, setname) - allocate(ext(get_rank_hdf(file, setname))) - call get_size_hdf(file, setname, ext) - call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) - ! Specify the slice - hslice = int(parse_hdf_slice(slice, ext),hsize_t) - call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & - & file%status, stride=hslice(3,:)) - call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & - & file%status, file_space_id=dspace, mem_space_id=mspace) - call h5sclose_f(dspace, file%status) - call h5sclose_f(mspace, file%status) - deallocate(ext) - end subroutine - - - ! ***************************************************** - ! Optional Reads - ! ***************************************************** - - - ! ***************************************************** - ! Dataset creation operation - ! ***************************************************** - subroutine create_hdf_set(file, setname, ext, type_id) - implicit none - - type(hdf_file) :: file - character(len=*), intent(in) :: setname - integer(i4b), dimension(:), intent(in) :: ext - integer(hid_t) :: type_id - integer(hid_t) :: space - integer(hsize_t), allocatable, dimension(:) :: ext_hdf - if (trim(file%setname) /= trim(setname)) call close_hdf_set(file) - !write(*,*) trim(file%setname), trim(setname) - file%setname = setname - allocate(ext_hdf(size(shape(ext)))) - ext_hdf = int(ext, hsize_t) - call h5screate_simple_f(size(ext), ext_hdf, space, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot create data space, "//trim(file%filename)//', '//trim(setname)) - !write(*,*) trim(file%setname), type_id, space, file%sethandle, file%status, ext - call h5dcreate_f(file%filehandle, file%setname, type_id, space, file%sethandle, file%status) - !write(*,*) ' HDF status = ', file%status - !call h5eprint_f(file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot create data set "//trim(file%filename)//', '//trim(setname)) - call h5sclose_f(space, file%status) - call assert(file%status>=0, "comm_hdf_mod: Cannot close data space") - deallocate(ext_hdf) - end subroutine create_hdf_set - - ! Group creation. Once created, they can be used by specifying "group/dset" instead - ! of just "dset". - subroutine create_hdf_group(file, group) - implicit none - type(hdf_file) :: file - character(len=*) :: group - integer(hid_t) :: gid - call h5gcreate_f(file%filehandle, group, gid, file%status) - call h5gclose_f(gid, file%status) - end subroutine - - ! ********************** - ! Helper functions - ! ********************** - - function slice_0d() result(res) - implicit none - integer(i4b) :: res(3,0) - res = 0 - end function - - function slice_1d(s0) result(res) - implicit none - integer(i4b), dimension(:) :: s0(:) - integer(i4b) :: res(3,1) - select case(size(s0)) - case(0); res(:,1) = [1,-1,1] - case(1); res(:,1) = [s0(1),s0(1),1] - case(2); res(:,1) = [s0(1),s0(2),1] - case(3:); res(:,1) = s0 - end select - end function - - function slice_2d(s0,s1) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1 - integer(i4b) :: res(3,2) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - end function - - function slice_3d(s0,s1,s2) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1,s2 - integer(i4b) :: res(3,3) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - res(:,3:3) = slice_1d(s2) - end function - - function slice_4d(s0,s1,s2,s3) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1,s2,s3 - integer(i4b) :: res(3,4) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - res(:,3:3) = slice_1d(s2) - res(:,4:4) = slice_1d(s3) - end function - - function slice_5d(s0,s1,s2,s3,s4) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1,s2,s3,s4 - integer(i4b) :: res(3,5) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - res(:,3:3) = slice_1d(s2) - res(:,4:4) = slice_1d(s3) - res(:,5:5) = slice_1d(s4) - end function - - function slice_6d(s0,s1,s2,s3,s4,s5) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5 - integer(i4b) :: res(3,6) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - res(:,3:3) = slice_1d(s2) - res(:,4:4) = slice_1d(s3) - res(:,5:5) = slice_1d(s4) - res(:,6:6) = slice_1d(s5) - end function - - function slice_7d(s0,s1,s2,s3,s4,s5,s6) result(res) - implicit none - integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5,s6 - integer(i4b) :: res(3,7) - res(:,1:1) = slice_1d(s0) - res(:,2:2) = slice_1d(s1) - res(:,3:3) = slice_1d(s2) - res(:,4:4) = slice_1d(s3) - res(:,5:5) = slice_1d(s4) - res(:,6:6) = slice_1d(s5) - res(:,7:7) = slice_1d(s6) - end function - - function parse_hdf_slice(slice, ext) result(hslice) - implicit none - integer(i4b), intent(in) :: slice(:,:), ext(:) - integer(i4b) :: hslice(3,size(slice,2)) - hslice = slice - ! Negative indices count from the end, with -1 being the last valid index - where(hslice([1,2],:) < 0) hslice([1,2],:) = hslice([1,2],:) + spread(ext,1,2) + 1 - ! We need to translate "to" into "count" - hslice(2,:) = (hslice(2,:)-hslice(1,:)+hslice(3,:))/hslice(3,:) - ! 0 based - hslice(1,:) = hslice(1,:) - 1 - end function - -end module comm_hdf_mod - diff --git a/install_ita.sh b/install_ita.sh index cd8a3a2fb..48ee62ec5 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -119,7 +119,7 @@ then # Unloading any loaded module module purge # Loading GNU Autotools (autoconf, libtool, automake etc.), GIT and CMake - module load gnu git/2.30.1 cmake/3.21.1 + module load git cmake # Choosing which compiler toolchain to use if [[ "$toolchain" =~ "intel" ]] then @@ -145,9 +145,7 @@ then mpicc="mpiicc" mpicxx="mpiicpc" printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" - module load intel/oneapi - module load intel/oneapi mpi/latest icc/latest compiler-rt/latest - module load mkl/latest + module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 elif [[ "$toolchain" =~ "gnu" ]] then # Compilers @@ -226,7 +224,7 @@ then -DCFITSIO_USE_CURL:BOOL=OFF \ -DUSE_SYSTEM_FFTW:BOOL=OFF \ -DUSE_SYSTEM_CFITSIO:BOOL=OFF \ - -DUSE_SYSTEM_HDF5:BOOL=ON \ + -DUSE_SYSTEM_HDF5:BOOL=OFF \ -DUSE_SYSTEM_HEALPIX:BOOL=OFF \ -DUSE_SYSTEM_BLAS:BOOL=ON \ -S $comm3_root_dir -B $abs_path_to_build From 9c5af5e63413f79830781c9cb0064de66cbb4651 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 8 May 2024 06:37:12 +0200 Subject: [PATCH 018/171] Fixed scaling reset bug, disabled old-style specind sampling --- commander3/src/comm_chisq_mod.f90 | 6 ++++++ commander3/src/comm_mh_specind_mod.f90 | 20 ++++++++++++++++++++ commander3/src/comm_zodi_mod.f90 | 2 +- commander3/src/comm_zodi_samp_mod.f90 | 2 +- commander3/src/commander.f90 | 2 +- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_chisq_mod.f90 b/commander3/src/comm_chisq_mod.f90 index 7663c0e8d..6fb1b141e 100644 --- a/commander3/src/comm_chisq_mod.f90 +++ b/commander3/src/comm_chisq_mod.f90 @@ -98,6 +98,11 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ res%map = res%map * mask(i)%p%map else if (present(maskpath)) then mask_tmp => comm_map(data(i)%info, trim(maskpath), udgrade=.true.) + where(mask_tmp%map < 0.5d0) + mask_tmp%map = 0.d0 + elsewhere + mask_tmp%map = 1.d0 + end where res%map = res%map * mask_tmp%map call mask_tmp%dealloc(); deallocate(mask_tmp) end if @@ -140,6 +145,7 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ chisq_fullsky = chisq_fullsky + sum(res_lowres%map) else chisq_fullsky = chisq_fullsky + sum(res%map) + !write(*,*) trim(data(i)%label), sum(res%map), chisq_fullsky end if end if diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 2f8052821..aca04a7f8 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -283,6 +283,26 @@ subroutine sample_template_mh(outdir, cpar, handle, handle_noise, l) write(*,*) '| ' end if + i = 0 + c => compList + do while (associated(c)) + if (c%scale_sigma(l) > 0d0) then + i = i + 1 + select type(c) + class is (comm_diffuse_comp) + c%x%alm = c%x%alm/scales(i) + !call c%x%Y + class is (comm_template_comp) + c%T%map = c%T%map/scales(i) + class default + write(*,*) "You have not set behavior for class ", trim(c%class) + stop + end select + end if + c => c%nextComp() + end do + + ! Instead of doing compsep, revert the amplitudes here if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 0604be026..7630fbc75 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -165,7 +165,7 @@ subroutine initialize_zodi_mod(cpar) zodi_model%par_labels(ind:ind+zodi_model%comps(i)%npar-1) = & & zodi_model%comps(i)%labels do j = ind, ind+zodi_model%comps(i)%npar-1 - zodi_model%par_labels(j) = & + zodi_model%par_labels_full(j) = & & trim(zodi_model%comp_labels(i))//':'//trim(zodi_model%par_labels(j)) end do diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index dfa3d2dab..9054a5d53 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -1167,7 +1167,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) filename = trim(cpar%outdir)//'/zodi_powell_sg'//sgroup//'_k'//iter_string//'.dat' unit = getlun() open(unit, file=trim(filename), recl=10000) - write(unit, '(a)', advance="no") "# " + write(unit, '(a)', advance="no") "# chisq_red " do i = 1, zodi_model%npar_tot if (zodi_model%theta_stat(i,samp_group)==0) then write(unit, "(a,a)", advance="no") trim(adjustl(zodi_model%par_labels_full(i))), " " diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index f9a18b0ac..6fb4e969d 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -417,7 +417,7 @@ program commander ! Sample non-linear parameters - if (iter > 1 .and. cpar%sample_specind) then + if (.false. .and. iter > 1 .and. cpar%sample_specind) then call timer%start(TOT_SPECIND) call sample_nonlin_params(cpar, iter, handle, handle_noise) call timer%stop(TOT_SPECIND) From 0de6a8d86d92d986d2c141de00c6b464f5181ddf Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 8 May 2024 06:48:26 +0200 Subject: [PATCH 019/171] Enabled old-style specind sampling again --- commander3/src/commander.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 6fb4e969d..f9a18b0ac 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -417,7 +417,7 @@ program commander ! Sample non-linear parameters - if (.false. .and. iter > 1 .and. cpar%sample_specind) then + if (iter > 1 .and. cpar%sample_specind) then call timer%start(TOT_SPECIND) call sample_nonlin_params(cpar, iter, handle, handle_noise) call timer%stop(TOT_SPECIND) From 78d20df86f07a7af9bf73329e5eee7ed265d0f50 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 8 May 2024 08:13:18 +0200 Subject: [PATCH 020/171] Revert "Segfault appearing in initialize_data_mod somehow" This reverts commit 4f6c64a183594b2daa5abda56bf3a69cee7f1ec8. --- commander3/src/comm_cr_mod.f90 | 5 +++++ commander3/src/comm_data_mod.f90 | 2 +- commander3/src/comm_mh_specind_mod.f90 | 15 ++++----------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/commander3/src/comm_cr_mod.f90 b/commander3/src/comm_cr_mod.f90 index f3de77661..3b43b822f 100644 --- a/commander3/src/comm_cr_mod.f90 +++ b/commander3/src/comm_cr_mod.f90 @@ -741,6 +741,7 @@ function cr_matmulA(x, samp_group) !call update_status(status, "A1") allocate(y(ncr), sqrtS_x(ncr)) y = 0.d0 + myid = data(1)%map%info%myid ! Multiply with sqrt(S) call wall_time(t1) @@ -789,6 +790,8 @@ function cr_matmulA(x, samp_group) c => c%nextComp() end do call wall_time(t2) + !if (myid == 0) write(*,fmt='(a,f8.2)') 'sqrtS time = ', real(t2-t1,sp) + !write(*,*) 'df3' ! Add frequency dependent terms @@ -865,6 +868,7 @@ function cr_matmulA(x, samp_group) !call update_status(status, "A11") !write(*,*) 'c', sum(abs(pmap%map)) call wall_time(t2) + !if (myid == 0) !write(*,fmt='(a,f8.2)') 'getBand time = ', real(t2-t1,sp) !write(*,*) 'df5' ! Multiply with invN @@ -872,6 +876,7 @@ function cr_matmulA(x, samp_group) call data(i)%N%InvN(map, samp_group=samp_group) call wall_time(t2) !call update_status(status, "A12") + !if (myid == 0) write(*,fmt='(a,f8.2)') 'invN time = ', real(t2-t1,sp) ! Project summed map into components, ie., row-wise matrix elements call wall_time(t1) diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index fdf405543..05ad1f1a0 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -38,7 +38,6 @@ module comm_data_mod real(dp) :: gain, gain_tmp, gain_prior(2) real(dp), allocatable, dimension(:) :: gain_sigmas character(len=128) :: gain_comp - character(len=128) :: rescale_comp integer(i4b) :: gain_lmin, gain_lmax integer(i4b) :: ndet character(len=128) :: tod_type @@ -123,6 +122,7 @@ subroutine initialize_data_mod(cpar, handle) data(n)%noise_format = cpar%ds_noise_format(i) allocate(data(n)%gain_stat(cpar%mcmc_num_user_samp_groups)) + data(n)%gain_stat = 0 if (cpar%myid == 0 .and. cpar%verbosity > 0) & diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 9064a5f24..aca04a7f8 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -828,9 +828,7 @@ subroutine initialize_mh_mod(cpar) ! Initializing, allocating all gain proposal lengths do i = 1, numband allocate(data(i)%gain_sigmas(cpar%mcmc_num_user_samp_groups)) - !allocate(data(i)%rescale_comp(cpar%mcmc_num_user_samp_groups)) data(i)%gain_sigmas = 0d0 - !data(i)%rescale_comp = '' end do do i = 1, cpar%mcmc_num_user_samp_groups @@ -863,16 +861,13 @@ subroutine initialize_mh_mod(cpar) else if (n == 1) then + call get_tokens(tokens(j), '%', comp_tokens) + read(comp_tokens(2), *) sigma call get_tokens(comp_tokens(1), ':', comp_names) - - if (comp_names(1)(1:7) == 'rescale') then - write(*,*) comp_tokens(1) - stop - else if (trim(comp_names(1)) == 'gain') then - call get_tokens(tokens(j), '%', comp_tokens) - read(comp_tokens(2), *) sigma + + if (trim(comp_names(1)) == 'gain') then do k = 1, numband if (trim(comp_names(2)) .eq. trim(data(k)%label)) then data(k)%gain_sigmas(i) = sigma @@ -880,8 +875,6 @@ subroutine initialize_mh_mod(cpar) end do else if (trim(comp_names(2)) == 'scale') then - call get_tokens(tokens(j), '%', comp_tokens) - read(comp_tokens(2), *) sigma c => compList do while (associated(c)) From 535cbc430c66e250cb4cbb19cb0cd08e916499d0 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 16 May 2024 14:23:25 +0200 Subject: [PATCH 021/171] now outputs template scaling amplitude to chains file if it is used --- commander3/src/comm_diffuse_comp_mod.f90 | 1 + commander3/src/comm_diffuse_comp_smod.f90 | 5 +++++ commander3/src/comm_hdf_mod.f90 | 2 +- commander3/src/comm_mh_specind_mod.f90 | 2 ++ commander3/src/comm_template_comp_mod.f90 | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_diffuse_comp_mod.f90 b/commander3/src/comm_diffuse_comp_mod.f90 index df114bfdf..f98568002 100644 --- a/commander3/src/comm_diffuse_comp_mod.f90 +++ b/commander3/src/comm_diffuse_comp_mod.f90 @@ -97,6 +97,7 @@ module comm_diffuse_comp_mod ! only interfaces in this file, accompanying smod.f class(comm_map), pointer :: defmask => null() class(comm_map), pointer :: priormask => null() class(comm_map), pointer :: x => null() ! Spatial parameters + real(dp) :: x_scale !overall scaling parameter for component class(comm_map), pointer :: x_smooth => null() ! Spatial parameters class(comm_map), pointer :: mu => null() ! Spatial prior mean class(comm_B), pointer :: B_out => null() ! Output beam diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index c034349f9..430329cee 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -86,6 +86,7 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%apply_jeffreys = .false. self%sample_first_niter = cpar%cs_local_burn_in self%output_localsamp_maps = cpar%cs_output_localsamp_maps + self%x_scale = 1.d0 only_pol = cpar%only_pol only_I = cpar%only_I @@ -2507,6 +2508,10 @@ module subroutine dumpDiffuseToFITS(self, iter, chainfile, output_hdf, postfix, !write(*,*) 'path2', trim(path)//'/amp_' call map%writeFITS(trim(dir)//'/'//trim(filename), & & hdffile=chainfile, hdfpath=trim(path)//'/amp_', output_hdf_map=.false.) + !if we have set the overall scale parameter + if (self%x_scale /= 1.d0 .and. self%myid == 0) then + call write_hdf(chainfile, trim(path)//'/x_scale', self%x_scale) + end if else call map%writeFITS(trim(dir)//'/'//trim(filename)) end if diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index 949a68dcf..82446a1f6 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -304,7 +304,7 @@ subroutine close_hdf_set(file) type(hdf_file) :: file if (file%sethandle == -1) return call h5dclose_f(file%sethandle, file%status) - call assert(file%status>=0, 'comm_hdf_mod: Could not close set') + call assert(file%status>=0, 'comm_hdf_mod: Could not close set' // file%setname // ' in ' // file%filename) file%sethandle = -1 file%setname = '' end subroutine close_hdf_set diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index aca04a7f8..e7a230dba 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -243,9 +243,11 @@ subroutine sample_template_mh(outdir, cpar, handle, handle_noise, l) select type(c) class is (comm_diffuse_comp) c%x%alm = c%x%alm*scales(i) + c%x_scale = c%x_scale * scales(i) !call c%x%Y class is (comm_template_comp) c%T%map = c%T%map*scales(i) + c%T_scale = c%T_scale * scales(i) class default write(*,*) "You have not set behavior for class ", trim(c%class) stop diff --git a/commander3/src/comm_template_comp_mod.f90 b/commander3/src/comm_template_comp_mod.f90 index 078449ba1..ec3729462 100644 --- a/commander3/src/comm_template_comp_mod.f90 +++ b/commander3/src/comm_template_comp_mod.f90 @@ -52,6 +52,7 @@ module comm_template_comp_mod real(dp), dimension(2) :: P ! Gaussian prior on amplitude (mean,sigma) real(dp), dimension(2) :: P_cg ! Gaussian prior on amplitude for CG (mean,sigma) class(comm_map), pointer :: T => null() ! Template + real(dp) :: T_scale ! overall scaling amplitude for the template class(comm_map), pointer :: mask => null() ! Template mask contains procedure :: dumpFITS => dumpTemplateToFITS @@ -112,6 +113,7 @@ function constructor_template(cpar, id, id_abs, mu, rms, def, band, label, mapfi c%comm = cpar%comm_chain c%numprocs = cpar%numprocs_chain c%P = [mu,rms] + c%T_scale = 1.d0 npre = npre + 1 comm_pre = cpar%comm_chain myid_pre = cpar%myid_chain @@ -296,6 +298,9 @@ subroutine dumpTemplateToFITS(self, iter, chainfile, output_hdf, postfix, dir) call create_hdf_group(chainfile, trim(adjustl(path))) path = trim(adjustl(path))//'/'//trim(adjustl(data(self%band)%label)) call write_hdf(chainfile, trim(adjustl(path)), self%x) + if(self%T_scale /= 1.d0 .and. self%myid == 0) then + call write_hdf(chainfile, trim(adjustl(path)) // 'T_scale', self%T_scale) + end if end if end subroutine dumpTemplateToFITS From a127bb05ac9eff6324255bad9313a3bf5cc13988 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 24 Jun 2024 13:48:03 +0200 Subject: [PATCH 022/171] Changed random zodi initialization to use a fixed rms step length --- commander3/src/comm_zodi_comp_mod.f90 | 170 +++++++++++++------------- commander3/src/comm_zodi_mod.f90 | 35 +++--- commander3/src/comm_zodi_samp_mod.f90 | 7 +- commander3/src/commander.f90 | 6 +- 4 files changed, 113 insertions(+), 105 deletions(-) diff --git a/commander3/src/comm_zodi_comp_mod.f90 b/commander3/src/comm_zodi_comp_mod.f90 index d7df1b01b..7c24b6da1 100644 --- a/commander3/src/comm_zodi_comp_mod.f90 +++ b/commander3/src/comm_zodi_comp_mod.f90 @@ -44,7 +44,7 @@ subroutine prior_interface(self, start_ind, prior, scale) class(ZodiComponent), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale end subroutine prior_interface subroutine p2m_interface(self, x) @@ -191,30 +191,30 @@ subroutine init_cloud_priors_and_scales(self, start_ind, prior, scale) class(ZodiCloud), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 4.d-9] prior(:,start_ind+1) = [-30.d0, 30.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.03d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 0.3d0] prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 1d-3] prior(:,start_ind+4) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 0.8d-3] prior(:,start_ind+5) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 0.3d-3] ! Component-specific parameters prior(:,start_ind+6) = [1.d0, 2.d0, 1.34d0, -1.d0] ! alpha - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.02d0] prior(:,start_ind+7) = [3.d0, 5d0, 4.14d0, -1.d0] ! beta - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.05d0] prior(:,start_ind+8) = [0.3d0, 1.1d0, 0.942d0, -1.d0] ! gamma - scale(start_ind+8) = 1.d0 + scale(start_ind+8,:) = [1.d0, 0.03d0] prior(:,start_ind+9) = [0.1d0, 0.4d0, 0.189d0, -1.d0] ! mu - scale(start_ind+9) = 1.d0 + scale(start_ind+9,:) = [1.d0, 0.013d0] end subroutine init_cloud_priors_and_scales subroutine init_band_priors_and_scales(self, start_ind, prior, scale) @@ -222,30 +222,30 @@ subroutine init_band_priors_and_scales(self, start_ind, prior, scale) class(ZodiBand), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 0.2d-9] prior(:,start_ind+1) = [-30.d0, 30.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.05d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 - prior(:,start_ind+3) = [-0.3d0, 0.3d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 - prior(:,start_ind+4) = [-0.3d0, 0.3d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 - prior(:,start_ind+5) = [-0.3d0, 0.3d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+2,:) = [1.d0, 2.d0] + prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 + scale(start_ind+3,:) = [1.d0, 0.5d-3] + prior(:,start_ind+4) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Y_0 + scale(start_ind+4,:) = [1.d0, 0.2d-3] + prior(:,start_ind+5) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Z_0 + scale(start_ind+5,:) = [1.d0, 0.3d-3] ! Component-specific parameters prior(:,start_ind+6) = [0.d0, 30d0, 0d0, -1.d0] ! delta_zeta - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.14d0] prior(:,start_ind+7) = [0.8d0, 5.4d0, 4.14d0, -1.d0] ! delta_r - scale(start_ind+7) = 1.d0 - prior(:,start_ind+8) = [0.01d0, 2.5d0, 0.942d0, -1.d0] ! v - scale(start_ind+8) = 1.d0 - prior(:,start_ind+9) = [3.999d0, 4.001d0, 0.189d0, -1.d0] ! p - scale(start_ind+9) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.005d0] + prior(:,start_ind+8) = [0.01d0, 1.5d0, 0.942d0, -1.d0] ! v + scale(start_ind+8,:) = [1.d0, 0.1d0] + prior(:,start_ind+9) = [3.99999d0, 4.000001d0, 0.189d0, -1.d0] ! p + scale(start_ind+9,:) = [1.d0, 1d-6] end subroutine init_band_priors_and_scales subroutine init_ring_priors_and_scales(self, start_ind, prior, scale) @@ -253,32 +253,32 @@ subroutine init_ring_priors_and_scales(self, start_ind, prior, scale) class(ZodiRing), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 1.d-11] prior(:,start_ind+1) = [-30.d0, 30.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.1d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 1.d0] prior(:,start_ind+3) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 1d-3] prior(:,start_ind+4) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 1d-3] prior(:,start_ind+5) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 1d-3] ! Component-specific parameters prior(:,start_ind+6) = [0.9d0, 1.1d0, 0d0, -1.d0] ! r - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.01d0] prior(:,start_ind+7) = [0.d0, 0.3d0, 0.2d0, -1.d0] ! delta_r - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.01d0] prior(:,start_ind+8) = [0.0d0, 0.2d0, 0.1d0, -1.d0] ! delta_z - scale(start_ind+8) = 1.d0 + scale(start_ind+8,:) = [1.d0, 0.01d0] prior(:,start_ind+9) = [-60.d-3, 60.d-3, 0.d0, -1.d0] ! theta - scale(start_ind+9) = 1.d0 + scale(start_ind+9,:) = [1.d0, 0.01d0] prior(:,start_ind+10) = [0.d0, 30.d0, 0.d0, -1.d0] ! sigma_theta - scale(start_ind+10) = 1.d0 + scale(start_ind+10,:) = [1.d0, 0.01d0] end subroutine init_ring_priors_and_scales subroutine init_feature_priors_and_scales(self, start_ind, prior, scale) @@ -286,32 +286,32 @@ subroutine init_feature_priors_and_scales(self, start_ind, prior, scale) class(ZodiFeature), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 1.d-11] prior(:,start_ind+1) = [-30.d0, 30.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.1d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 1.d0] prior(:,start_ind+3) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 1d-3] prior(:,start_ind+4) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 1d-3] prior(:,start_ind+5) = [-0.001d0, 0.001d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 1d-3] ! Component-specific parameters prior(:,start_ind+6) = [0.9d0, 1.1d0, 0d0, -1.d0] ! r - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.01d0] prior(:,start_ind+7) = [0.d0, 0.3d0, 0.2d0, -1.d0] ! delta_r - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.01d0] prior(:,start_ind+8) = [0.0d0, 0.2d0, 0.1d0, -1.d0] ! delta_z - scale(start_ind+8) = 1.d0 + scale(start_ind+8,:) = [1.d0, 0.01d0] prior(:,start_ind+9) = [-20.d0, 20.d0, 0.d0, -1.d0] ! theta - scale(start_ind+9) = 1.d0 + scale(start_ind+9,:) = [1.d0, 0.01d0] prior(:,start_ind+10) = [0.d0, 30.d0, 0.d0, -1.d0] ! sigma_theta - scale(start_ind+10) = 1.d0 + scale(start_ind+10,:) = [1.d0, 0.01d0] end subroutine init_feature_priors_and_scales subroutine init_interstellar_priors_and_scales(self, start_ind, prior, scale) @@ -319,26 +319,26 @@ subroutine init_interstellar_priors_and_scales(self, start_ind, prior, scale) class(ZodiInterstellar), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 1.d-11] prior(:,start_ind+1) = [0.d0, 00.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.d0] prior(:,start_ind+2) = [0.d0, 0.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 0.d0] prior(:,start_ind+3) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 0.d0] prior(:,start_ind+4) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 0.d0] prior(:,start_ind+5) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 0.d0] ! Component-specific parameters prior(:,start_ind+6) = [0.d0, 0.0d0, 0d0, -1.d0] ! R, inactive - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.d0] prior(:,start_ind+7) = [0.d0, 0.0d0, 0.2d0, -1.d0] ! alpha, inactive - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.d0] end subroutine init_interstellar_priors_and_scales subroutine init_fan_priors_and_scales(self, start_ind, prior, scale) @@ -346,32 +346,32 @@ subroutine init_fan_priors_and_scales(self, start_ind, prior, scale) class(ZodiFan), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 + scale(start_ind+0,:) = [1.d-9, 1.d-11] prior(:,start_ind+1) = [0.d0, 10.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+1,:) = [1.d0, 0.d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 0.d0] prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 0.d0] prior(:,start_ind+4) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 0.d0] prior(:,start_ind+5) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 0.d0] ! Component-specific parameters prior(:,start_ind+6) = [5d0, 15d0, 0d0, -1.d0] ! Q - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.d0] prior(:,start_ind+7) = [1.d0, 3d0, 0.2d0, -1.d0] ! P - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.d0] prior(:,start_ind+8) = [0.5d0, 2d0, 0.1d0, -1.d0] ! Gamma - scale(start_ind+8) = 1.d0 + scale(start_ind+8,:) = [1.d0, 0.d0] prior(:,start_ind+9) = [0.d0, 0.3d0, 0.d0, -1.d0] ! Z - scale(start_ind+9) = 1.d0 + scale(start_ind+9,:) = [1.d0, 0.d0] prior(:,start_ind+10) = [1.d0, 5.d0, 0.d0, -1.d0] ! R_max - scale(start_ind+10) = 1.d0 + scale(start_ind+10,:) = [1.d0, 0.d0] end subroutine init_fan_priors_and_scales subroutine init_comet_priors_and_scales(self, start_ind, prior, scale) @@ -379,30 +379,30 @@ subroutine init_comet_priors_and_scales(self, start_ind, prior, scale) class(ZodiComet), intent(in) :: self integer(i4b), intent(in) :: start_ind real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 - scale(start_ind+0) = 1.d-9 - prior(:,start_ind+1) = [0.d0, 00.d0, 0.d0, -1.d0] ! Incl - scale(start_ind+1) = 1.d0 + scale(start_ind+0,:) = [1.d-9, 0.d0] + prior(:,start_ind+1) = [0.d0, 0.d0, 0.d0, -1.d0] ! Incl + scale(start_ind+1,:) = [1.d0, 0.d0] prior(:,start_ind+2) = [0.d0, 0.d0, 0.d0, -1.d0] ! Omega - scale(start_ind+2) = 1.d0 + scale(start_ind+2,:) = [1.d0, 0.d0] prior(:,start_ind+3) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! X_0 - scale(start_ind+3) = 1.d0 + scale(start_ind+3,:) = [1.d0, 0.d0] prior(:,start_ind+4) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Y_0 - scale(start_ind+4) = 1.d0 + scale(start_ind+4,:) = [1.d0, 0.d0] prior(:,start_ind+5) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Z_0 - scale(start_ind+5) = 1.d0 + scale(start_ind+5,:) = [1.d0, 0.d0] ! Component-specific parameters prior(:,start_ind+6) = [1d0, 5d0, 0d0, -1.d0] ! P - scale(start_ind+6) = 1.d0 + scale(start_ind+6,:) = [1.d0, 0.d0] prior(:,start_ind+7) = [0.d0, 0.3d0, 0.2d0, -1.d0] ! z_mid - scale(start_ind+7) = 1.d0 + scale(start_ind+7,:) = [1.d0, 0.d0] prior(:,start_ind+8) = [0.5d0, 1.5d0, 0.1d0, -1.d0] ! R_inner - scale(start_ind+8) = 1.d0 + scale(start_ind+8,:) = [1.d0, 0.d0] prior(:,start_ind+9) = [1.5d0, 5.d0, 0.d0, -1.d0] ! R_outer - scale(start_ind+9) = 1.d0 + scale(start_ind+9,:) = [1.d0, 0.d0] end subroutine init_comet_priors_and_scales subroutine param2model_cloud(self, x) diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 7630fbc75..041941d9d 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -33,7 +33,7 @@ module comm_zodi_mod logical(lgt), allocatable, dimension(:,:) :: sampgroup_active_band integer(i4b), allocatable, dimension(:) :: theta2band real(dp), allocatable, dimension(:,:) :: theta_prior - real(dp), allocatable, dimension(:) :: theta_scale + real(dp), allocatable, dimension(:,:) :: theta_scale ! Stationary model ! real(dp), allocatable, dimension(:) :: amp_static @@ -116,7 +116,7 @@ subroutine initialize_zodi_mod(cpar) allocate(zodi_model%theta_stat(zodi_model%npar_tot,0:cpar%zs_num_samp_groups)) allocate(zodi_model%theta2band(zodi_model%npar_tot)) allocate(zodi_model%theta_prior(4,zodi_model%npar_tot)) ! [min,max,mean,rms] - allocate(zodi_model%theta_scale(zodi_model%npar_tot)) + allocate(zodi_model%theta_scale(zodi_model%npar_tot,2)) allocate(zodi_model%par_labels(zodi_model%npar_tot)) allocate(zodi_model%par_labels_full(zodi_model%npar_tot)) @@ -173,21 +173,26 @@ subroutine initialize_zodi_mod(cpar) ind = zodi_model%comps(i)%start_ind + zodi_model%comps(i)%npar-1 do j = 1, numband zodi_model%theta_prior(:,ind+j) = [0.d0, 5.d0, 1.d0, -1.d0] ! Emissivity - zodi_model%theta_scale(ind+j) = 1.d0 + zodi_model%theta_scale(ind+j,:) = [1.d0,0.1d0] zodi_model%par_labels(ind+j) = 'em@'//trim(band_labels(j)) zodi_model%par_labels_full(ind+j) = trim(zodi_model%comp_labels(i))//':em@'//trim(band_labels(j)) zodi_model%theta_prior(:,ind+numband+j) = [0.d0, 1.d0, 0.3d0, -1.d0] ! Albedo - zodi_model%theta_scale(ind+numband+j) = 1.d0 + zodi_model%theta_scale(ind+numband+j,:) = [1.d0, 0.01d0] zodi_model%par_labels(ind+numband+j) = 'al@'//trim(band_labels(j)) zodi_model%par_labels_full(ind+numband+j) = trim(zodi_model%comp_labels(i))//':al@'//trim(band_labels(j)) + + ! Set DIRBE emissivity rms by hand + if (trim(band_instlabels(j)) == '06') zodi_model%theta_scale(ind+j,:) = [1.d0,0.01d0] + if (trim(band_instlabels(j)) == '07') zodi_model%theta_scale(ind+j,:) = [1.d0,0.02d0] + if (trim(band_instlabels(j)) == '08') zodi_model%theta_scale(ind+j,:) = [1.d0,0.03d0] end do end do ! Monopoles do j = 1, numband ind = zodi_model%npar_tot - numband + j zodi_model%theta_prior(:,ind) = [0.d0, 1d30, 0.d0, -1.d0] ! Priors - zodi_model%theta_scale(ind) = 1.d0 + zodi_model%theta_scale(ind,:) = [1.d0,0.01d0] zodi_model%par_labels(ind) = 'm@'//trim(band_labels(j)) zodi_model%par_labels_full(ind) = 'm@'//trim(band_labels(j)) end do @@ -259,12 +264,12 @@ subroutine init_general_priors_and_scales(self, prior, scale) implicit none class(ZodiModel), intent(in) :: self real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:), intent(inout) :: scale + real(dp), dimension(1:,1:), intent(inout) :: scale prior(:,1) = [250.d0, 300.d0, 286.d0, 5.d0] ! T_0 - scale(1) = 286.d0 + scale(1,:) = [286.d0, 3.d0] prior(:,2) = [0.4d0, 0.5d0, 0.467d0, 0.004d0] ! delta - scale(2) = 0.4d0 + scale(2,:) = [0.4d0, 0.01d0] end subroutine init_general_priors_and_scales @@ -866,6 +871,8 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) if (active(band) .and. band_todtype(band) /= 'none') then !ind = zodi_model%get_par_ind(mono_band=band) band_update_monopole(band,samp_group) = .true. + ind = zodi_model%get_par_ind(mono_band=band) + stat(ind) = 0 end if cycle else @@ -945,12 +952,12 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) end do ! Set up monopoles - do i = 1, numband - if (active(i) .and. band_todtype(i) /= 'none') then - ind = zodi_model%get_par_ind(mono_band=i) - stat(ind) = 0 - end if - end do +!!$ do i = 1, numband +!!$ if (active(i) .and. band_todtype(i) /= 'none') then +!!$ ind = zodi_model%get_par_ind(mono_band=i) +!!$ stat(ind) = 0 +!!$ end if +!!$ end do ! Apply explicit parameter wiring call get_tokens(cpar%zs_wiring, ',', tokens, n_params) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 9054a5d53..2403b949d 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -1177,7 +1177,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) end if ! Get chisq of old point - scale = pack(zodi_model%theta_scale, zodi_model%theta_stat(:,samp_group)==0) + scale = pack(zodi_model%theta_scale(:,1), zodi_model%theta_stat(:,samp_group)==0) call model_to_params(zodi_model, theta_old, samp_group) !!$ if (cpar%myid == cpar%root) then !!$ do i = 1, npar @@ -1222,7 +1222,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) if (chisq_new < chisq_old) then accept = .true. else - accept = rand_uni(handle) < exp(-0.5d0*(chisq_new-chisq_old)/0.1d0) + accept = rand_uni(handle) < exp(-0.5d0*(chisq_new-chisq_old)/0.02d0) end if if (accept) then ! Accept new point; update @@ -2188,7 +2188,8 @@ subroutine randomize_zodi_init(x, samp_group, cpar, handle, rms) do i = 1, zodi_model%npar_tot if (zodi_model%theta_stat(i,samp_group) == 0) then j = j+1 - x(j) = x(j) * (1.d0 + eps*rand_gauss(handle)) + x(j) = x(j) + eps*zodi_model%theta_scale(i,2)*rand_gauss(handle) + !x(j) = x(j) * (1.d0 + eps*rand_gauss(handle)) x(j) = max(x(j), zodi_model%theta_prior(1,i)) x(j) = min(x(j), zodi_model%theta_prior(2,i)) end if diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index f9a18b0ac..1182b7902 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -417,14 +417,14 @@ program commander ! Sample non-linear parameters - if (iter > 1 .and. cpar%sample_specind) then + if (iter > 3 .and. cpar%sample_specind) then call timer%start(TOT_SPECIND) call sample_nonlin_params(cpar, iter, handle, handle_noise) call timer%stop(TOT_SPECIND) end if !if (mod(iter,cpar%thinning) == 0) call output_FITS_sample(cpar, 100+iter, .true.) - if (iter > 1) then + if (iter > 3) then do i = 1, cpar%mcmc_num_samp_groups if (index(cpar%mcmc_samp_groups(i), 'gain:') .ne. 0) then if (cpar%myid == 0) write(*,*) '| MH sampling map-based gains' @@ -444,7 +444,7 @@ program commander ! Sample linear parameters with CG search; loop over CG sample groups !call output_FITS_sample(cpar, 1000+iter, .true.) - if (cpar%sample_signal_amplitudes) then + if (cpar%sample_signal_amplitudes .and. iter > 1) then ! Do CG group sampling call sample_all_amps_by_CG(cpar, handle, handle_noise) From 93d5d198723b5f945b983fe8875ffbb4d83e2a47 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 24 Jun 2024 15:21:44 +0200 Subject: [PATCH 023/171] Added dummy function for writing things out --- commander3/src/comm_tod_dirbe_mod.f90 | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index a7972c74d..393783576 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -39,6 +39,7 @@ module comm_tod_DIRBE_mod type, extends(comm_tod) :: comm_dirbe_tod contains procedure :: process_tod => process_DIRBE_tod + procedure :: dumpToHDF_inst => dumpToHDF_DIRBE end type comm_dirbe_tod interface comm_dirbe_tod @@ -160,6 +161,37 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) call timer%stop(TOD_INIT, id_abs) end function constructor_dirbe + + subroutine dumpToHDF_DIRBE(self, chainfile, path) + ! + ! Writes instrument-specific TOD parameters to existing chain file + ! + ! Arguments: + ! ---------- + ! self: derived class (comm_tod) + ! TOD object + ! chainfile: derived type (hdf_file) + ! Already open HDF file handle to existing chainfile + ! path: string + ! HDF path to current dataset, e.g., "000001/tod/030" + ! + ! Returns + ! ---------- + ! None + ! + implicit none + class(comm_dirbe_tod), intent(in) :: self + type(hdf_file), intent(in) :: chainfile + character(len=*), intent(in) :: path + + + if (self%myid == 0) then + write(*,*) 'Whoopydoopy', trim(path) + !call write_hdf(chainfile, trim(adjustl(path))//'1Hz_temp', self%spike_templates) + end if + + end subroutine dumpToHDF_DIRBE + !************************************************** ! Driver routine !************************************************** From 6470747a99fb9752134ff1364ef3f51478dbd8d8 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 24 Jun 2024 14:30:06 +0200 Subject: [PATCH 024/171] Updated to read in SED from existing chain --- commander3/src/comm_diffuse_comp_smod.f90 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 430329cee..0b9593bd5 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -2763,6 +2763,10 @@ module subroutine initDiffuseHDF(self, cpar, hdffile, hdfpath) if (l < self%lmin_amp) self%x%alm(i,:) = 0.d0 end do + if (trim(self%type) == 'MBBtab') then + call read_hdf(hdffile, trim(adjustl(path))//'/SED', self%SEDtab) + end if + do i = 1, self%npar call self%theta(i)%p%readHDF(hdffile, trim(path)//'/'//trim(adjustl(self%indlabel(i)))//& & '_map', .true.) @@ -2807,14 +2811,7 @@ module subroutine initDiffuseHDF(self, cpar, hdffile, hdfpath) end do call tp%dealloc(); deallocate(tp) end if - end if !lmax_ind > 0 - !if (trim(self%label) == 'dust' .and. i == 1) self%theta(i)%p%map(:,1) = 1.65d0 - !if (trim(self%label) == 'dust' .and. i == 2) self%theta(i)%p%map(:,1) = 18.d0 - !if (trim(self%label) == 'dust' .and. i > 1) self%theta(i)%p%map(:,1) = 1.6d0 - !if (trim(self%label) == 'dust' .and. i == 1) self%theta(i)%p%alm(:,:) = 1.65d0 * sqrt(4*pi) - !if (trim(self%label) == 'dust' .and. i == 2) self%theta(i)%p%alm(:,:) = 18 * sqrt(4*pi) - !if (trim(self%label) == 'synch' .and. i > 1) self%theta(i)%p%alm(:,:) = -3.11d0 * sqrt(4*pi) - !if (trim(self%label) == 'ame' .and. i == 1) self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) + 0.5d0*sqrt(4*pi) + end if !Need to initialize pixelregions and local sampler from chain as well (where relevant) npol=min(self%nmaps,self%poltype(i))!only concerned about the maps/poltypes in use @@ -2850,7 +2847,6 @@ module subroutine initDiffuseHDF(self, cpar, hdffile, hdfpath) end do !i = 1,npar end if - !if (trim(self%label) == 'dust') write(*,*) 'range beta = ', minval(self%theta(1)%p%map), maxval(self%theta(1)%p%map) call self%updateMixmat end subroutine initDiffuseHDF From 8083450460e5c85e3a7b491182a5753670df6096 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 24 Jun 2024 19:28:13 +0200 Subject: [PATCH 025/171] Added readin capability --- commander3/src/comm_tod_dirbe_mod.f90 | 5 +++-- commander3/src/comm_tod_mod.f90 | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 393783576..7beaf8f3a 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -186,8 +186,9 @@ subroutine dumpToHDF_DIRBE(self, chainfile, path) if (self%myid == 0) then - write(*,*) 'Whoopydoopy', trim(path) - !call write_hdf(chainfile, trim(adjustl(path))//'1Hz_temp', self%spike_templates) + if (self%map_solar_allocated == .true.) then + call write_hdf(chainfile, trim(adjustl(path))//'map_solar', self%map_solar) + end if end if end subroutine dumpToHDF_DIRBE diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 84b78fb30..f3bb8a399 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -1625,8 +1625,16 @@ subroutine initHDF(self, chainfile, iter, map, rms) call read_hdf(chainfile, trim(adjustl(path))//'gain_sigma_0', self%gain_sigma_0) call read_hdf(chainfile, trim(adjustl(path))//'gain_fknee', self%gain_fknee) call read_hdf(chainfile, trim(adjustl(path))//'gain_alpha', self%gain_alpha) + if (self%map_solar_allocated == .true.) then + if (hdf_group_exists(chainfile, trim(adjustl(path))//'map_solar')) then + call read_hdf(chainfile, trim(adjustl(path))//'map_solar', self%map_solar) + else + write(*,*) 'Solar map field not in existing chain, keeping default' + end if + end if end if + call mpi_bcast(output, size(output), MPI_DOUBLE_PRECISION, 0, & & self%comm, ierr) call mpi_bcast(self%bp_delta, size(self%bp_delta), MPI_DOUBLE_PRECISION, 0, & @@ -2984,7 +2992,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) ! call pix2vec_ring(self%nside, self%scans(scan)%d(det)%pix_sol(i,1), vec) ! elon = acos(min(max(vec(1),-1.d0),1.d0)) * 180.d0/pi ! The Sun is at (1,0,0) ! cut = cut .or. elon < self%sol_elong_range(1) .or. elon > self%sol_elong_range(2) - if (allocated(self%mask_solar)) then + if (allocated(self%mask_solar) .and. self%use_solar_point) then cut = cut .or. (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) end if From dd2979009d2471039968225cdf88eb1c9e117eee Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 1 Jul 2024 12:13:35 +0200 Subject: [PATCH 026/171] Disabled static component sampling --- commander3/src/commander.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 1182b7902..2efd39b17 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -378,7 +378,7 @@ program commander end select ! Sample stationary zodi components with 2D model - call sample_static_zodi_map(cpar, handle) + !call sample_static_zodi_map(cpar, handle) !call sample_static_zodi_amps(cpar, handle) !!$ if (mod(iter-2,10) == 0) then From 8b84f2fa992b0fe34611c6c02459176b4b1ac8dc Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 12 Jul 2024 12:13:30 +0200 Subject: [PATCH 027/171] Added FIRAS defaults, fixed line emission bug --- .../bands/FIRAS/FIRAS_H1510_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1523_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1537_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1550_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1564_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1673_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1686_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1700_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1714_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1727_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1741_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1754_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1768_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1782_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1795_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1822_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1836_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1850_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1863_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1877_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1931_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1945_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1958_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1972_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1986_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H1999_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2013_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2027_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2040_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2054_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2067_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2095_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2108_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2122_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2149_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2163_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2176_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2190_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2203_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2217_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2231_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2244_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2258_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2271_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2285_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2299_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2312_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2326_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2339_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2353_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2367_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2380_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2394_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2407_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2421_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2435_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2448_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2462_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2475_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2489_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2503_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2516_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2530_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2543_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2557_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2571_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2584_map.defaults | 45 +++++++++++++++++++ .../bands/FIRAS/FIRAS_H2598_map.defaults | 45 +++++++++++++++++++ commander3/src/comm_line_comp_mod.f90 | 2 +- 69 files changed, 3061 insertions(+), 1 deletion(-) create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1510_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1523_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1537_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1550_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1564_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1673_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1686_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1700_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1714_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1727_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1741_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1754_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1768_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1782_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1795_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1822_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1836_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1850_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1863_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1877_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1931_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1945_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1958_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1972_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1986_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1999_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2013_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2027_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2040_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2054_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2067_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2095_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2108_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2122_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2149_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2163_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2176_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2190_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2203_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2217_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2231_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2244_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2258_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2271_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2285_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2299_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2312_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2326_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2339_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2353_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2367_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2380_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2394_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2407_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2421_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2435_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2448_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2462_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2475_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2489_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2503_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2516_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2530_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2543_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2557_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2571_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2584_map.defaults create mode 100644 commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2598_map.defaults diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1510_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1510_map.defaults new file mode 100644 index 000000000..51ad3f208 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1510_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1510 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1510 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1510 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1510 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1510GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1510GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1510GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1523_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1523_map.defaults new file mode 100644 index 000000000..742d57c2b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1523_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1523 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1523 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1523 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1523 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1523GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1523GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1523GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1537_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1537_map.defaults new file mode 100644 index 000000000..74dc7746d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1537_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1537 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1537 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1537 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1537 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1537GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1537GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1537GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1550_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1550_map.defaults new file mode 100644 index 000000000..23d4f6f5a --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1550_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1550 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1550 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1550 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1550 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1550GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1550GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1550GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1564_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1564_map.defaults new file mode 100644 index 000000000..03fff18e1 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1564_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1564 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1564 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1564 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1564 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1564GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1564GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1564GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1673_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1673_map.defaults new file mode 100644 index 000000000..67c1806ea --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1673_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1673 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1673 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1673 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1673 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1673GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1673GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1673GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1686_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1686_map.defaults new file mode 100644 index 000000000..2cfe3acf1 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1686_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1686 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1686 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1686 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1686 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1686GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1686GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1686GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1700_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1700_map.defaults new file mode 100644 index 000000000..4f7cc5454 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1700_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1700 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1700 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1700 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1700 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1700GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1700GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1700GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1714_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1714_map.defaults new file mode 100644 index 000000000..a1d2aa0af --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1714_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1714 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1714 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1714 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1714 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1714GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1714GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1714GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1727_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1727_map.defaults new file mode 100644 index 000000000..04839217d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1727_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1727 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1727 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1727 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1727 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1727GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1727GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1727GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1741_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1741_map.defaults new file mode 100644 index 000000000..0a3be6a0d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1741_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1741 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1741 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1741 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1741 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1741GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1741GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1741GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1754_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1754_map.defaults new file mode 100644 index 000000000..7e4af2b36 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1754_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1754 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1754 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1754 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1754 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1754GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1754GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1754GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1768_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1768_map.defaults new file mode 100644 index 000000000..29396f4db --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1768_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1768 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1768 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1768 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1768 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1768GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1768GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1768GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1782_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1782_map.defaults new file mode 100644 index 000000000..af313a8c3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1782_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1782 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1782 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1782 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1782 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1782GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1782GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1782GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1795_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1795_map.defaults new file mode 100644 index 000000000..59973d658 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1795_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1795 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1795 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1795 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1795 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1795GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1795GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1795GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1822_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1822_map.defaults new file mode 100644 index 000000000..83283b534 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1822_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1822 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1822 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1822 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1822 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1822GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1822GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1822GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1836_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1836_map.defaults new file mode 100644 index 000000000..4b458f5e3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1836_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1836 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1836 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1836 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1836 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1836GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1836GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1836GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1850_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1850_map.defaults new file mode 100644 index 000000000..96fac3ffd --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1850_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1850 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1850 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1850 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1850 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1850GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1850GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1850GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1863_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1863_map.defaults new file mode 100644 index 000000000..45929201e --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1863_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1863 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1863 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1863 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1863 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1863GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1863GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1863GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1877_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1877_map.defaults new file mode 100644 index 000000000..381c81a49 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1877_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1877 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1877 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1877 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1877 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1877GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1877GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1877GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1931_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1931_map.defaults new file mode 100644 index 000000000..9e7d04f1d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1931_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1931 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1931 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1931 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1931 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1931GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1931GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1931GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1945_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1945_map.defaults new file mode 100644 index 000000000..f183f3aed --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1945_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1945 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1945 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1945 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1945 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1945GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1945GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1945GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1958_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1958_map.defaults new file mode 100644 index 000000000..23732c383 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1958_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1958 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1958 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1958 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1958 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1958GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1958GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1958GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1972_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1972_map.defaults new file mode 100644 index 000000000..a8d20002b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1972_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1972 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1972 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1972 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1972 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1972GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1972GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1972GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1986_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1986_map.defaults new file mode 100644 index 000000000..47db1003f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1986_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1986 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1986 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1986 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1986 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1986GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1986GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1986GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1999_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1999_map.defaults new file mode 100644 index 000000000..ad8ad8179 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1999_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 1999 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H1999 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H1999 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 1999 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_1999GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_1999GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_1999GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2013_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2013_map.defaults new file mode 100644 index 000000000..e3737b71d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2013_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2013 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2013 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2013 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2013 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2013GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2013GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2013GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2027_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2027_map.defaults new file mode 100644 index 000000000..a45671d64 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2027_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2027 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2027 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2027 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2027 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2027GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2027GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2027GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2040_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2040_map.defaults new file mode 100644 index 000000000..59fd36a42 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2040_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2040 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2040 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2040 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2040 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2040GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2040GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2040GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2054_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2054_map.defaults new file mode 100644 index 000000000..d468a7df4 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2054_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2054 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2054 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2054 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2054 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2054GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2054GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2054GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2067_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2067_map.defaults new file mode 100644 index 000000000..3c00ef9ba --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2067_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2067 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2067 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2067 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2067 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2067GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2067GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2067GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2095_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2095_map.defaults new file mode 100644 index 000000000..f360deeea --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2095_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2095 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2095 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2095 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2095 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2095GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2095GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2095GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2108_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2108_map.defaults new file mode 100644 index 000000000..011625e2b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2108_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2108 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2108 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2108 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2108 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2108GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2108GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2108GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2122_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2122_map.defaults new file mode 100644 index 000000000..601ae92bc --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2122_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2122 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2122 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2122 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2122 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2122GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2122GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2122GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2149_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2149_map.defaults new file mode 100644 index 000000000..00d767624 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2149_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2149 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2149 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2149 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2149 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2149GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2149GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2149GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2163_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2163_map.defaults new file mode 100644 index 000000000..b284a09c5 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2163_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2163 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2163 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2163 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2163 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2163GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2163GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2163GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2176_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2176_map.defaults new file mode 100644 index 000000000..466536efa --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2176_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2176 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2176 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2176 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2176 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2176GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2176GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2176GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2190_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2190_map.defaults new file mode 100644 index 000000000..29c80df79 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2190_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2190 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2190 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2190 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2190 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2190GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2190GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2190GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2203_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2203_map.defaults new file mode 100644 index 000000000..448180a30 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2203_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2203 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2203 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2203 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2203 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2203GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2203GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2203GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2217_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2217_map.defaults new file mode 100644 index 000000000..8903aea3f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2217_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2217 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2217 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2217 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2217GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2217GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2217GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2231_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2231_map.defaults new file mode 100644 index 000000000..ce0139fc2 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2231_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2231 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2231 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2231 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2231 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2231GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2231GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2231GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2244_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2244_map.defaults new file mode 100644 index 000000000..f60d7d263 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2244_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2244 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2244 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2244 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2244 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2244GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2244GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2244GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2258_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2258_map.defaults new file mode 100644 index 000000000..942968b47 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2258_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2258 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2258 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2258 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2258 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2258GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2258GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2258GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2271_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2271_map.defaults new file mode 100644 index 000000000..affd7d953 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2271_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2271 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2271 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2271 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2271 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2271GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2271GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2271GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2285_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2285_map.defaults new file mode 100644 index 000000000..62092fee2 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2285_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2285 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2285 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2285 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2285 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2285GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2285GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2285GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2299_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2299_map.defaults new file mode 100644 index 000000000..71e48de6a --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2299_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2299 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2299 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2299 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2299 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2299GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2299GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2299GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2312_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2312_map.defaults new file mode 100644 index 000000000..2ef10654d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2312_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2312 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2312 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2312 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2312 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2312GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2312GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2312GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2326_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2326_map.defaults new file mode 100644 index 000000000..f3005e8a1 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2326_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2326 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2326 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2326 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2326 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2326GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2326GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2326GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2339_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2339_map.defaults new file mode 100644 index 000000000..9b1bfc661 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2339_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2339 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2339 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2339 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2339 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2339GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2339GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2339GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2353_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2353_map.defaults new file mode 100644 index 000000000..67d5d6ad8 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2353_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2353 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2353 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2353 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2353GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2353GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2353GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2367_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2367_map.defaults new file mode 100644 index 000000000..3f0d5d783 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2367_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2367 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2367 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2367 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2367 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2367GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2367GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2367GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2380_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2380_map.defaults new file mode 100644 index 000000000..c5708ac86 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2380_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2380 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2380 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2380 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2380 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2380GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2380GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2380GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2394_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2394_map.defaults new file mode 100644 index 000000000..e85731043 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2394_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2394 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2394 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2394 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2394 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2394GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2394GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2394GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2407_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2407_map.defaults new file mode 100644 index 000000000..376fda849 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2407_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2407 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2407 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2407 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2407 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2407GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2407GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2407GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2421_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2421_map.defaults new file mode 100644 index 000000000..09fa75f06 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2421_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2421 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2421 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2421 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2421 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2421GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2421GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2421GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2435_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2435_map.defaults new file mode 100644 index 000000000..f52d3a574 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2435_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2435 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2435 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2435 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2435 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2435GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2435GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2435GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2448_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2448_map.defaults new file mode 100644 index 000000000..73c123ccd --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2448_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2448 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2448 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2448 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2448 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2448GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2448GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2448GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2462_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2462_map.defaults new file mode 100644 index 000000000..32fc0e7d0 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2462_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2462 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2462 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2462 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2462 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2462GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2462GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2462GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2475_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2475_map.defaults new file mode 100644 index 000000000..caaf80d28 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2475_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2475 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2475 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2475 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2475 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2475GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2475GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2475GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2489_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2489_map.defaults new file mode 100644 index 000000000..ba37d2ce9 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2489_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2489 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2489 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2489 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2489 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2489GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2489GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2489GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2503_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2503_map.defaults new file mode 100644 index 000000000..361e55df2 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2503_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2503 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2503 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2503 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2503 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2503GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2503GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2503GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2516_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2516_map.defaults new file mode 100644 index 000000000..542ae6a64 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2516_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2516 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2516 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2516 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2516 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2516GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2516GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2516GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2530_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2530_map.defaults new file mode 100644 index 000000000..b6f829f30 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2530_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2530 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2530 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2530 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2530 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2530GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2530GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2530GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2543_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2543_map.defaults new file mode 100644 index 000000000..dbe86eb24 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2543_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2543 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2543 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2543 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2543 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2543GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2543GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2543GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2557_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2557_map.defaults new file mode 100644 index 000000000..02523ab2b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2557_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2557 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2557 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2557 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2557 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2557GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2557GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2557GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2571_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2571_map.defaults new file mode 100644 index 000000000..26d628e82 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2571_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2571 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2571 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2571 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2571 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2571GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2571GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2571GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2584_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2584_map.defaults new file mode 100644 index 000000000..8a2d0ce50 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2584_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2584 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2584 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2584 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2584 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2584GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2584GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2584GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2598_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2598_map.defaults new file mode 100644 index 000000000..41cbab06f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H2598_map.defaults @@ -0,0 +1,45 @@ +# FIRAS 2598 GHz default parameters +# NOTE: data dir in parameter file + +BAND_LABEL&&& = FIRAS_H2598 +BAND_INSTRUMENT_LABEL&&& = FIRAS_H2598 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 16 +BAND_LMAX&&& = 192 +BAND_UNIT&&& = MJy/sr # Need to implement micron -> GHz in bp_mod and scale weights +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = FIRAS_mask.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = FIRAS # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_7deg.fits +BAND_BEAM_B_PTSRC_FILE&&& = FIRAS_beam_spline.dat +BAND_PIXEL_WINDOW&&& = pixel_window_n0016.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 2598 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = FIRAS_bp_2598GHz_highf_v2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none +BAND_MAPFILE&&& = FIRAS_map_2598GHz_highf.fits +BAND_NOISEFILE&&& = FIRAS_rms_2598GHz_highf.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none + diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index a617d17e3..ef9aaca74 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -305,7 +305,7 @@ subroutine sampleLineRatios(self, cpar, handle, id, iter) end if ! Draw sample - par = -1.d30 + par = -1.d300 if (trim(self%operation) == 'optimize') then if (mu < self%p_uni(1,id)) then par = self%p_uni(1,id) From 52df515f5f17fd460523028444d6231af793858e Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 15 Aug 2024 16:34:42 +0200 Subject: [PATCH 028/171] Fixed resetting pixreg_val after MH rejection --- commander3/src/comm_mh_specind_mod.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index e7a230dba..67111c6ad 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -705,6 +705,7 @@ subroutine sample_specind_mh(outdir, cpar, handle, handle_noise, l) c%theta(j)%p%map(pix,pol) = c%theta_pixreg_buff(c%ind_pixreg_arr(pix,pol,j),pol,j) end do end do + c%theta_pixreg(:,:,j) = c%theta_pixreg_buff(:,:,j) if (any(c%lmax_ind_pol(:,j) >= 0)) call c%theta(j)%p%YtW_scalar() end select end do From 9e4925fab3c540b04ae1a60d1499d6a159251a3a Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 27 Aug 2024 13:41:05 +0200 Subject: [PATCH 029/171] Updated modules to working version --- install_ita.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_ita.sh b/install_ita.sh index 61b98bfca..4c2a686a8 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -160,7 +160,7 @@ then mpicc="mpiicc" mpicxx="mpiicpc" printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" - module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 + module load intel/oneapi mpi tbb icc compiler-rt mkl compiler elif [[ "$toolchain" =~ "gnu" ]] then # Compilers From 877247fa4d793a27113927c93536411148b43643 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 28 Aug 2024 10:05:41 +0200 Subject: [PATCH 030/171] Fixed freefreeEM component; cannot be fitted, but only projected from input --- commander3/src/comm_diffuse_comp_smod.f90 | 94 ++++++++++----------- commander3/src/comm_freefreeEM_comp_mod.f90 | 13 +-- commander3/src/comm_param_mod.f90 | 2 + 3 files changed, 57 insertions(+), 52 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 0b9593bd5..c714698a7 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -641,7 +641,7 @@ module subroutine initPixregSampling(self, cpar, id, id_abs) write(*,fmt='(a,a)') 'Component "'//trim(self%label)//'", spec. ind "'& & //trim(self%indlabel(i))//'", all poltypes have pixel region sampling '//& & 'and all regions have been fixed. This only the prior RMS should do. Exiting' - stop + !stop end if end do !npar end if @@ -1882,7 +1882,6 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) !if (info%myid == 0) write(*,*) 'udgrade = ', t2-t1 end if theta_p(:,:,j) = td%map - !if (info%myid == 0) write(*,*) 'q1, j=',j, minval(theta_p(:,:,j)), maxval(theta_p(:,:,j)) call td%dealloc(); deallocate(td) end do end if @@ -1938,6 +1937,7 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) stop !debug, replace by proper stop and error message end if self%F(i,l)%p%map(j,1) = self%F_int(1,i,l)%p%eval(theta_p(j,1,:)) * data(i)%gain * self%cg_scale(1) + !write(*,*) i, j, theta_p(j,1,:), self%F_int(1,i,l)%p%eval(theta_p(j,1,:)), self%F(i,l)%p%map(j,1) end if else if (mixmatnull) then @@ -2608,55 +2608,55 @@ module subroutine dumpDiffuseToFITS(self, iter, chainfile, output_hdf, postfix, end if !write proposal length and number of proposals maps if local sampling was used - if (self%output_localsamp_maps .and. any(self%lmax_ind_pol(:min(self%nmaps,self%poltype(i)),i) < 0 .and. & - & self%pol_pixreg_type(:min(self%nmaps,self%poltype(i)),i) > 0)) then - filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & - & '_proplen_' // trim(postfix) // '.fits' - call self%pol_proplen(i)%p%writeFITS(trim(dir)//'/'//trim(filename)) - - filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & - & '_nprop_' // trim(postfix) // '.fits' - call self%pol_nprop(i)%p%writeFITS(trim(dir)//'/'//trim(filename)) - - end if + if (self%output_localsamp_maps) then + if (any(self%lmax_ind_pol(:min(self%nmaps,self%poltype(i)),i) < 0 .and. & + & self%pol_pixreg_type(:min(self%nmaps,self%poltype(i)),i) > 0)) then + filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & + & '_proplen_' // trim(postfix) // '.fits' + call self%pol_proplen(i)%p%writeFITS(trim(dir)//'/'//trim(filename)) + + filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & + & '_nprop_' // trim(postfix) // '.fits' + call self%pol_nprop(i)%p%writeFITS(trim(dir)//'/'//trim(filename)) + end if - !if pixelregions, create map without smoothed thetas (for input in new runs) - if (self%output_localsamp_maps .and. any(self%pol_pixreg_type(1:min(self%nmaps,self%poltype(i)),i) > 0)) then - - info => comm_mapinfo(self%theta(i)%p%info%comm, self%theta(i)%p%info%nside, & - & self%theta(i)%p%info%lmax, self%theta(i)%p%info%nmaps, self%theta(i)%p%info%pol) - tp => comm_map(info) - tp%map = self%theta(i)%p%map - do p = 1,self%poltype(i) - if (self%pol_pixreg_type(p,i) /=3) cycle - if (self%poltype(i) == 1) then - p_min=1 - p_max=info%nmaps - if (only_pol) p_min = 2 - else if (self%poltype(i)==2) then - if (p == 1) then - p_min = 1 - p_max = 1 + if (any(self%pol_pixreg_type(1:min(self%nmaps,self%poltype(i)),i) > 0)) then + + info => comm_mapinfo(self%theta(i)%p%info%comm, self%theta(i)%p%info%nside, & + & self%theta(i)%p%info%lmax, self%theta(i)%p%info%nmaps, self%theta(i)%p%info%pol) + tp => comm_map(info) + tp%map = self%theta(i)%p%map + do p = 1,self%poltype(i) + if (self%pol_pixreg_type(p,i) /=3) cycle + if (self%poltype(i) == 1) then + p_min=1 + p_max=info%nmaps + if (only_pol) p_min = 2 + else if (self%poltype(i)==2) then + if (p == 1) then + p_min = 1 + p_max = 1 + else + p_min = 2 + p_max = info%nmaps + end if + else if (self%poltype(i)==3) then + p_min = p + p_max = p else - p_min = 2 - p_max = info%nmaps + write(*,*) ' Unknown poltype in component ',self%label,', parameter ',self%indlabel(i) + stop end if - else if (self%poltype(i)==3) then - p_min = p - p_max = p - else - write(*,*) ' Unknown poltype in component ',self%label,', parameter ',self%indlabel(i) - stop - end if - - do j = 0,info%np-1 - tp%map(j,p_min:p_max) = self%theta_pixreg(self%ind_pixreg_arr(j,p,i),p,i) + + do j = 0,info%np-1 + tp%map(j,p_min:p_max) = self%theta_pixreg(self%ind_pixreg_arr(j,p,i),p,i) + end do end do - end do - filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & - & '_noSmooth_' // trim(postfix) // '.fits' - call tp%writeFITS(trim(dir)//'/'//trim(filename)) - call tp%dealloc(); deallocate(tp) + filename = trim(self%label) // '_' // trim(self%indlabel(i)) // & + & '_noSmooth_' // trim(postfix) // '.fits' + call tp%writeFITS(trim(dir)//'/'//trim(filename)) + call tp%dealloc(); deallocate(tp) + end if end if diff --git a/commander3/src/comm_freefreeEM_comp_mod.f90 b/commander3/src/comm_freefreeEM_comp_mod.f90 index 3bbfeca1f..0027b6780 100644 --- a/commander3/src/comm_freefreeEM_comp_mod.f90 +++ b/commander3/src/comm_freefreeEM_comp_mod.f90 @@ -67,8 +67,11 @@ function constructor_ffEM(cpar, id, id_abs) result(c) do i = 1, c%npar c%poltype(i) = cpar%cs_poltype(i,id_abs) end do - call c%initLmaxSpecind(cpar, id, id_abs) - + !call c%initLmaxSpecind(cpar, id, id_abs) + allocate(c%lmax_ind_pol(3,c%npar), c%lmax_ind_mix(3,c%npar)) + c%lmax_ind_pol = -1 + c%lmax_ind_mix = -1 + call c%initDiffuse(cpar, id, id_abs) ! Component specific parameters @@ -126,9 +129,9 @@ function constructor_ffEM(cpar, id, id_abs) result(c) end if end do - call c%initPixregSampling(cpar, id, id_abs) + !call c%initPixregSampling(cpar, id, id_abs) ! Init alm - if (c%lmax_ind >= 0) call c%initSpecindProp(cpar, id, id_abs) + !if (c%lmax_ind >= 0) call c%initSpecindProp(cpar, id, id_abs) ! Initialize mixing matrix call c%updateMixmat @@ -154,7 +157,7 @@ function evalSED_ffEM(self, nu, band, pol, theta) tau = 5.468d-2 * Te**(-1.5d0) * (nu/1.d9)**(-2) * EM * g evalSED_ffEM = 1.d6 * Te * (1.d0 - exp(-tau)) - + end function evalSED_ffEM diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index f72e41e10..5ea9986dc 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -2815,6 +2815,8 @@ subroutine read_freefreeEM_params_hash(htbl, cpar, itext, i, len_itext, bool_fla call get_parameter_hashtable(htbl, 'COMP_EM_SMOOTHING_SCALE'//itext, len_itext=len_itext, & & par_int=cpar%cs_smooth_scale(i,1)) cpar%cs_almsamp_init(1,i) = 'none' + cpar%cs_spec_pixreg(:,1,i) = 'fullsky' + cpar%cs_spec_pixreg_map(:,i) = 'fullsky' call get_parameter_hashtable(htbl, 'COMP_T_E_POLTYPE'//itext, len_itext=len_itext, par_int=cpar%cs_poltype(2,i)) k = cpar%cs_poltype(2,i) From fa732670e114f8ae2a1899b793550ea5cddc1391 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 28 Aug 2024 10:07:04 +0200 Subject: [PATCH 031/171] Added defaults files for planck2015 case --- .../defaults/bands/planck2015_1deg.defaults | 42 +++++++ .../ame/ame_planck2015_1deg.defaults | 96 +++++++++++++++ .../cmb/cmb_planck2015_1deg.defaults | 30 +++++ .../cmb/cmb_relquad_planck2015_1deg.defaults | 14 +++ .../components/co/co_planck2015_1deg.defaults | 29 +++++ .../dust/dust_planck2015_1deg.defaults | 67 ++++++++++ ...dust_planck2015_1deg_localsampler.defaults | 68 +++++++++++ .../freefree_planck2015_1deg.defaults | 72 +++++++++++ ...free_planck2015_1deg_localsampler.defaults | 57 +++++++++ .../monodipole/md_planck2015_1deg.defaults | 9 ++ .../synch/synch_planck2015_1deg.defaults | 96 +++++++++++++++ .../defaults/planck2015_1deg.defaults | 114 ++++++++++++++++++ 12 files changed, 694 insertions(+) create mode 100644 commander3/parameter_files/defaults/bands/planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg_localsampler.defaults create mode 100644 commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults create mode 100644 commander3/parameter_files/defaults/components/monodipole/md_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/planck2015_1deg.defaults diff --git a/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults b/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults new file mode 100644 index 000000000..d444ba7e3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults @@ -0,0 +1,42 @@ +#Generic Planck 2015 1deg default parameters + +BAND_LABEL&&& = 030 +BAND_INSTRUMENT_LABEL&&& = 030 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 256 +BAND_LMAX&&& = 750 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = fullsky +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_60arcmin.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n0256.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = LFI +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 28.4 +BAND_SAMP_BANDPASS&&& = .false. +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0.1 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none + +BAND_MAPFILE&&& = init_tod_map_030_n512_BP8.1_v1.fits +BAND_NOISEFILE&&& = init_tod_rms_030_n512_BP8.1_v1.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_BANDPASSFILE&&& = LFI_instrument_v4.h5 diff --git a/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults new file mode 100644 index 000000000..b4739b12b --- /dev/null +++ b/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults @@ -0,0 +1,96 @@ +# AME component +COMP_LABEL&& = ame1 +COMP_TYPE&& = spindust +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 22.8 +COMP_NU_REF_P&& = 22.8 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_ame1_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_NU_P_NU_MIN&& = 20 # Lowest frequency for index estimation in GHz +COMP_NU_P_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_NU_P_INPUT_MAP&& = init_ame1_nup_rc2_n256_v03.fits +COMP_NU_P_DEFAULT&& = 19 +COMP_NU_P_PRIOR_UNI_LOW&& = 10 +COMP_NU_P_PRIOR_UNI_HIGH&& = 70 +COMP_NU_P_PRIOR_GAUSS_MEAN&& = 19 +COMP_NU_P_PRIOR_GAUSS_RMS&& = 0. # 0.1 +COMP_NU_P_SMOOTHING_SCALE&& = 0 +COMP_NU_P_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + + +# New Local sampling parameters, 'ame' +COMP_NU_P_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_INT_LNLTYPE&& = prior # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_NU_P_INT_PRIOR_MEAN&& = 19 # prior sampler mean; Planck 2015 +COMP_NU_P_INT_PRIOR_RMS&& = 0.0 # prior sampler RMS; Planck 2015 +COMP_NU_P_INT_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_NU_P_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_NU_P_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_NU_P_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_ALMSAMP_INIT&& = init_alm_dust_beta.dat +COMP_NU_P_MASK&& = fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_NU_P_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_NU_P_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_NU_P_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_INT_FIX_PIXREG&& = none +COMP_NU_P_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_POL_FIX_PIXREG&& = none +COMP_NU_P_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_NU_P_PIXREG_INITVALUE_MAP&& = none +COMP_NU_P_COMBINED_MONOPOLE_SAMPLING&& = .true. +COMP_NU_P_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_NU_P_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_NU_P_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_NU_P_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_NU_P_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults new file mode 100644 index 000000000..569ae1fd6 --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults @@ -0,0 +1,30 @@ +# CMB for Planck 2015 1deg +COMP_LABEL&& = cmb +COMP_TYPE&& = cmb +COMP_CLASS&& = diffuse # {diffuse, ptsrc, template} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none + +COMP_LMAX_IND&& = 0 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_cmb +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 1 100. +COMP_NU_REF_P&& = 1 100. +COMP_CL_TYPE&& = none power_law # {none, single_l, binned, power_law} +COMP_MASK&& = fullsky +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = none default + diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults new file mode 100644 index 000000000..f339a4f2c --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults @@ -0,0 +1,14 @@ +# CMB relativistic quadrupole correction +COMP_LABEL&& = relquad +COMP_TYPE&& = cmb_relquad +COMP_CLASS&& = template +COMP_POLARIZATION&& = .false. +#COMP_CG_SCALE&& = 1.d0 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_PRIOR_GAUSS_MEAN&& = 1.d0 +COMP_PRIOR_GAUSS_RMS&& = 0.d0 +COMP_DEFAULT_AMPLITUDE&& = 1.d0 +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def.txt +COMP_INIT_FROM_HDF&& = none diff --git a/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults new file mode 100644 index 000000000..6febcff97 --- /dev/null +++ b/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults @@ -0,0 +1,29 @@ +# Line emission component +COMP_LABEL&& = co100 +COMP_TYPE&& = line +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_L_APOD&& = 750 +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = Kkm/s +COMP_NU_REF_T&& = 115.27 +COMP_NU_REF_P&& = 115.27 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_BAND_REF&& = 100-1 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky +COMP_MONOPOLE_PRIOR&& = none +COMP_CL_TYPE&& = none +COMP_LINE_TEMPLATE&& = /mn/stornext/d5/data/metins/dirbe/data/co100_line_template_DIRBE_v1.dat +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits +COMP_AMP_PRIOR_MAP&& = none +COMP_INIT_FROM_HDF&& = none diff --git a/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults new file mode 100644 index 000000000..67058c461 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults @@ -0,0 +1,67 @@ +# Thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBB +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_MASK&& = fullsky +COMP_INDMASK&& = none + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_dust_amp_BP8.1_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_BETA_NU_MIN&& = 20 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 1.68 1.55 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.56 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 0 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 18. +COMP_T_PRIOR_UNI_LOW&& = 10. +COMP_T_PRIOR_UNI_HIGH&& = 35. +COMP_T_PRIOR_GAUSS_MEAN&& = 18.5 +COMP_T_PRIOR_GAUSS_RMS&& = 0. +COMP_T_SMOOTHING_SCALE&& = 0 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 150 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + diff --git a/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg_localsampler.defaults new file mode 100644 index 000000000..e360e96e5 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg_localsampler.defaults @@ -0,0 +1,68 @@ +# New Local sampling parameters, 'dust' +COMP_BETA_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_INT_LNLTYPE&& = prior # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_BETA_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_BETA_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_BETA_INT_PRIOR_MEAN&& = 1.56 # prior sampler mean; Planck 2015 +COMP_BETA_INT_PRIOR_RMS&& = 0.03 # prior sampler RMS; Planck 2015 +COMP_BETA_INT_PIXREG_PRIORS&& = none +COMP_BETA_POL_PIXREG_PRIORS&& = none +COMP_BETA_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_BETA_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_BETA_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_BETA_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_BETA_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_BETA_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_BETA_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_BETA_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_BETA_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_BETA_ALMSAMP_INIT&& = init_alm_dust_beta.dat +COMP_BETA_MASK&& = fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_BETA_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_BETA_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_BETA_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_BETA_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_BETA_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_BETA_INT_FIX_PIXREG&& = none +COMP_BETA_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_BETA_POL_FIX_PIXREG&& = none +COMP_BETA_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_BETA_PIXREG_INITVALUE_MAP&& = none +COMP_BETA_COMBINED_MONOPOLE_SAMPLING&& = .true. +COMP_BETA_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_BETA_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_BETA_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_BETA_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_BETA_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + +COMP_T_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_INT_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_T_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_T_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_INT_PIXREG_PRIORS&& = none +COMP_T_POL_PIXREG_PRIORS&& = none +COMP_T_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_T_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_T_ALMSAMP_INIT&& = none +COMP_T_MASK&& = fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_T_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_T_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_INT_FIX_PIXREG&& = none +COMP_T_POL_FIX_PIXREG&& = none +COMP_T_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_T_PIXREG_INITVALUE_MAP&& = none +COMP_T_COMBINED_MONOPOLE_SAMPLING&& = .false. +COMP_T_CORRELATION_CONVERGENCE_SAMPLING&& = .false. diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults new file mode 100644 index 000000000..4f932cd09 --- /dev/null +++ b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults @@ -0,0 +1,72 @@ +# freefree component --------------------------------------------------------------------- +COMP_LABEL&& = ff +COMP_TYPE&& = freefreeEM +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 150 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_LMAX_IND&& = -1 # Use input map as is +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 22.8 +COMP_NU_REF_P&& = 22.8 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky +COMP_CL_TYPE&& = none +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 1 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e3 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 50 +COMP_CL_DEFAULT_AMP_B&& = 50 +COMP_CL_DEFAULT_BETA_T&& = 2.0d0 -0.5d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_CL_DEFAULT_THETA_T&& = 30.d0 # equivalent to BETA for CL_TYPE = gauss (see synch), BP8.0 used 90.d0 +COMP_CL_DEFAULT_THETA_E&& = 90.d0 +COMP_CL_DEFAULT_THETA_B&& = 90.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 1500 +COMP_AMP_INPUT_MAP&& = init_ff_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = init_ff_rc2_n256_v03.fits +COMP_AMP_PRIOR_LMAX&& = -1 + +COMP_EM_POLTYPE&& = 1 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_EM_INPUT_MAP&& = init_ff_EM_rc2_n256_v03.fits +COMP_EM_SMOOTHING_SCALE&& = 0 +COMP_EM_DEFAULT&& = 1. +COMP_EM_PRIOR_UNI_LOW&& = 1.d-6 +COMP_EM_PRIOR_UNI_HIGH&& = 1.d6 +COMP_EM_PRIOR_GAUSS_MEAN&& = 1. +COMP_EM_PRIOR_GAUSS_RMS&& = 0. +COMP_EM_NU_MIN&& = 0. # Lowest frequency for index estimation in GHz +COMP_EM_NU_MAX&& = 80. # Highest frequency for index estimation in GHz + +COMP_T_E_POLTYPE&& = 1 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_E_INPUT_MAP&& = init_ff_T_e_rc2_n256_v03.fits +COMP_T_E_SMOOTHING_SCALE&& = 0 +COMP_T_E_DEFAULT&& = 7000. +COMP_T_E_PRIOR_UNI_LOW&& = 1200. +COMP_T_E_PRIOR_UNI_HIGH&& = 12000. +COMP_T_E_PRIOR_GAUSS_MEAN&& = 7000. +COMP_T_E_PRIOR_GAUSS_RMS&& = 000. +COMP_T_E_NU_MIN&& = 0. # Lowest frequency for index estimation in GHz +COMP_T_E_NU_MAX&& = 217. # Highest frequency for index estimation in GHz +COMP_T_E_INT_PIXREG_PRIORS&& = none +COMP_T_E_POL_PIXREG_PRIORS&& = none + +COMP_T_E_ALMSAMP_INIT&& = none + +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults new file mode 100644 index 000000000..6db104749 --- /dev/null +++ b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults @@ -0,0 +1,57 @@ +# New Local sampling parameters. 'freefree, ff' +COMP_EM_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_EM_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_EM_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_EM_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_EM_INT_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_EM_POL_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_EM_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_EM_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_EM_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_EM_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_EM_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_EM_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_EM_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_EM_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_EM_MASK&& = fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_EM_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_EM_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_EM_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_EM_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_EM_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_EM_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_EM_INT_FIX_PIXREG&& = none +COMP_EM_POL_FIX_PIXREG&& = none +COMP_EM_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_EM_PIXREG_INITVALUE_MAP&& = none +COMP_EM_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_EM_COMBINED_MONOPOLE_SAMPLING&& = .false. + +COMP_T_E_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_E_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_E_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_E_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_E_INT_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_E_POL_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_E_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_T_E_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_T_E_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_E_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_E_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_E_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_E_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_T_E_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_T_E_MASK&& = fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_E_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_T_E_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_T_E_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_E_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_E_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_E_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_E_INT_FIX_PIXREG&& = none +COMP_T_E_POL_FIX_PIXREG&& = none +COMP_T_E_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_T_E_PIXREG_INITVALUE_MAP&& = none +COMP_T_E_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_T_E_COMBINED_MONOPOLE_SAMPLING&& = .false. + diff --git a/commander3/parameter_files/defaults/components/monodipole/md_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/monodipole/md_planck2015_1deg.defaults new file mode 100644 index 000000000..87db6139e --- /dev/null +++ b/commander3/parameter_files/defaults/components/monodipole/md_planck2015_1deg.defaults @@ -0,0 +1,9 @@ +# Mono- and dipole component +COMP_LABEL&& = md +COMP_TYPE&& = md +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_MD_MONO_FROM_PRIOR&& = none +COMP_MD_DEFINITION_FILE&& = init_md_BP10_v1.dat +COMP_INIT_FROM_HDF&& = none diff --git a/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults new file mode 100644 index 000000000..9ff961019 --- /dev/null +++ b/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults @@ -0,0 +1,96 @@ +# Synch component +COMP_LABEL&& = synch +COMP_TYPE&& = spindust +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 0.408 +COMP_NU_REF_P&& = 0.408 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_synch_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_NU_P_NU_MIN&& = 0 # Lowest frequency for index estimation in GHz +COMP_NU_P_NU_MAX&& = 100 # Highest frequency for index estimation in GHz +COMP_NU_P_INPUT_MAP&& = init_synch_nup_rc2_n256_v03.fits +COMP_NU_P_DEFAULT&& = 0.015407022 +COMP_NU_P_PRIOR_UNI_LOW&& = 0.001 +COMP_NU_P_PRIOR_UNI_HIGH&& = 0.10 +COMP_NU_P_PRIOR_GAUSS_MEAN&& = 0.015407022 +COMP_NU_P_PRIOR_GAUSS_RMS&& = 0. # 0.1 +COMP_NU_P_SMOOTHING_SCALE&& = 0 +COMP_NU_P_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + + +# New Local sampling parameters, 'synch' +COMP_NU_P_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_INT_LNLTYPE&& = prior # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_NU_P_INT_PRIOR_MEAN&& = 19 # prior sampler mean; Planck 2015 +COMP_NU_P_INT_PRIOR_RMS&& = 0.0 # prior sampler RMS; Planck 2015 +COMP_NU_P_INT_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_NU_P_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_NU_P_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_NU_P_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_ALMSAMP_INIT&& = init_alm_dust_beta.dat +COMP_NU_P_MASK&& = fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_NU_P_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_NU_P_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_NU_P_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_INT_FIX_PIXREG&& = none +COMP_NU_P_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_POL_FIX_PIXREG&& = none +COMP_NU_P_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_NU_P_PIXREG_INITVALUE_MAP&& = none +COMP_NU_P_COMBINED_MONOPOLE_SAMPLING&& = .true. +COMP_NU_P_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_NU_P_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_NU_P_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_NU_P_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_NU_P_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + diff --git a/commander3/parameter_files/defaults/planck2015_1deg.defaults b/commander3/parameter_files/defaults/planck2015_1deg.defaults new file mode 100644 index 000000000..843e1f398 --- /dev/null +++ b/commander3/parameter_files/defaults/planck2015_1deg.defaults @@ -0,0 +1,114 @@ +# Monte Carlo options +BASE_SEED = 163425 # Seed for random number generator + +NUM_GIBBS_STEPS_PER_TOD_SAMPLE = 0 + +SAMPLE_ONLY_TEMPERATURE = .true. +SAMPLE_ONLY_POLARIZATION = .false. +SAMPLE_SIGNAL_AMPLITUDES = .true. +SAMPLE_SPECTRAL_INDICES = .false. +SAMPLE_POWSPEC = .false. + +ENABLE_TOD_ANALYSIS = .false. +TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER = 10 +TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER = 10 +TOD_INCLUDE_ZODI = .false. +FFTW3_MAGIC_NUMBERS = fft3_magic_numbers_230810.txt + +ENABLE_TOD_SIMULATIONS = .false. +SIMS_OUTPUT_DIRECTORY = none + +# Options for CMB resampling (for constrained realization production) +RESAMPLE_CMB = .false. +FIRST_SAMPLE_FOR_CMB_RESAMP = 1 +LAST_SAMPLE_FOR_CMB_RESAMP = 15 +NUM_SUBSAMP_PER_MAIN_SAMPLE = 10 + +# Numerical accuracy settings +CG_CONVERGENCE_CRITERION = fixed_iter chisq # {residual, chisquare} +CG_LMAX_PRECOND = -1 # lmax for low-l preconditioner +CG_MAXITER = 300 # Conjugate gradients time out limit +CG_MINITER = 5 +CG_TOLERANCE = 1.d-8 # Fractional CG convergence criterion +CG_CONV_CHECK_FREQUENCY = 1 # Check convergence every n'th iteration +CG_PRECOND_TYPE = diagonal pseudoinv +CG_INIT_AMPS_ON_ZERO = .false. +SET_ALL_NOISE_MAPS_TO_MEAN = .false. +NUM_INDEX_CYCLES_PER_ITERATION = 1 +IGNORE_GAIN_AND_BANDPASS_CORR = .false. + +############################################################## +## Output options # +############################################################### + +THINNING_FACTOR = 1 +NSIDE_CHISQ = 16 +POLARIZATION_CHISQ = .true. +OUTPUT_MIXING_MATRIX = .false. +OUTPUT_RESIDUAL_MAPS = .true. +OUTPUT_CHISQ_MAP = .true. +OUTPUT_EVERY_NTH_CG_ITERATION = 0 +OUTPUT_CG_PRECOND_EIGENVALS = .false. +OUTPUT_INPUT_MODEL = .false. +OUTPUT_DEBUG_SEDS = .false. +OUTPUT_SIGNALS_PER_BAND = .false. + + +SOURCE_MASKFILE = none #bright_sources.txt +PROCESSING_MASKFILE = none #mask_cmb_v1_n0256_apod_v2_clean.fits +PROC_SMOOTH_SCALE = 30. #arcmin; smoothing inside processing mask + +# Spectral index sampling options + NUM_SMOOTHING_SCALES = 0 + + SMOOTHING_SCALE_FWHM01 = 300. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX01 = 96 + SMOOTHING_SCALE_NSIDE01 = 32 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN01 = pixel_window_n0032.fits + SMOOTHING_SCALE_FWHM_POSTPROC01 = 600. # Smoothing FWHM after pixel-by-pixel fit + + SMOOTHING_SCALE_FWHM02 = 600. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX02 = 64 + SMOOTHING_SCALE_NSIDE02 = 16 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN02 = pixel_window_n0016.fits + SMOOTHING_SCALE_FWHM_POSTPROC02 = 600. # Smoothing FWHM after pixel-by-pixel fit + + #fullsky spec. ind. parameters sampling (per say no smoothing in skymaps, but smoothing in postproc) + SMOOTHING_SCALE_FWHM03 = 60. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX03 = 64 + SMOOTHING_SCALE_NSIDE03 = 16 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN03 = pixel_window_n0016.fits + SMOOTHING_SCALE_FWHM_POSTPROC03 = 600. # Smoothing FWHM after pixel-by-pixel fit + + # TOD sampling options + TOD_NUM_BP_PROPOSALS_PER_ITER = 1 # 1 for sampling; >= 1 for optimize + + NUMITER_RESAMPLE_HARD_GAIN_PRIORS = 3 + + +CMB_DIPOLE_PRIOR = none + +OUTPUT_COMPS_TO_CHAINDIR = all + +# Alm sampler settings +ALMSAMP_NSAMP_ALM = 100 # of mcmc samples per gibbs +ALMSAMP_BURN_IN = 2 # of gibbs iterations with steplength adjustment +ALMSAMP_NSIDE_CHISQ_LOWRES = 16 +ALMSAMP_PRIOR_FWHM = 0 +ALMSAMP_OPTIMIZE_ALM = .false. # save chisq from prev gibbs iter +ALMSAMP_APPLY_PRIOR = .true. # apply prior to alms +ALMSAMP_PIXREG = .true. +ALMSAMP_PRIORSAMP_FROZEN_REGIONS = .true. + +#local sampler settings +LOCALSAMP_BURN_IN = 2 # of gibbs iterations with steplength adjustment +LOCALSAMP_OUTPUT_MAPS = .false. # {.true., .false.} output extra maps from local sampler + +############################################################## +## Conventions and global parameters # +############################################################### + + +MJYSR_CONVENTION = IRAS +T_CMB = 2.7255d0 + From 9594570e525eb87c6dc4547fc9d2497a44d25ad1 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 28 Aug 2024 10:14:45 +0200 Subject: [PATCH 032/171] Added Planck 2015 parameter file and run script --- .../param_AST9240_planck2015_1deg.txt | 701 ++++++++++++++++++ commander3/parameter_files/run_comm3_AST9240 | 46 ++ 2 files changed, 747 insertions(+) create mode 100644 commander3/parameter_files/param_AST9240_planck2015_1deg.txt create mode 100755 commander3/parameter_files/run_comm3_AST9240 diff --git a/commander3/parameter_files/param_AST9240_planck2015_1deg.txt b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt new file mode 100644 index 000000000..965b90428 --- /dev/null +++ b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt @@ -0,0 +1,701 @@ +************************************************************** +* Commander parameter file * +************************************************************** +@DEFAULT planck2015_1deg.defaults + +OPERATION = sample # {sample,optimize} +#OPERATION = optimize # {sample,optimize} +VERBOSITY = 3 # [0,...,3] + +############################################################## +# Algorithm specification # +############################################################## + +# Monte Carlo options +NUMCHAIN = 1 # Number of independent chains +NUM_GIBBS_ITER = 250 # Length of each Markov chain +CHAIN_STATUS = new +NUM_INIT_CHAINS = 1 + +INIT_CHAIN01 = none + +OUTPUT_MIXING_MATRIX = .true. +OUTPUT_INPUT_MODEL = .true. +OUTPUT_SIGNALS_PER_BAND = .true. +NSIDE_CHISQ = 256 + +############################################################## +# Output options # +############################################################## + +OUTPUT_DIRECTORY = chains + +############################################################## +# Data sets # +############################################################## + +DATA_DIRECTORY = /mn/stornext/d16/cmbco/AST9240/2024/planck2015_comm3/data +NUMBAND = 32 + +# HFI +INCLUDE_BAND001 = .true. # 857-2 +INCLUDE_BAND002 = .true. # 545-2 +INCLUDE_BAND003 = .true. # 545-4 +INCLUDE_BAND004 = .true. # 353-ds2 +INCLUDE_BAND005 = .true. # 353-1 +INCLUDE_BAND006 = .true. # 217-1 +INCLUDE_BAND007 = .true. # 217-2 +INCLUDE_BAND008 = .true. # 217-3 +INCLUDE_BAND009 = .true. # 217-4 +INCLUDE_BAND010 = .true. # 143-ds1 +INCLUDE_BAND011 = .true. # 143-ds2 +INCLUDE_BAND012 = .true. # 143-5 +INCLUDE_BAND013 = .true. # 143-6 +INCLUDE_BAND014 = .true. # 143-7 +INCLUDE_BAND015 = .true. # 100-ds1 +INCLUDE_BAND016 = .true. # 100-ds2 + +# LFI +INCLUDE_BAND017 = .true. # 30 GHz +INCLUDE_BAND018 = .true. # 44 GHz +INCLUDE_BAND019 = .true. # 70-ds1 +INCLUDE_BAND020 = .true. # 70-ds2 +INCLUDE_BAND021 = .true. # 70-ds3 + +# WMAP +INCLUDE_BAND022 = .true. # K +INCLUDE_BAND023 = .true. # Ka +INCLUDE_BAND024 = .true. # Q1 +INCLUDE_BAND025 = .true. # Q2 +INCLUDE_BAND026 = .true. # V1 +INCLUDE_BAND027 = .true. # V2 +INCLUDE_BAND028 = .true. # W1 +INCLUDE_BAND029 = .true. # W2 +INCLUDE_BAND030 = .true. # W3 +INCLUDE_BAND031 = .true. # W4 + +# Haslam +INCLUDE_BAND032 = .true. # Haslam + + +# 857-2 +@START 001 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 857-2 +BAND_INSTRUMENT_LABEL&&& = 857-2 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 857. +BAND_MAPFILE&&& = map_dx11d_r2_zc_857-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_857-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_857-2.dat +@END 001 + +# 545-2 +@START 002 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 545-2 +BAND_INSTRUMENT_LABEL&&& = 545-2 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 545. +BAND_MAPFILE&&& = map_dx11d_r2_zc_545-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_545-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_545-2.dat +@END 002 + +# 545-4 +@START 003 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 545-4 +BAND_INSTRUMENT_LABEL&&& = 545-4 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 545. +BAND_MAPFILE&&& = map_dx11d_r2_zc_545-4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_545-4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_545-4.dat +@END 003 + +# 353-ds2 +@START 004 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 353-ds2 +BAND_INSTRUMENT_LABEL&&& = 353-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 353. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_353-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_353-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_353-ds2.dat +@END 004 + +# 353-1 +@START 005 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 353-1 +BAND_INSTRUMENT_LABEL&&& = 353-1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 353. +BAND_MAPFILE&&& = map_dx11d_r2_zc_353-1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_353-1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_353-1.dat +@END 005 + +# 217-1 +@START 006 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-1 +BAND_INSTRUMENT_LABEL&&& = 217-1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-1.dat +@END 006 + +# 217-2 +@START 007 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-2 +BAND_INSTRUMENT_LABEL&&& = 217-2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-2.dat +@END 007 + +# 217-3 +@START 008 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-3 +BAND_INSTRUMENT_LABEL&&& = 217-3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-3_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-3_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-3.dat +@END 008 + +# 217-1 +@START 009 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-4 +BAND_INSTRUMENT_LABEL&&& = 217-4 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-4.dat +@END 009 + +# 143-ds1 +@START 010 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-ds1 +BAND_INSTRUMENT_LABEL&&& = 143-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_143-ds1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-ds1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-ds1.dat +@END 010 + +# 143-ds2 +@START 011 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-ds2 +BAND_INSTRUMENT_LABEL&&& = 143-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_143-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-ds2.dat +@END 011 + +# 143-5 +@START 012 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-5 +BAND_INSTRUMENT_LABEL&&& = 143-5 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-5_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-5_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-5.dat +@END 012 + +# 143-6 +@START 013 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-6 +BAND_INSTRUMENT_LABEL&&& = 143-6 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-6_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-6_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-6.dat +@END 013 + +# 143-7 +@START 014 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-7 +BAND_INSTRUMENT_LABEL&&& = 143-7 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-7_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-7_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-7.dat +@END 014 + +# 100-ds1 +@START 015 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 100-ds1 +BAND_INSTRUMENT_LABEL&&& = 100-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 100. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_100-ds1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_100-ds1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_100-ds1.dat +@END 015 + +# 100-ds2 +@START 016 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 100-ds2 +BAND_INSTRUMENT_LABEL&&& = 100-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 100. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_100-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_100-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_100-ds2.dat +@END 016 + +# 30 GHz +@START 017 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 030 +BAND_INSTRUMENT_LABEL&&& = 030 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 28.4 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_030_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_030_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_030.dat +@END 017 + +# 44 GHz +@START 018 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 044 +BAND_INSTRUMENT_LABEL&&& = 044 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 44.1 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_044_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_044_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_044.dat +@END 018 + +# 70-ds1 +@START 019 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds1 +BAND_INSTRUMENT_LABEL&&& = 070-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-18_23_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-18_23_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-18_23.dat +@END 019 + +# 70-ds2 +@START 020 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds2 +BAND_INSTRUMENT_LABEL&&& = 070-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-19_22_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-19_22_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-19_22.dat +@END 020 + +# 70-ds3 +@START 021 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds3 +BAND_INSTRUMENT_LABEL&&& = 070-ds3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-20_21_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-20_21_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-20_21.dat +@END 021 + +# WMAP K +@START 022 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_K +BAND_INSTRUMENT_LABEL&&& = WMAP_K +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 22.8 +BAND_MAPFILE&&& = map_wmap9_K_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_K_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_K_v3.dat +@END 022 + +# WMAP Ka +@START 023 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Ka +BAND_INSTRUMENT_LABEL&&& = WMAP_Ka +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 33.0 +BAND_MAPFILE&&& = map_wmap9_Ka_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Ka_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Ka_v3.dat +@END 023 + +# WMAP Q1 +@START 024 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Q1 +BAND_INSTRUMENT_LABEL&&& = WMAP_Q1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 40.6 +BAND_MAPFILE&&& = map_wmap9_Q1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Q1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Q1_v3.dat +@END 024 + +# WMAP Q2 +@START 025 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Q2 +BAND_INSTRUMENT_LABEL&&& = WMAP_Q2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 40.6 +BAND_MAPFILE&&& = map_wmap9_Q2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Q2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Q2_v3.dat +@END 025 + +# WMAP V1 +@START 026 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_V1 +BAND_INSTRUMENT_LABEL&&& = WMAP_V1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 60.8 +BAND_MAPFILE&&& = map_wmap9_V1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_V1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_V1_v3.dat +@END 026 + +# WMAP V2 +@START 027 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_V2 +BAND_INSTRUMENT_LABEL&&& = WMAP_V2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 60.8 +BAND_MAPFILE&&& = map_wmap9_V2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_V2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_V2_v3.dat +@END 027 + +# WMAP W1 +@START 028 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W1 +BAND_INSTRUMENT_LABEL&&& = WMAP_W1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W1_v3.dat +@END 028 + +# WMAP W2 +@START 029 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W2 +BAND_INSTRUMENT_LABEL&&& = WMAP_W2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W2_v3.dat +@END 029 + +# WMAP W3 +@START 030 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W3 +BAND_INSTRUMENT_LABEL&&& = WMAP_W3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W3_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W3_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W3_v3.dat +@END 030 + +# WMAP W4 +@START 031 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W4 +BAND_INSTRUMENT_LABEL&&& = WMAP_W4 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W4_v3.dat +@END 031 + +# Haslam +@START 032 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = Haslam +BAND_INSTRUMENT_LABEL&&& = Haslam +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = delta +BAND_NOMINAL_FREQ&&& = 0.408 +BAND_MAPFILE&&& = map_haslam408_ds_Remazeilles2014_1deg_n256_uK_TQU.fits +BAND_NOISEFILE&&& = rms_haslam408_ds_Remazeilles2014_1deg_n256_uK_0.8K_1pct_TQU.fits +BAND_BANDPASSFILE&&& = haslam_bp.dat +@END 032 + + +############################################################## +# Model parameters # +############################################################## + +INSTRUMENT_PARAM_FILE = init_instpar_planck2015_v1.dat +INIT_INSTRUMENT_FROM_HDF = none + +NUM_SIGNAL_COMPONENTS = 13 +INCLUDE_COMP01 = .true. # CMB +INCLUDE_COMP02 = .true. # Relativistic CMB correction +INCLUDE_COMP03 = .true. # Dust +INCLUDE_COMP04 = .true. # Synch +INCLUDE_COMP05 = .true. # Free-free +INCLUDE_COMP06 = .true. # AME1 +INCLUDE_COMP07 = .true. # AME2 +INCLUDE_COMP08 = .true. # CO10 +INCLUDE_COMP09 = .true. # CO21 +INCLUDE_COMP10 = .true. # CO32 +INCLUDE_COMP11 = .false. # HCN +INCLUDE_COMP12 = .false. # SZ +INCLUDE_COMP13 = .true. # Monopole + +# CMB +@START 01 +@DEFAULT components/cmb/cmb_planck2015_1deg.defaults +COMP_AMP_INPUT_MAP&& = init_cmb_rc2_n256_v03.fits +COMP_MONOPOLE_PRIOR&& = none +@END 01 + +# CMB relativistic quadrupole correction +@START 02 +@DEFAULT components/cmb/cmb_relquad_planck2015_1deg.defaults +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_planck2015_1deg.txt +@END 02 + +# Thermal dust component +@START 03 +@DEFAULT components/dust/dust_planck2015_1deg.defaults +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_INDMASK&& = fullsky +COMP_AMP_INPUT_MAP&& = init_dust_rc2_n256_v03.fits +COMP_BETA_INPUT_MAP&& = init_dust_beta_rc2_n256_v03.fits +COMP_T_INPUT_MAP&& = init_dust_Td_rc2_n256_v03.fits +COMP_BETA_SMOOTHING_SCALE&& = 0 +COMP_AMP_LMAX&& = 750 +@DEFAULT components/dust/dust_LFI_localsampler.defaults +# New Local sampling parameters, 'dust' +COMP_IND_LMAX&& = 750 +COMP_BETA_DEFAULT&& = 1.50 +COMP_T_DEFAULT&& = 19.5 +COMP_BETA_COMBINED_MONOPOLE_SAMPLING&& = .false. +COMP_BETA_ALMSAMP_INIT&& = none +COMP_BETA_MASK&& = fullsky +COMP_INIT_FROM_HDF&& = default +COMP_BETA_INT_LNLTYPE&& = prior chisq +COMP_BETA_INT_LMAX&& = -1 +COMP_BETA_INT_PIXREG&& = pixreg +COMP_BETA_POL_LNLTYPE&& = prior +COMP_BETA_INT_PRIOR_MEAN&& = 1.50 +COMP_BETA_POL_PRIOR_MEAN&& = 1.50 +COMP_BETA_POL_PRIOR_RMS&& = 0.03 0.03 +COMP_BETA_INT_PRIOR_RMS&& = 0.03 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.05 +COMP_BETA_POL_LMAX&& = -1 +COMP_CL_DEFAULT_AMP_T&& = 1e4 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 100 +COMP_CL_DEFAULT_AMP_B&& = 100 +COMP_CL_DEFAULT_BETA_T&& = 14.d0 +COMP_CL_DEFAULT_BETA_E&& = 14.d0 +COMP_CL_DEFAULT_BETA_B&& = 14.d0 +@END 03 + +# Synchrotron component +@START 04 +@DEFAULT components/synch/synch_planck2015_1deg.defaults +COMP_LABEL&& = synch +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 0.408 +COMP_NU_P_INPUT_MAP&& = init_synch_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = Synchrotron_template_GHz_extended.txt +COMP_AMP_INPUT_MAP&& = init_synch_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 04 + +# freefree component --------------------------------------------------------------------- +@START 05 +@DEFAULT components/freefree/freefree_planck2015_1deg.defaults +@DEFAULT components/freefree/freefree_planck2015_1deg_localsampler.defaults +COMP_EM_INPUT_MAP&& = init_ff_EM_rc2_n256_v03.fits +COMP_T_E_INPUT_MAP&& = init_ff_T_e_rc2_n256_v03.fits +@END 05 + +# AME1 component ------------------------------------------------------------------ +@START 06 +@DEFAULT components/ame/ame_planck2015_1deg.defaults +COMP_LABEL&& = ame1 +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 22.8 +COMP_NU_P_INPUT_MAP&& = init_ame1_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = spdust2_cnm.dat +COMP_AMP_INPUT_MAP&& = init_ame1_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 06 + +# AME1 component ------------------------------------------------------------------ +@START 07 +@DEFAULT components/ame/ame_planck2015_1deg.defaults +COMP_LABEL&& = ame2 +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 41 +COMP_NU_P_INPUT_MAP&& = init_ame2_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = spdust2_cnm.dat +COMP_AMP_INPUT_MAP&& = init_ame2_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 07 + + +# CO10 line emission +@START 08 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co100 +COMP_NU_REF_T&& = 115.27 +COMP_BAND_REF&& = 100-ds1 +COMP_LINE_TEMPLATE&& = co100_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co10_rc2_n256_v03.fits +@END 08 + +# CO21 line emission +@START 09 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co217 +COMP_NU_REF_T&& = 230.54 +COMP_BAND_REF&& = 217-1 +COMP_LINE_TEMPLATE&& = co217_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co21_rc2_n256_v03.fits +@END 09 + +# CO32 line emission +@START 10 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co353 +COMP_NU_REF_T&& = 345.81 +COMP_BAND_REF&& = 353-ds2 +COMP_LINE_TEMPLATE&& = co353_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co32_rc2_n256_v03.fits +@END 10 + +# HCN line emission +@START 11 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = hcn +COMP_NU_REF_T&& = 88.6 +COMP_BAND_REF&& = 100-ds1 +COMP_LINE_TEMPLATE&& = /mn/stornext/d5/data/metins/dirbe/data/hcn_line_template_DIRBE_v1.dat +COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits +@END 11 + +# SZ placeholder -- not implemented yet +@START 12 +@DEFAULT components/cmb/cmb_planck2015_1deg.defaults +COMP_AMP_INPUT_MAP&& = init_cmb_rc2_n256_v03.fits +COMP_MONOPOLE_PRIOR&& = none +@END 12 + +# Mono- and dipole component +@START 13 +@DEFAULT components/monodipole/md_LFI.defaults +COMP_MD_MONO_FROM_PRIORS&& = none +COMP_MD_DEFINITION_FILE&& = init_md_planck2015_1deg.dat +COMP_INIT_FROM_HDF&& = none +@END 13 + + + + + + + + + +NUM_CG_SAMPLING_GROUPS = 0 +NUM_MCMC_SAMPLING_GROUPS = 0 + +@START 01 +CG_SAMPLING_GROUP&& = cmb,ff,ame,synch,dust +CG_SAMPLING_GROUP_MASK&& = fullsky +CG_SAMPLING_GROUP_MAXITER&& = 60 +@END 01 + +@START 02 +CG_SAMPLING_GROUP&& = md +CG_SAMPLING_GROUP_MASK&& = mask_chisq_15band_n256_v2_ptsrc.fits +CG_SAMPLING_GROUP_MAXITER&& = 7 +@END 02 + + + +NUM_SMOOTHING_SCALES = 1 +SMOOTHING_SCALE_FWHM01 = 60. # Arcmin; 0 = native resolution +SMOOTHING_SCALE_LMAX01 = 750 +SMOOTHING_SCALE_NSIDE01 = 256 # Must match NSIDE of component it is used for +SMOOTHING_SCALE_PIXWIN01 = pixel_window_n0256.fits +SMOOTHING_SCALE_FWHM_POSTPROC01 = 60. # Smoothing FWHM after pixel-by-pixel fit diff --git a/commander3/parameter_files/run_comm3_AST9240 b/commander3/parameter_files/run_comm3_AST9240 new file mode 100755 index 000000000..3bede0dea --- /dev/null +++ b/commander3/parameter_files/run_comm3_AST9240 @@ -0,0 +1,46 @@ +#!/bin/bash +list1=owl{17..24}.uio.no +list2=owl{25..28}.uio.no +list3=owl{29..30}.uio.no +list4=owl{31..35}.uio.no +list5=owl{36..37}.uio.no +list6=hyades{2..3}.uio.no +list7=hyades4.uio.no +list8=hyades5.uio.no +list9=hyades6.uio.no +list10=hyades{7..9}.uio.no +list11=hyades{10..16}.uio.no +lists=(list1 list2 list3 list4 list5 list6 list7 list8 list9 list10 list11) +ns=(24 72 64 64 128 86 64 24 64) +tLen=${#lists[@]} +builds=("owl1724" "owl2528" "owl2930" "owl3135" "owl3637" "hya13" "hya4" "hya5" "hya6" "hya79" "hya1016") +module purge +module load intel/oneapi mpi icc compiler-rt tbb mkl compiler +build=0 +for (( i=0; i<${tLen}; i++ )); +do + c=${!lists[$i]} + v=$(eval "echo $c") + if [[ "$v" == *"$HOSTNAME"* ]] + then + build=$((i+1)) + build=${builds[$i]} + n=${ns[$i]} + fi +done +echo $build + +seed=$RANDOM + + +#killall -9 commander +COMM_ROOT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/build_owl3135_oneapi_Release" +#COMM_ROOT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/build" +export COMMANDER_PARAMS_DEFAULT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/commander3/parameter_files/defaults" +export HEALPIX=${COMM_ROOT}"/install/healpix" +export LD_LIBRARY_PATH=${COMM_ROOT}/install/lib:${COMM_ROOT}/install/healpix/lib:$LD_LIBRARY_PATH +pfile=param_ml_32band_comm3.txt +dir="chains" +cp $pfile $dir/${pfile}_orig_v1 +n=64 +export OMP_NUM_THREADS=1; mpirun -env I_MPI_FABRICS shm -n $n ${COMM_ROOT}/../commander3/src/commander $pfile 2>&1| tee -a $dir/slurm.txt From 7026ff2586751489c51f5db56242eae2ee5274eb Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 28 Aug 2024 13:43:03 +0200 Subject: [PATCH 033/171] Changed libraries for cmake --- install_ita.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_ita.sh b/install_ita.sh index 4c2a686a8..61b98bfca 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -160,7 +160,7 @@ then mpicc="mpiicc" mpicxx="mpiicpc" printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" - module load intel/oneapi mpi tbb icc compiler-rt mkl compiler + module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 elif [[ "$toolchain" =~ "gnu" ]] then # Compilers From 7da0f6096498303ae4524bbba73bcbbd40ff0f52 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 28 Aug 2024 19:35:35 +0200 Subject: [PATCH 034/171] Updated default runfile --- commander3/parameter_files/run_comm3_AST9240 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/commander3/parameter_files/run_comm3_AST9240 b/commander3/parameter_files/run_comm3_AST9240 index 3bede0dea..8b68118de 100755 --- a/commander3/parameter_files/run_comm3_AST9240 +++ b/commander3/parameter_files/run_comm3_AST9240 @@ -15,7 +15,8 @@ ns=(24 72 64 64 128 86 64 24 64) tLen=${#lists[@]} builds=("owl1724" "owl2528" "owl2930" "owl3135" "owl3637" "hya13" "hya4" "hya5" "hya6" "hya79" "hya1016") module purge -module load intel/oneapi mpi icc compiler-rt tbb mkl compiler +module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 + build=0 for (( i=0; i<${tLen}; i++ )); do @@ -34,13 +35,13 @@ seed=$RANDOM #killall -9 commander -COMM_ROOT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/build_owl3135_oneapi_Release" -#COMM_ROOT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/build" -export COMMANDER_PARAMS_DEFAULT="/mn/stornext/u3/hke/git/Commander_AST9240_2024/commander3/parameter_files/defaults" -export HEALPIX=${COMM_ROOT}"/install/healpix" +COMM_ROOT="/mn/stornext/u3/hke/git/Commander_AST9240_2024" +export COMMANDER_PARAMS_DEFAULT=$COMM_ROOT"/commander3/parameter_files/defaults" +export COMM_EXEC=$COMM_ROOT"/build_${build}_oneapi_Release/install/bin/commander3" +export HEALPIX=${COMM_ROOT}"/build_${build}_oneapi_Release/install/healpix" export LD_LIBRARY_PATH=${COMM_ROOT}/install/lib:${COMM_ROOT}/install/healpix/lib:$LD_LIBRARY_PATH -pfile=param_ml_32band_comm3.txt +pfile=param_AST9240_planck2015_1deg.txt dir="chains" cp $pfile $dir/${pfile}_orig_v1 n=64 -export OMP_NUM_THREADS=1; mpirun -env I_MPI_FABRICS shm -n $n ${COMM_ROOT}/../commander3/src/commander $pfile 2>&1| tee -a $dir/slurm.txt +export OMP_NUM_THREADS=1; mpirun -env I_MPI_FABRICS shm -n $n $COMM_EXEC $pfile 2>&1| tee -a $dir/slurm.txt From 3104ec6364fd55b808d3d7ecef069f5365348568 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sat, 31 Aug 2024 15:58:24 +0200 Subject: [PATCH 035/171] Fixed bug with duplicate labels --- .../param_AST9240_planck2015_1deg.txt | 1 + commander3/src/comm_hdf_mod.f90 | 2 ++ commander3/src/comm_output_mod.f90 | 1 - commander3/src/comm_param_mod.f90 | 12 ++++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/commander3/parameter_files/param_AST9240_planck2015_1deg.txt b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt index 965b90428..fe1ee52b6 100644 --- a/commander3/parameter_files/param_AST9240_planck2015_1deg.txt +++ b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt @@ -656,6 +656,7 @@ COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits # SZ placeholder -- not implemented yet @START 12 @DEFAULT components/cmb/cmb_planck2015_1deg.defaults +COMP_LABEL&& = sz COMP_AMP_INPUT_MAP&& = init_cmb_rc2_n256_v03.fits COMP_MONOPOLE_PRIOR&& = none @END 12 diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index 82446a1f6..61c2d4ce6 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -5311,7 +5311,9 @@ subroutine create_hdf_group(file, group) character(len=*) :: group integer(hid_t) :: gid call h5gcreate_f(file%filehandle, group, gid, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot create group "//trim(file%filename)//', '//trim(group)) call h5gclose_f(gid, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot close group "//trim(file%filename)//', '//trim(group)) end subroutine ! ********************** diff --git a/commander3/src/comm_output_mod.f90 b/commander3/src/comm_output_mod.f90 index e8d3f6159..dcdc02522 100644 --- a/commander3/src/comm_output_mod.f90 +++ b/commander3/src/comm_output_mod.f90 @@ -510,7 +510,6 @@ subroutine write_params_to_hdf(cpar, chainfile) call create_hdf_group(chainfile, 'parameters') n = size(cpar%cs_label) - do i = 1, n hdf_path = 'parameters/'//trim(adjustl(cpar%cs_label(i))) call create_hdf_group(chainfile, trim(hdf_path)) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 5ea9986dc..490a2bbc6 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -979,6 +979,18 @@ subroutine read_component_params_hash(htbl, cpar) end if end do + + if (cpar%myid == 0) then + do i = 1, n + do j = i+1, n + if (trim(cpar%cs_label(i)) == (cpar%cs_label(j))) then + write(*,*) 'COMP_LABEL ', i, ' and ', j, ' are both ', trim(cpar%cs_label(i)) + write(*,*) 'Only unique components labels allowed' + stop + end if + end do + end do + end if cpar%cs_ncomp = count(cpar%cs_include) !cpar%cg_num_samp_groups = maxval(cpar%cs_cg_samp_group) From 2cfad7c832607772d377afdaba6bb3e4235fbff0 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sat, 31 Aug 2024 17:14:27 +0200 Subject: [PATCH 036/171] Updated parameter file, temporary workaround for free-free --- .../parameter_files/param_AST9240_planck2015_1deg.txt | 4 +++- commander3/src/comm_diffuse_comp_smod.f90 | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/commander3/parameter_files/param_AST9240_planck2015_1deg.txt b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt index fe1ee52b6..9b1be1ecc 100644 --- a/commander3/parameter_files/param_AST9240_planck2015_1deg.txt +++ b/commander3/parameter_files/param_AST9240_planck2015_1deg.txt @@ -677,19 +677,21 @@ COMP_INIT_FROM_HDF&& = none -NUM_CG_SAMPLING_GROUPS = 0 +NUM_CG_SAMPLING_GROUPS = 2 NUM_MCMC_SAMPLING_GROUPS = 0 @START 01 CG_SAMPLING_GROUP&& = cmb,ff,ame,synch,dust CG_SAMPLING_GROUP_MASK&& = fullsky CG_SAMPLING_GROUP_MAXITER&& = 60 +CG_SAMPLING_GROUP_BANDS&& = all @END 01 @START 02 CG_SAMPLING_GROUP&& = md CG_SAMPLING_GROUP_MASK&& = mask_chisq_15band_n256_v2_ptsrc.fits CG_SAMPLING_GROUP_MAXITER&& = 7 +CG_SAMPLING_GROUP_BANDS&& = all @END 02 diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index c714698a7..14004866e 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -488,6 +488,7 @@ module subroutine initPixregSampling(self, cpar, id, id_abs) allocate(self%first_ind_sample(3,self%npar)) !used for pixelregion sampling self%first_ind_sample=.true. + call update_status(status, "initPixreg_specind_pixreg_type") self%npixreg = 0 @@ -2663,7 +2664,9 @@ module subroutine dumpDiffuseToFITS(self, iter, chainfile, output_hdf, postfix, !output theta, proposal length and number of proposals per pixel region to HDF if (output_hdf) then npol=min(self%nmaps,self%poltype(i))!only concerned about the maps/poltypes in use - if (any(self%pol_pixreg_type(:npol,i) > 0)) then + if (.not. allocated(self%pol_pixreg_type)) then + continue + else if (any(self%pol_pixreg_type(:npol,i) > 0)) then npr=0 do j = 1,npol if (self%npixreg(j,i)>npr) npr = self%npixreg(j,i) @@ -2691,6 +2694,8 @@ module subroutine dumpDiffuseToFITS(self, iter, chainfile, output_hdf, postfix, deallocate(dp_pixreg,int_pixreg) end if + else + continue end if end if From bb76f6449e006911e780c5d58c3882d6ce3c5233 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 2 Sep 2024 15:19:56 +0200 Subject: [PATCH 037/171] Fixed out-of-bounds error --- commander3/src/comm_diffuse_comp_smod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 14004866e..0808013ac 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -1046,7 +1046,7 @@ module subroutine initPixregSampling(self, cpar, id, id_abs) ! if (self%myid == 0) write(*,*) 'd1', self%theta(i)%p%map(0,1:self%nmaps) smooth_scale = self%smooth_scale(i) - if (cpar%num_smooth_scales > 0 .and. smooth_scale >= 0) then + if (cpar%num_smooth_scales > 0 .and. smooth_scale > 0) then !ind. map with 1 map (will be smoothed like zero spin map using the existing code) tp => comm_map(info2) From a392607abc875886312fd1a9b0628b5f64e6be94 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 11:45:47 +0200 Subject: [PATCH 038/171] Deconvolve beam from input maps --- commander3/src/comm_diffuse_comp_smod.f90 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index c714698a7..dd3652709 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -119,6 +119,10 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%lmax_pre_lowl = -1 end if + ! Initialize output beam + self%B_out => comm_B_bl(cpar, self%x%info, 0, 0, fwhm=cpar%cs_fwhm(id_abs), nside=self%nside,& + & init_realspace=.false.) + ! Initialize amplitude map if (trim(cpar%cs_input_amp(id_abs)) == 'zero' .or. trim(cpar%cs_input_amp(id_abs)) == 'none') then self%x => comm_map(info) @@ -132,15 +136,15 @@ module subroutine initDiffuse(self, cpar, id, id_abs) do i = 0, self%x%info%nalm-1 call self%x%info%i2lm(i,l,m) - if (l < self%lmin_amp) self%x%alm(i,:) = 0.d0 + if (l < self%lmin_amp) then + self%x%alm(i,:) = 0.d0 + else + self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) + end if end do end if self%ncr = size(self%x%alm) - ! Initialize output beam - self%B_out => comm_B_bl(cpar, self%x%info, 0, 0, fwhm=cpar%cs_fwhm(id_abs), nside=self%nside,& - & init_realspace=.false.) - ! Read component mask if (trim(cpar%cs_mask(id_abs)) /= 'fullsky' .and. self%latmask < 0.d0) then self%mask => comm_map(self%x%info, trim(cpar%cs_mask(id_abs)), & From e6197807f352eaab2fa7aac0753f3f9c500ac9d6 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 12:22:31 +0200 Subject: [PATCH 039/171] Fixed init error --- commander3/src/comm_diffuse_comp_smod.f90 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index c2bc512c9..6c9fd9285 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -119,10 +119,6 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%lmax_pre_lowl = -1 end if - ! Initialize output beam - self%B_out => comm_B_bl(cpar, self%x%info, 0, 0, fwhm=cpar%cs_fwhm(id_abs), nside=self%nside,& - & init_realspace=.false.) - ! Initialize amplitude map if (trim(cpar%cs_input_amp(id_abs)) == 'zero' .or. trim(cpar%cs_input_amp(id_abs)) == 'none') then self%x => comm_map(info) @@ -136,15 +132,23 @@ module subroutine initDiffuse(self, cpar, id, id_abs) do i = 0, self%x%info%nalm-1 call self%x%info%i2lm(i,l,m) - if (l < self%lmin_amp) then - self%x%alm(i,:) = 0.d0 - else - self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) - end if + if (l < self%lmin_amp) self%x%alm(i,:) = 0.d0 end do end if self%ncr = size(self%x%alm) + ! Initialize output beam + self%B_out => comm_B_bl(cpar, self%x%info, 0, 0, fwhm=cpar%cs_fwhm(id_abs), nside=self%nside,& + & init_realspace=.false.) + + ! Deconvolve the existing beam if initialized from an input map + if (trim(cpar%cs_input_amp(id_abs)) /= 'zero' .and. trim(cpar%cs_input_amp(id_abs)) /= 'none') then + do i = 0, self%x%info%nalm-1 + call self%x%info%i2lm(i,l,m) + self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) + end do + end if + ! Read component mask if (trim(cpar%cs_mask(id_abs)) /= 'fullsky' .and. self%latmask < 0.d0) then self%mask => comm_map(self%x%info, trim(cpar%cs_mask(id_abs)), & From ecbbec8d6271f162314949c82f4e97100555ecf9 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 12:28:01 +0200 Subject: [PATCH 040/171] Fixed init error --- commander3/src/comm_diffuse_comp_smod.f90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 6c9fd9285..f0b4c6f46 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -145,7 +145,11 @@ module subroutine initDiffuse(self, cpar, id, id_abs) if (trim(cpar%cs_input_amp(id_abs)) /= 'zero' .and. trim(cpar%cs_input_amp(id_abs)) /= 'none') then do i = 0, self%x%info%nalm-1 call self%x%info%i2lm(i,l,m) - self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) + where (self%B_out%b_l(l,:) > 1d-6) + self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) + elsewhere + self%x%alm(i,:) = 0.d0 + end where end do end if From 81d7d430abc36107388cec37e8539e84dfd9d7db Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 12:44:57 +0200 Subject: [PATCH 041/171] Fixed init error --- commander3/src/comm_diffuse_comp_smod.f90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index f0b4c6f46..b43cbd772 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -147,6 +147,9 @@ module subroutine initDiffuse(self, cpar, id, id_abs) call self%x%info%i2lm(i,l,m) where (self%B_out%b_l(l,:) > 1d-6) self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) + if (l > 500) then + self%x%alm(i,:) = self%x%alm(i,:) * real((500.d0/l,dp)**20 + end if elsewhere self%x%alm(i,:) = 0.d0 end where From 149c9750704d7ba6603a180ed7c91d092ec3ca0b Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 12:46:27 +0200 Subject: [PATCH 042/171] Fixed init error --- commander3/src/comm_diffuse_comp_smod.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index b43cbd772..2f232feb4 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -147,12 +147,12 @@ module subroutine initDiffuse(self, cpar, id, id_abs) call self%x%info%i2lm(i,l,m) where (self%B_out%b_l(l,:) > 1d-6) self%x%alm(i,:) = self%x%alm(i,:) / self%B_out%b_l(l,:) - if (l > 500) then - self%x%alm(i,:) = self%x%alm(i,:) * real((500.d0/l,dp)**20 - end if elsewhere self%x%alm(i,:) = 0.d0 end where + if (l > 500) then + self%x%alm(i,:) = self%x%alm(i,:) * real((500.d0/l,dp)**20 + end if end do end if From f456d24277f676abc29c542f4d4250495b330d0c Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 6 Sep 2024 12:48:27 +0200 Subject: [PATCH 043/171] Fixed init error --- commander3/src/comm_diffuse_comp_smod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 2f232feb4..874c52497 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -151,7 +151,7 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%x%alm(i,:) = 0.d0 end where if (l > 500) then - self%x%alm(i,:) = self%x%alm(i,:) * real((500.d0/l,dp)**20 + self%x%alm(i,:) = self%x%alm(i,:) * real(500.d0/l,dp)**20 end if end do end if From 34f6d846425328aab966d5141e03fe6ccb98cc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Gjerl=C3=B8w?= Date: Wed, 18 Sep 2024 12:18:29 +0200 Subject: [PATCH 044/171] Make report_error actually end the program --- commander3/src/comm_utils.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_utils.f90 b/commander3/src/comm_utils.f90 index 74f9ea1dd..ebfa9d00b 100644 --- a/commander3/src/comm_utils.f90 +++ b/commander3/src/comm_utils.f90 @@ -603,8 +603,8 @@ subroutine report_error(message) call mpi_comm_rank(MPI_COMM_WORLD, myid, ierr) if (myid == 0) write(*,*) trim(message) - call mpi_finalize(ierr) - stop + + call mpi_abort(MPI_COMM_WORLD, 1, ierr) end subroutine report_error From a77fbefb5e7e55e4c40293b7d9e40fb24034c02b Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 26 Oct 2024 11:20:33 +0200 Subject: [PATCH 045/171] Restored hdf mod; simplified hfi baseline routine; moved scandata to comm_tod_mod to support nonlinear instrument corrections --- commander3/config/config.ita_internal | 8 +- commander3/src/comm_hdf_mod.f90 | 5416 +++++++++++++++++++++++ commander3/src/comm_hdf_mod.f90.in | 25 +- commander3/src/comm_tod_dirbe_mod.f90 | 8 +- commander3/src/comm_tod_driver_mod.f90 | 414 +- commander3/src/comm_tod_hfi_mod.f90 | 267 +- commander3/src/comm_tod_lb_mod.f90 | 8 +- commander3/src/comm_tod_lfi_smod.f90 | 12 +- commander3/src/comm_tod_mod.f90 | 33 +- commander3/src/comm_tod_quiet_smod.f90 | 8 +- commander3/src/comm_tod_spider_smod.f90 | 10 +- commander3/src/comm_tod_wmap_mod.f90 | 8 +- 12 files changed, 5819 insertions(+), 398 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index 93f5529cd..6d647d271 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -53,11 +53,11 @@ export MPCC := mpiicc #export F90FLAGS := -fpe0 -march=native -g -O2 -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -xHost #export F90FLAGS := -g -O2 -traceback #export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -prof-gen=srcpos -prof-dir=/mn/stornext/u3/hke/xsan/commander3/BP9/prof -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -diag-disable=10448 #debug # -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv +export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv @@ -71,7 +71,7 @@ export FFLAGS := -O2 export CFLAGS := -O3 # Extra flags used for linking -export LDFLAGS := -qopt-matmul -lm -qopenmp -cxxlib -parallel -mkl #-prof-file prof.dat -prof-dir . -profile-functions -profile-loops=all +export LDFLAGS := -qopt-matmul -lm -qopenmp -cxxlib -parallel -qmkl #-prof-file prof.dat -prof-dir . -profile-functions -profile-loops=all # ============== Language Mixing ================= @@ -86,7 +86,7 @@ export MPFCLIBS := -qopenmp # instead of lowercase (*.mod). #export FORTRAN_UPPER := 1 -export LOCAL=../../build +export LOCAL=../../build/install # =============== CFITSIO Linking ================ diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index e69de29bb..82446a1f6 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -0,0 +1,5416 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ +! Due to the extreme amount of redundancy in hdf_mod, it is now generated +! by using the handy tempita template language. All the machinery for +! doing this is included in the repository, so this should just work. +module comm_hdf_mod + use comm_utils + use hdf5 + implicit none + + type hdf_file + character(len=512) :: filename, setname + integer(hid_t) :: filehandle, sethandle + integer :: status + end type hdf_file + + type :: byte_pointer + byte, allocatable, dimension(:) :: p + ! contains + ! final :: dealloc_byte_pointer + end type byte_pointer + + interface read_hdf + module procedure read_hdf_0d_dp + module procedure read_hdf_0d_sp + module procedure read_hdf_0d_int + module procedure read_hdf_0d_char + module procedure read_hdf_1d_dp + module procedure read_hdf_1d_sp + module procedure read_hdf_1d_int + module procedure read_hdf_1d_char + module procedure read_hdf_2d_dp + module procedure read_hdf_2d_sp + module procedure read_hdf_2d_int + module procedure read_hdf_2d_char + module procedure read_hdf_3d_dp + module procedure read_hdf_3d_sp + module procedure read_hdf_3d_int + module procedure read_hdf_3d_char + module procedure read_hdf_4d_dp + module procedure read_hdf_4d_sp + module procedure read_hdf_4d_int + module procedure read_hdf_4d_char + module procedure read_hdf_5d_dp + module procedure read_hdf_5d_sp + module procedure read_hdf_5d_int + module procedure read_hdf_5d_char + module procedure read_hdf_6d_dp + module procedure read_hdf_6d_sp + module procedure read_hdf_6d_int + module procedure read_hdf_6d_char + module procedure read_hdf_7d_dp + module procedure read_hdf_7d_sp + module procedure read_hdf_7d_int + module procedure read_hdf_7d_char + module procedure read_hdf_slice_0d_dp + module procedure read_hdf_slice_0d_sp + module procedure read_hdf_slice_0d_int + module procedure read_hdf_slice_0d_char + module procedure read_hdf_slice_1d_dp + module procedure read_hdf_slice_1d_sp + module procedure read_hdf_slice_1d_int + module procedure read_hdf_slice_1d_char + module procedure read_hdf_slice_2d_dp + module procedure read_hdf_slice_2d_sp + module procedure read_hdf_slice_2d_int + module procedure read_hdf_slice_2d_char + module procedure read_hdf_slice_3d_dp + module procedure read_hdf_slice_3d_sp + module procedure read_hdf_slice_3d_int + module procedure read_hdf_slice_3d_char + module procedure read_hdf_slice_4d_dp + module procedure read_hdf_slice_4d_sp + module procedure read_hdf_slice_4d_int + module procedure read_hdf_slice_4d_char + module procedure read_hdf_slice_5d_dp + module procedure read_hdf_slice_5d_sp + module procedure read_hdf_slice_5d_int + module procedure read_hdf_slice_5d_char + module procedure read_hdf_slice_6d_dp + module procedure read_hdf_slice_6d_sp + module procedure read_hdf_slice_6d_int + module procedure read_hdf_slice_6d_char + module procedure read_hdf_slice_7d_dp + module procedure read_hdf_slice_7d_sp + module procedure read_hdf_slice_7d_int + module procedure read_hdf_slice_7d_char + end interface + + interface read_alloc_hdf + module procedure read_alloc_hdf_1d_dp + module procedure read_alloc_hdf_1d_sp + module procedure read_alloc_hdf_1d_int + module procedure read_alloc_hdf_1d_char + module procedure read_alloc_hdf_2d_dp + module procedure read_alloc_hdf_2d_sp + module procedure read_alloc_hdf_2d_int + module procedure read_alloc_hdf_2d_char + module procedure read_alloc_hdf_3d_dp + module procedure read_alloc_hdf_3d_sp + module procedure read_alloc_hdf_3d_int + module procedure read_alloc_hdf_3d_char + module procedure read_alloc_hdf_4d_dp + module procedure read_alloc_hdf_4d_sp + module procedure read_alloc_hdf_4d_int + module procedure read_alloc_hdf_4d_char + module procedure read_alloc_hdf_5d_dp + module procedure read_alloc_hdf_5d_sp + module procedure read_alloc_hdf_5d_int + module procedure read_alloc_hdf_5d_char + module procedure read_alloc_hdf_6d_dp + module procedure read_alloc_hdf_6d_sp + module procedure read_alloc_hdf_6d_int + module procedure read_alloc_hdf_6d_char + module procedure read_alloc_hdf_7d_dp + module procedure read_alloc_hdf_7d_sp + module procedure read_alloc_hdf_7d_int + module procedure read_alloc_hdf_7d_char + end interface + + interface write_hdf + module procedure write_hdf_0d_dp + module procedure write_hdf_0d_sp + module procedure write_hdf_0d_int + module procedure write_hdf_0d_char + module procedure write_hdf_1d_dp + module procedure write_hdf_1d_sp + module procedure write_hdf_1d_int + module procedure write_hdf_1d_char + module procedure write_hdf_2d_dp + module procedure write_hdf_2d_sp + module procedure write_hdf_2d_int + module procedure write_hdf_2d_char + module procedure write_hdf_3d_dp + module procedure write_hdf_3d_sp + module procedure write_hdf_3d_int + module procedure write_hdf_3d_char + module procedure write_hdf_4d_dp + module procedure write_hdf_4d_sp + module procedure write_hdf_4d_int + module procedure write_hdf_4d_char + module procedure write_hdf_5d_dp + module procedure write_hdf_5d_sp + module procedure write_hdf_5d_int + module procedure write_hdf_5d_char + module procedure write_hdf_6d_dp + module procedure write_hdf_6d_sp + module procedure write_hdf_6d_int + module procedure write_hdf_6d_char + module procedure write_hdf_7d_dp + module procedure write_hdf_7d_sp + module procedure write_hdf_7d_int + module procedure write_hdf_7d_char + module procedure write_hdf_slice_0d_dp + module procedure write_hdf_slice_0d_sp + module procedure write_hdf_slice_0d_int + module procedure write_hdf_slice_0d_char + module procedure write_hdf_slice_1d_dp + module procedure write_hdf_slice_1d_sp + module procedure write_hdf_slice_1d_int + module procedure write_hdf_slice_1d_char + module procedure write_hdf_slice_2d_dp + module procedure write_hdf_slice_2d_sp + module procedure write_hdf_slice_2d_int + module procedure write_hdf_slice_2d_char + module procedure write_hdf_slice_3d_dp + module procedure write_hdf_slice_3d_sp + module procedure write_hdf_slice_3d_int + module procedure write_hdf_slice_3d_char + module procedure write_hdf_slice_4d_dp + module procedure write_hdf_slice_4d_sp + module procedure write_hdf_slice_4d_int + module procedure write_hdf_slice_4d_char + module procedure write_hdf_slice_5d_dp + module procedure write_hdf_slice_5d_sp + module procedure write_hdf_slice_5d_int + module procedure write_hdf_slice_5d_char + module procedure write_hdf_slice_6d_dp + module procedure write_hdf_slice_6d_sp + module procedure write_hdf_slice_6d_int + module procedure write_hdf_slice_6d_char + module procedure write_hdf_slice_7d_dp + module procedure write_hdf_slice_7d_sp + module procedure write_hdf_slice_7d_int + module procedure write_hdf_slice_7d_char + end interface + + interface slice + module procedure slice_0d + module procedure slice_1d + module procedure slice_2d + module procedure slice_3d + module procedure slice_4d + module procedure slice_5d + module procedure slice_6d + module procedure slice_7d + end interface + +contains + + ! ***************************************************** + ! Initialization and cleanup routines + ! ***************************************************** + subroutine initialize_comm_hdf_mod + implicit none + logical(lgt), save :: initialized = .false. + integer(i4b) :: status + if(initialized) return + call h5open_f(status) + call assert(status==0, 'comm_hdf_mod: Could not initialize hdf module') + initialized = .true. + end subroutine initialize_comm_hdf_mod + + subroutine cleanup_comm_hdf_mod + implicit none + integer(i4b) :: status + call h5close_f(status) + call assert(status==0, 'comm_hdf_mod: Could not close hdf module') + end subroutine cleanup_comm_hdf_mod + + subroutine copy_hdf_struct(file_in, file_out) + implicit none + type(hdf_file), intent(in) :: file_in + type(hdf_file), intent(out) :: file_out + + file_out%filename = file_in%filename + file_out%setname = file_in%setname + file_out%filehandle = file_in%filehandle + file_out%sethandle = file_in%sethandle + file_out%status = file_in%status + + end subroutine copy_hdf_struct + + + ! ***************************************************** + ! Basic file open and close routines + ! ***************************************************** + subroutine open_hdf_file(filename, file, mode) + implicit none + character(len=*), intent(in) :: filename + character(len=1), intent(in) :: mode + type(hdf_file) :: file + + ! Initialize + call initialize_comm_hdf_mod + + ! Open file in either read or write mode + file%filename = filename + file%status = 0 + if (mode == 'r') then + call h5fopen_f(file%filename, H5F_ACC_RDONLY_F, file%filehandle, file%status) + else if (mode == 'w') then + call h5fcreate_f(file%filename, H5F_ACC_TRUNC_F, file%filehandle, file%status) + else if (mode == 'b') then + call h5fopen_f(file%filename, H5F_ACC_RDWR_F, file%filehandle, file%status) + else + write(*,*) 'comm_hdf_mod: Unknown hdf file mode =', mode + stop + end if + + ! Initalize sethandle to empty value + file%setname = '' + file%sethandle = -1 + end subroutine open_hdf_file + + subroutine close_hdf_file(file) + implicit none + type(hdf_file) :: file + call close_hdf_set(file) + call h5fclose_f(file%filehandle, file%status) + call assert(file%status>=0, 'comm_hdf_mod: Could not close file') + end subroutine close_hdf_file + + subroutine open_hdf_set(file, setname) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + if (trim(file%setname) == trim(setname)) return + call close_hdf_set(file) + file%setname = setname + call h5dopen_f(file%filehandle, file%setname, file%sethandle, file%status) + end subroutine open_hdf_set + + subroutine close_hdf_set(file) + implicit none + type(hdf_file) :: file + if (file%sethandle == -1) return + call h5dclose_f(file%sethandle, file%status) + call assert(file%status>=0, 'comm_hdf_mod: Could not close set' // file%setname // ' in ' // file%filename) + file%sethandle = -1 + file%setname = '' + end subroutine close_hdf_set + + ! ***************************************************** + ! Query operations + ! ***************************************************** + function get_rank_hdf(file, setname) result(rank) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) :: rank + integer(hid_t) :: space + call open_hdf_set(file, setname) + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_ndims_f(space, rank, file%status) + call h5sclose_f(space, file%status) + end function + + subroutine get_size_hdf(file, setname, ext) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(out) :: ext(:) + integer(i4b) :: rank + integer(hid_t) :: space, n + integer(hsize_t), allocatable, dimension(:) :: ext_hdf, mext_hdf + call open_hdf_set(file, setname) + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_ndims_f(space, rank, file%status) + allocate(ext_hdf(rank), mext_hdf(rank)) + call h5sget_simple_extent_dims_f(space, ext_hdf, mext_hdf, file%status) + call h5sclose_f(space, file%status) + if (file%status == -1) then + write(*,*) 'Error reading file ', trim(file%filename), trim(setname) + stop + end if + n = min(size(ext),rank) + ext(:n) = int(ext_hdf(:n),i4b) + deallocate(ext_hdf, mext_hdf) + end subroutine get_size_hdf + + function hdf_group_exists(file, group) result(exists) + type(hdf_file) :: file + character(len=*), intent(in) :: group + logical(lgt) :: exists + integer(i4b) :: hdferr + TYPE(h5o_info_t) :: object_info + + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, trim(adjustl(group)), object_info, hdferr) + exists = hdferr == 0 + end function hdf_group_exists + + ! ***************************************************** + ! Set read operations + ! ***************************************************** + + subroutine read_hdf_dp_2d_buffer(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(dp), dimension(:,:), intent(out) :: val + real(dp), dimension(:,:), allocatable :: buffer + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + return + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + call get_size_hdf(file, setname, ext) + allocate(buffer(ext(1),ext(2))) + ext2 = ext + ! Validate that sizes are consistent + !call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, buffer, ext2, file%status) + val = buffer(1:s(1),1:s(2)) + deallocate(buffer) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_int_2d_buffer(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + integer(i4b), dimension(:,:), intent(out) :: val + integer(i4b), dimension(:,:), allocatable :: buffer + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + return + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + call get_size_hdf(file, setname, ext) + allocate(buffer(ext(1),ext(2))) + ext2 = ext + ! Validate that sizes are consistent + !call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, buffer, ext2, file%status) + val = buffer(1:s(1),1:s(2)) + deallocate(buffer) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + real(dp) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + real(sp) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + integer(i4b) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + character(len=*) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + real(dp) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + real(sp) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + integer(i4b) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + character(len=*) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(dp) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(sp) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + integer(i4b) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + character(len=*) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + real(dp) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + real(sp) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + integer(i4b) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + character(len=*) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + real(dp) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + real(sp) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + integer(i4b) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + character(len=*) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + real(dp) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + real(sp) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + character(len=*) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + ! reads a 1-d array of string into an unallocated buffer + ! this now actually works so if you need to read a n-d array of strings + ! you could use this as a starting point + + subroutine read_alloc_hdf_1d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:), allocatable, target, intent(out) :: val + integer(i4b) :: n(1), i, j, length + integer(hsize_t), dimension(1:1) :: dims, maxdims + integer(i4b) :: ext(1) + type(c_ptr) :: f_ptr + integer(hid_t) :: space, memtype, filetype + integer(size_t), parameter :: sdim = 8 + integer(size_t) :: datasize + TYPE(C_PTR), DIMENSION(:), ALLOCATABLE, TARGET :: rdata ! Read buffer + + character(len=8, kind=c_char), pointer :: readable_data + + if(allocated(val)) deallocate(val) + + call open_hdf_set(file, setname) + + call h5dget_type_f(file%sethandle, filetype, file%status) + + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_dims_f(space, dims, maxdims, file%status) + + allocate(rdata(dims(1))) + + call H5Tget_size_f(filetype, datasize, file%status) + + f_ptr = C_LOC(rdata(1)) + + call h5dread_f(file%sethandle, filetype, f_ptr, file%status)!, space) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + + allocate(val(dims(1))) + + ! convert each c string to a fortran string + do i=1, dims(1) + call c_f_pointer(rdata(i), readable_data) + length = 0 + do + ! determine lengths by looking for c end of string character + if(readable_data(length+1:length+1) == C_NULL_CHAR .or. length >= sdim) exit + length = length +1 + end do + val(i) = readable_data(1:length) + end do + + deallocate(rdata) + + end subroutine + + subroutine read_alloc_hdf_2d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + + subroutine read_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, allocatable, dimension(:), target, intent(out) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, dtype, file%status) + call h5tget_size_f(dtype, len, file%status) + numint = len + allocate(val(numint)) + f_ptr = c_loc(val) + call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + call h5tclose_f(dtype, file%status) + end subroutine read_hdf_opaque + + + subroutine write_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, dimension(:), target, intent(in) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + !call open_hdf_set(file, setname) + !call h5dget_type_f(file%sethandle, dtype, file%status) + !call h5tget_size_f(dtype, len, file%status) + !numint = len + !allocate(val(numint)) + !f_ptr = c_loc(val) + !call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + !call h5tclose_f(dtype, file%status) + end subroutine write_hdf_opaque + + subroutine read_hdf_vlen(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + type(byte_pointer), dimension(:), intent(inout) :: val + + INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles + INTEGER :: hdferr + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims + INTEGER :: i, j + integer, dimension(:), pointer :: ptr_r + + ! vl data + TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures + TYPE(C_PTR) :: f_ptr + !type(byte_pointer), allocatable, dimension(:) :: r_ptr + byte, pointer, dimension(:) :: r_ptr + + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, filetype, hdferr) + CALL h5dget_space_f(file%sethandle, space, hdferr) + + CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + allocate(rdata(dims(1))) + + CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) + ! Get address of the C pointer corresponding + ! to the first element of our data + f_ptr = C_LOC(rdata(1)) + CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) + ! + ! Write the variable-length data to the fortran array + ! + allocate(r_ptr(dims(1))) + DO i = 1, dims(1) + !WRITE(*,'(A,"(",I0,"):",/,"{")', ADVANCE="no") setname,i + !CALL c_f_pointer(rdata(i)%p, r_ptr(i)%p, [rdata(i)%len] ) + CALL c_f_pointer(rdata(i)%p, r_ptr, [rdata(i)%len] ) + !allocate(val(i)%p(size(r_ptr(i)%p))) + allocate(val(i)%p(size(r_ptr))) + !val(i)%p(:) = r_ptr(i)%p(:) + val(i)%p(:) = r_ptr + + !DO j = 1, rdata(i)%len + ! WRITE(*,'(1X,I0)', ADVANCE='no') val(i)%p(j) + ! IF ( j .LT. rdata(i)%len) WRITE(*,'(",")', ADVANCE='no') + !ENDDO + !WRITE(*,'( " }")') + + ENDDO + ! + ! Close and release resources. Note the use of H5Dvlen_reclaim + ! removes the need to manually deallocate the previously allocated + ! data. + ! + ! Not clear if this line is good or not. It could be de-allocating the read + ! memory that we are now pointing to, but I am not sure + CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) + CALL h5dclose_f(dset , hdferr) + CALL h5sclose_f(space, hdferr) + CALL h5tclose_f(filetype, hdferr) + call close_hdf_set(file) + CALL h5tclose_f(memtype, hdferr) + !deallocate(r_ptr, rdata) + deallocate(rdata) + ! deallocate(rdata) + + end subroutine read_hdf_vlen + + subroutine get_hdf_vlen_ext(file, setname, ext) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), dimension(:), intent(out) :: ext + + INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles + INTEGER :: hdferr + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims + INTEGER :: i, j + integer, dimension(:), pointer :: ptr_r + + ! vl data + TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures + TYPE(C_PTR) :: f_ptr + + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, filetype, hdferr) + CALL h5dget_space_f(file%sethandle, space, hdferr) + CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + allocate(rdata(dims(1))) + CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) + f_ptr = C_LOC(rdata(1)) + CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) + ext(:) = rdata(:)%len + + CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) + CALL h5dclose_f(dset , hdferr) + CALL h5sclose_f(space, hdferr) + CALL h5tclose_f(filetype, hdferr) + call close_hdf_set(file) + CALL h5tclose_f(memtype, hdferr) + deallocate(rdata) + + end subroutine get_hdf_vlen_ext + + subroutine read_hdf_string(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*), intent(out) :: val + + integer(i4b), parameter :: mlen=10000 + integer(hid_t) :: filetype, space + integer(size_t), dimension(1) :: len + integer(hsize_t), dimension(1:2) :: data_dims + integer :: hdferr + character(mlen), allocatable, dimension(:) :: rdata + + call open_hdf_set(file, setname) + CALL H5Dget_type_f(file%sethandle, filetype, hdferr) + CALL H5Dget_space_f(file%sethandle, space, hdferr) + ALLOCATE(rdata(1)) + len=mlen + data_dims = [mlen,1] + CALL h5dread_vl_f(file%sethandle, filetype, rdata, data_dims, len, hdferr, space) + val = rdata(1) + DEALLOCATE(rdata) + call close_hdf_set(file) + CALL h5sclose_f(space, hdferr) + CALL H5Tclose_f(filetype, hdferr) + + end subroutine read_hdf_string + + + subroutine read_hdf_string2(file, setname, val, n) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*), intent(out) :: val + integer(i4b), intent(out) :: n + + integer(i4b), parameter :: mlen=100000 + integer(hid_t) :: filetype, space + INTEGER(SIZE_T) :: size + !integer(size_t), dimension(1) :: len + !integer(hsize_t), dimension(1:2) :: data_dims + INTEGER(HSIZE_T), DIMENSION(1:1) :: dims = (/mlen/) + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims + integer :: hdferr + !character(len=mlen), dimension(1) :: rdata + character(len=mlen) :: rdata + + call open_hdf_set(file, setname) + CALL H5Dget_type_f(file%sethandle, filetype, hdferr) + CALL H5Tget_size_f(filetype, size, hdferr) + CALL H5Dget_space_f(file%sethandle, space, hdferr) + CALL H5Sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + call h5dread_f(file%sethandle, filetype, rdata, dims, hdferr, H5S_ALL_F, H5S_ALL_F, H5P_DEFAULT_F) + val = rdata(1:size) + n = int(size,i4b) + + call close_hdf_set(file) + CALL h5sclose_f(space, hdferr) + CALL H5Tclose_f(filetype, hdferr) + + end subroutine read_hdf_string2 + + ! ***************************************************** + ! Set write operations + ! ***************************************************** + + subroutine write_hdf_0d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) , intent(in) :: val + real(dp), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) , intent(in) :: val + real(sp), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) , intent(in) :: val + integer(i4b), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) , intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_1d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:), intent(in) :: val + real(dp), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:), intent(in) :: val + real(sp), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:), intent(in) :: val + integer(i4b), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_2d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_3d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_4d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_5d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_6d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_7d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + + ! ***************************************************** + ! Sliced set operations. + ! These are like read/write, but the dataset is + ! indexed with a slice. Note that the dataset must + ! exist beforehand. Use create_hdf_set for this. + ! ***************************************************** + + subroutine read_hdf_slice_0d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + + ! ***************************************************** + ! Optional Reads + ! ***************************************************** + + + ! ***************************************************** + ! Dataset creation operation + ! ***************************************************** + subroutine create_hdf_set(file, setname, ext, type_id) + implicit none + + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), dimension(:), intent(in) :: ext + integer(hid_t) :: type_id + integer(hid_t) :: space + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + if (trim(file%setname) /= trim(setname)) call close_hdf_set(file) + !write(*,*) trim(file%setname), trim(setname) + file%setname = setname + allocate(ext_hdf(size(shape(ext)))) + ext_hdf = int(ext, hsize_t) + call h5screate_simple_f(size(ext), ext_hdf, space, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot create data space, "//trim(file%filename)//', '//trim(setname)) + !write(*,*) trim(file%setname), type_id, space, file%sethandle, file%status, ext + call h5dcreate_f(file%filehandle, file%setname, type_id, space, file%sethandle, file%status) + !write(*,*) ' HDF status = ', file%status + call h5eprint_f(file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot create data set "//trim(file%filename)//', '//trim(setname)) + call h5sclose_f(space, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot close data space") + deallocate(ext_hdf) + end subroutine create_hdf_set + + ! Group creation. Once created, they can be used by specifying "group/dset" instead + ! of just "dset". + subroutine create_hdf_group(file, group) + implicit none + type(hdf_file) :: file + character(len=*) :: group + integer(hid_t) :: gid + call h5gcreate_f(file%filehandle, group, gid, file%status) + call h5gclose_f(gid, file%status) + end subroutine + + ! ********************** + ! Helper functions + ! ********************** + + function slice_0d() result(res) + implicit none + integer(i4b) :: res(3,0) + res = 0 + end function + + function slice_1d(s0) result(res) + implicit none + integer(i4b), dimension(:) :: s0(:) + integer(i4b) :: res(3,1) + select case(size(s0)) + case(0); res(:,1) = [1,-1,1] + case(1); res(:,1) = [s0(1),s0(1),1] + case(2); res(:,1) = [s0(1),s0(2),1] + case(3:); res(:,1) = s0 + end select + end function + + function slice_2d(s0,s1) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1 + integer(i4b) :: res(3,2) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + end function + + function slice_3d(s0,s1,s2) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2 + integer(i4b) :: res(3,3) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + end function + + function slice_4d(s0,s1,s2,s3) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3 + integer(i4b) :: res(3,4) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + end function + + function slice_5d(s0,s1,s2,s3,s4) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4 + integer(i4b) :: res(3,5) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + end function + + function slice_6d(s0,s1,s2,s3,s4,s5) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5 + integer(i4b) :: res(3,6) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + res(:,6:6) = slice_1d(s5) + end function + + function slice_7d(s0,s1,s2,s3,s4,s5,s6) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5,s6 + integer(i4b) :: res(3,7) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + res(:,6:6) = slice_1d(s5) + res(:,7:7) = slice_1d(s6) + end function + + function parse_hdf_slice(slice, ext) result(hslice) + implicit none + integer(i4b), intent(in) :: slice(:,:), ext(:) + integer(i4b) :: hslice(3,size(slice,2)) + hslice = slice + ! Negative indices count from the end, with -1 being the last valid index + where(hslice([1,2],:) < 0) hslice([1,2],:) = hslice([1,2],:) + spread(ext,1,2) + 1 + ! We need to translate "to" into "count" + hslice(2,:) = (hslice(2,:)-hslice(1,:)+hslice(3,:))/hslice(3,:) + ! 0 based + hslice(1,:) = hslice(1,:) - 1 + end function + +end module comm_hdf_mod + diff --git a/commander3/src/comm_hdf_mod.f90.in b/commander3/src/comm_hdf_mod.f90.in index 970461013..02a7aba72 100644 --- a/commander3/src/comm_hdf_mod.f90.in +++ b/commander3/src/comm_hdf_mod.f90.in @@ -213,6 +213,10 @@ contains allocate(ext_hdf(rank), mext_hdf(rank)) call h5sget_simple_extent_dims_f(space, ext_hdf, mext_hdf, file%status) call h5sclose_f(space, file%status) + if (file%status == -1) then + write(*,*) 'Error reading file ', trim(file%filename), trim(setname) + stop + end if n = min(size(ext),rank) ext(:n) = int(ext_hdf(:n),i4b) deallocate(ext_hdf, mext_hdf) @@ -390,7 +394,6 @@ contains type(hdf_file) :: file character(len=*), intent(in) :: setname byte, allocatable, dimension(:), target, intent(out) :: val - !byte, dimension(:), pointer, intent(out) :: val integer(hid_t) :: dtype integer(size_t) :: len, numint @@ -405,6 +408,26 @@ contains call h5tclose_f(dtype, file%status) end subroutine read_hdf_opaque + + subroutine write_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, dimension(:), target, intent(in) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + !call open_hdf_set(file, setname) + !call h5dget_type_f(file%sethandle, dtype, file%status) + !call h5tget_size_f(dtype, len, file%status) + !numint = len + !allocate(val(numint)) + !f_ptr = c_loc(val) + !call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + !call h5tclose_f(dtype, file%status) + end subroutine write_hdf_opaque + subroutine read_hdf_vlen(file, setname, val) implicit none type(hdf_file) :: file diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index e69e2c73c..04c6eb4ec 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -337,11 +337,11 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) @@ -398,7 +398,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_buf, d_calib) end do diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 1b1318eb3..1f23dd6ed 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -13,49 +13,16 @@ module comm_tod_driver_mod use omp_lib implicit none - - ! Class for uncompressed data for a given scan - type :: comm_scandata - integer(i4b) :: ntod, ndet, nhorn, ndelta - real(sp), allocatable, dimension(:,:) :: tod ! Raw data - real(sp), allocatable, dimension(:,:) :: n_corr ! Correlated noise in V - real(sp), allocatable, dimension(:,:) :: s_sl ! Sidelobe correction - real(sp), allocatable, dimension(:,:) :: s_sky ! Stationary sky signal - real(sp), allocatable, dimension(:,:,:) :: s_sky_prop ! Stationary sky signal proposal for bandpass sampling - real(sp), allocatable, dimension(:,:) :: s_orb ! Orbital dipole - real(sp), allocatable, dimension(:,:) :: s_mono ! Detector monopole correction - real(sp), allocatable, dimension(:,:) :: s_bp ! Bandpass correction - real(sp), allocatable, dimension(:,:,:) :: s_bp_prop ! Bandpass correction proposal - real(sp), allocatable, dimension(:,:) :: s_zodi ! Zodiacal light - real(sp), allocatable, dimension(:,:) :: s_inst ! Instrument-specific correction template - real(sp), allocatable, dimension(:,:) :: s_tot ! Total signal - real(sp), allocatable, dimension(:,:) :: mask ! TOD mask (flags + main processing mask) - real(sp), allocatable, dimension(:,:) :: mask2 ! Small TOD mask, for bandpass sampling - integer(i4b), allocatable, dimension(:,:,:) :: pix ! Discretized pointing - integer(i4b), allocatable, dimension(:,:,:) :: psi ! Discretized polarization angle - integer(i4b), allocatable, dimension(:,:) :: flag ! Quality flags - - real(sp), allocatable, dimension(:,:) :: s_totA ! Total signal, horn A (differential only) - real(sp), allocatable, dimension(:,:) :: s_totB ! Total signal, horn B (differential only) - real(sp), allocatable, dimension(:,:) :: s_orbA ! Orbital signal, horn A (differential only) - real(sp), allocatable, dimension(:,:) :: s_orbB ! Orbital signal, horn B (differential only) - contains - procedure :: init_singlehorn => init_scan_data_singlehorn - procedure :: init_differential => init_scan_data_differential - procedure :: dealloc => dealloc_scan_data - end type comm_scandata - - contains !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Scan data routines !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmask2, & + subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2, & & init_s_bp, init_s_bp_prop, init_s_sky_prop) implicit none - class(comm_scandata), intent(inout) :: self + class(comm_scandata), intent(inout) :: sd class(comm_tod), intent(inout) :: tod integer(i4b), intent(in) :: scan real(sp), dimension(1:,1:,0:,1:), intent(in) :: map_sky @@ -84,61 +51,61 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas end if !if (.true. .or. tod%myid == 78) write(*,*) 'c1', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires - self%ntod = tod%scans(scan)%ntod - self%ndet = tod%ndet - self%nhorn = tod%nhorn - self%ndelta = 0; if (init_s_sky_prop_ .or. init_s_bp_prop_) self%ndelta = size(map_sky,4) + sd%ntod = tod%scans(scan)%ntod + sd%ndet = tod%ndet + sd%nhorn = tod%nhorn + sd%ndelta = 0; if (init_s_sky_prop_ .or. init_s_bp_prop_) sd%ndelta = size(map_sky,4) ! Allocate data structures - allocate(self%tod(self%ntod, self%ndet)) - allocate(self%n_corr(self%ntod, self%ndet)) - allocate(self%s_sl(self%ntod, self%ndet)) - allocate(self%s_sky(self%ntod, self%ndet)) - allocate(self%s_bp(self%ntod, self%ndet)) - allocate(self%s_orb(self%ntod, self%ndet)) - allocate(self%s_tot(self%ntod, self%ndet)) - allocate(self%mask(self%ntod, self%ndet)) - allocate(self%pix(self%ntod, self%ndet, self%nhorn)) - allocate(self%psi(self%ntod, self%ndet, self%nhorn)) - allocate(self%flag(self%ntod, self%ndet)) - if (init_s_sky_prop_) allocate(self%s_sky_prop(self%ntod, self%ndet, 2:self%ndelta)) - if (init_s_bp_prop_) allocate(self%s_bp_prop(self%ntod, self%ndet, 2:self%ndelta)) - if (init_s_sky_prop_) allocate(self%mask2(self%ntod, self%ndet)) - if (tod%sample_mono) allocate(self%s_mono(self%ntod, self%ndet)) - if (tod%subtract_zodi) allocate(self%s_zodi(self%ntod, self%ndet)) - if (tod%apply_inst_corr) allocate(self%s_inst(self%ntod, self%ndet)) + allocate(sd%tod(sd%ntod, sd%ndet)) + allocate(sd%n_corr(sd%ntod, sd%ndet)) + allocate(sd%s_sl(sd%ntod, sd%ndet)) + allocate(sd%s_sky(sd%ntod, sd%ndet)) + allocate(sd%s_bp(sd%ntod, sd%ndet)) + allocate(sd%s_orb(sd%ntod, sd%ndet)) + allocate(sd%s_tot(sd%ntod, sd%ndet)) + allocate(sd%mask(sd%ntod, sd%ndet)) + allocate(sd%pix(sd%ntod, sd%ndet, sd%nhorn)) + allocate(sd%psi(sd%ntod, sd%ndet, sd%nhorn)) + allocate(sd%flag(sd%ntod, sd%ndet)) + if (init_s_sky_prop_) allocate(sd%s_sky_prop(sd%ntod, sd%ndet, 2:sd%ndelta)) + if (init_s_bp_prop_) allocate(sd%s_bp_prop(sd%ntod, sd%ndet, 2:sd%ndelta)) + if (init_s_sky_prop_) allocate(sd%mask2(sd%ntod, sd%ndet)) + if (tod%sample_mono) allocate(sd%s_mono(sd%ntod, sd%ndet)) + if (tod%subtract_zodi) allocate(sd%s_zodi(sd%ntod, sd%ndet)) + if (tod%apply_inst_corr) allocate(sd%s_inst(sd%ntod, sd%ndet)) !call update_status(status, "todinit_alloc") !if (.true. .or. tod%myid == 78) write(*,*) 'c2', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires ! Decompress pointing, psi and flags for current scan call timer%start(TOD_DECOMP, tod%band) - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - call tod%decompress_pointing_and_flags(scan, j, self%pix(:,j,:), & - & self%psi(:,j,:), self%flag(:,j)) + call tod%decompress_pointing_and_flags(scan, j, sd%pix(:,j,:), & + & sd%psi(:,j,:), sd%flag(:,j)) end do call timer%stop(TOD_DECOMP, tod%band) !call update_status(status, "todinit_decomp") !if (tod%myid == 78) write(*,*) 'c3', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires - if (tod%symm_flags) call tod%symmetrize_flags(self%flag) + if (tod%symm_flags) call tod%symmetrize_flags(sd%flag) !call update_status(status, "todinit_symmflag") !if (.true. .or. tod%myid == 78) write(*,*) 'c4', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires ! Prepare TOD if (tod%ndiode == 1) then call timer%start(TOD_DECOMP, tod%band) - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle if (tod%compressed_tod) then - call tod%decompress_tod(scan, j, self%tod(:,j)) + call tod%decompress_tod(scan, j, sd%tod(:,j)) else - self%tod(:,j) = tod%scans(scan)%d(j)%tod + sd%tod(:,j) = tod%scans(scan)%d(j)%tod end if end do call timer%stop(TOD_DECOMP, tod%band) else - call tod%diode2tod_inst(scan, map_sky, procmask, self%tod) + call tod%diode2tod_inst(scan, map_sky, procmask, sd%tod) end if !call update_status(status, "todinit_tod") !if (.true. .or. tod%myid == 78) write(*,*) 'c5', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires @@ -146,27 +113,27 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas ! Construct sky signal template call timer%start(TOD_PROJECT, tod%band) if (init_s_bp_) then - call project_sky(tod, map_sky(:,:,:,1), self%pix(:,:,1), self%psi(:,:,1), self%flag, & - & procmask, scan, self%s_sky, self%mask, s_bp=self%s_bp) + call project_sky(tod, map_sky(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask, scan, sd%s_sky, sd%mask, s_bp=sd%s_bp) else - call project_sky(tod, map_sky(:,:,:,1), self%pix(:,:,1), self%psi(:,:,1), self%flag, & - & procmask, scan, self%s_sky, self%mask) + call project_sky(tod, map_sky(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask, scan, sd%s_sky, sd%mask) end if !call update_status(status, "todinit_sky") !if (tod%myid == 78) write(*,*) 'c6', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires ! Set up (optional) bandpass sampling quantities (s_sky_prop, mask2 and bp_prop) if (init_s_bp_prop_) then - do j = 2, self%ndelta + do j = 2, sd%ndelta !if (.true. .or. tod%myid == 78) write(*,*) 'c61', j, tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires, size(map_sky,4) - call project_sky(tod, map_sky(:,:,:,j), self%pix(:,:,1), self%psi(:,:,1), self%flag, & - & procmask2, scan, self%s_sky_prop(:,:,j), self%mask2, s_bp=self%s_bp_prop(:,:,j)) + call project_sky(tod, map_sky(:,:,:,j), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask2, scan, sd%s_sky_prop(:,:,j), sd%mask2, s_bp=sd%s_bp_prop(:,:,j)) end do else if (init_s_sky_prop_) then - do j = 2, self%ndelta + do j = 2, sd%ndelta !if (.true. .or. tod%myid == 78) write(*,*) 'c62', j, tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires - call project_sky(tod, map_sky(:,:,:,j), self%pix(:,:,1), self%psi(:,:,1), self%flag, & - & procmask2, scan, self%s_sky_prop(:,:,j), self%mask2) + call project_sky(tod, map_sky(:,:,:,j), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask2, scan, sd%s_sky_prop(:,:,j), sd%mask2) end do end if call timer%stop(TOD_PROJECT, tod%band) @@ -176,9 +143,9 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas !if (.true. .or. tod%myid == 78) write(*,*) 'c73', tod%myid, tod%slconv(1)%p%psires ! Perform sanity tests - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - if (all(self%mask(:,j) == 0)) tod%scans(scan)%d(j)%accept = .false. + if (all(sd%mask(:,j) == 0)) tod%scans(scan)%d(j)%accept = .false. if (tod%scans(scan)%d(j)%N_psd%sigma0 <= 0.d0) tod%scans(scan)%d(j)%accept = .false. end do !call update_status(status, "todinit_sanity") @@ -186,14 +153,14 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas ! Construct orbital dipole template call timer%start(TOD_ORBITAL, tod%band) - call tod%construct_dipole_template(scan, self%pix(:,:,1), self%psi(:,:,1), self%s_orb) + call tod%construct_dipole_template(scan, sd%pix(:,:,1), sd%psi(:,:,1), sd%s_orb) call timer%stop(TOD_ORBITAL, tod%band) !if (.true. .or. tod%myid == 78) write(*,*) 'c9', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires ! Construct zodical light template if (tod%subtract_zodi) then call timer%start(TOD_ZODI, tod%band) - call compute_zodi_template(tod%nside, self%pix(:,:,1), tod%scans(scan)%satpos, tod%nu_c, self%s_zodi) + call compute_zodi_template(tod%nside, sd%pix(:,:,1), tod%scans(scan)%satpos, tod%nu_c, sd%s_zodi) call timer%stop(TOD_ZODI, tod%band) end if !if (.true. .or. tod%myid == 78) write(*,*) 'c10', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires @@ -202,24 +169,24 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas !if (.true. .or. tod%myid == 78) write(*,*) 'd', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires if (tod%correct_sl) then call timer%start(TOD_SL_INT, tod%band) - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle !if (.true. .or. tod%myid == 78) write(*,*) 'e', tod%myid, j, tod%slconv(j)%p%psires, tod%slconv(j)%p%psisteps call tod%construct_sl_template(tod%slconv(j)%p, & - & self%pix(:,j,1), self%psi(:,j,1), self%s_sl(:,j), tod%mbang(j)) - self%s_sl(:,j) = 2.d0 * self%s_sl(:,j) ! Scaling by a factor of 2, by comparison with LevelS. Should be understood + & sd%pix(:,j,1), sd%psi(:,j,1), sd%s_sl(:,j), tod%mbang(j)) + sd%s_sl(:,j) = 2.d0 * sd%s_sl(:,j) ! Scaling by a factor of 2, by comparison with LevelS. Should be understood end do call timer%stop(TOD_SL_INT, tod%band) else - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_sl(:,j) = 0. + sd%s_sl(:,j) = 0. end do end if !!$ if (tod%scanid(scan) == 3) then !!$ open(58,file='sidelobe_BP10.dat') -!!$ do k = 1, size(self%s_sl,1) -!!$ write(58,*) k, self%s_sl(k,1) +!!$ do k = 1, size(sd%s_sl,1) +!!$ write(58,*) k, sd%s_sl(k,1) !!$ end do !!$ close(58) !!$ end if @@ -229,40 +196,47 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, procmask, procmas ! Construct monopole correction template if (tod%sample_mono) then - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - !self%s_mono(:,j) = tod%mono(j) - self%s_mono(:,j) = 0.d0 ! Disabled for now + !sd%s_mono(:,j) = tod%mono(j) + sd%s_mono(:,j) = 0.d0 ! Disabled for now end do end if ! Generate and apply instrument-specific correction template if (tod%apply_inst_corr) then - call tod%construct_corrtemp_inst(scan, self%pix(:,:,1), self%psi(:,:,1), self%s_inst) -!!$ do j = 1, self%ndet + call tod%construct_corrtemp_inst(scan, sd%pix(:,:,1), sd%psi(:,:,1), sd%s_inst) +!!$ do j = 1, sd%ndet !!$ if (.not. tod%scans(scan)%d(j)%accept) cycle -!!$ self%tod(:,j) = self%tod(:,j) - self%s_inst(:,j) +!!$ sd%tod(:,j) = sd%tod(:,j) - sd%s_inst(:,j) !!$ end do end if !call update_status(status, "todinit_instcorr") ! Construct total sky signal - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_tot(:,j) = self%s_sky(:,j) + self%s_sl(:,j) + self%s_orb(:,j) - if (tod%sample_mono) self%s_tot(:,j) = self%s_tot(:,j) + self%s_mono(:,j) - if (tod%apply_inst_corr) self%s_tot(:,j) = self%s_tot(:,j) + self%s_inst(:,j) + sd%s_tot(:,j) = sd%s_sky(:,j) + sd%s_sl(:,j) + sd%s_orb(:,j) + if (tod%sample_mono) sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_mono(:,j) + if (tod%apply_inst_corr) sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_inst(:,j) end do + ! Apply non-linearity corrections +!!$ select type (tod) +!!$ class is (comm_hfi_tod) +!!$ call tod%apply_hfi_nonlin_corr(sd) +!!$ end select + + !call update_status(status, "todinit_stot") end subroutine init_scan_data_singlehorn - subroutine init_scan_data_differential(self, tod, scan, map_sky, procmask, procmask2, & + subroutine init_scan_data_differential(sd, tod, scan, map_sky, procmask, procmask2, & & init_s_bp, init_s_bp_prop, init_s_sky_prop, polang) implicit none - class(comm_scandata), intent(inout) :: self + class(comm_scandata), intent(inout) :: sd class(comm_tod), intent(inout) :: tod integer(i4b), intent(in) :: scan real(sp), dimension(1:,1:,0:,1:), intent(in) :: map_sky @@ -290,168 +264,168 @@ subroutine init_scan_data_differential(self, tod, scan, map_sky, procmask, procm init_s_sky_prop_ = init_s_bp_prop end if - self%ntod = tod%scans(scan)%ntod - self%ndet = tod%ndet - self%nhorn = tod%nhorn - self%ndelta = 0; if (init_s_sky_prop_ .or. init_s_bp_prop_) self%ndelta = size(map_sky,4) + sd%ntod = tod%scans(scan)%ntod + sd%ndet = tod%ndet + sd%nhorn = tod%nhorn + sd%ndelta = 0; if (init_s_sky_prop_ .or. init_s_bp_prop_) sd%ndelta = size(map_sky,4) ! Allocate data structures - allocate(self%tod(self%ntod, self%ndet)) - allocate(self%n_corr(self%ntod, self%ndet)) - allocate(self%s_sl(self%ntod, self%ndet)) - allocate(self%s_sky(self%ntod, self%ndet)) - allocate(self%s_bp(self%ntod, self%ndet)) - allocate(self%s_orb(self%ntod, self%ndet)) - allocate(self%s_tot(self%ntod, self%ndet)) - allocate(self%s_totA(self%ntod, self%ndet)) - allocate(self%s_totB(self%ntod, self%ndet)) - allocate(self%s_orbA(self%ntod, self%ndet)) - allocate(self%s_orbB(self%ntod, self%ndet)) - allocate(self%mask(self%ntod, self%ndet)) - allocate(self%pix(self%ntod, 1, self%nhorn)) - allocate(self%psi(self%ntod, 1, self%nhorn)) - allocate(self%flag(self%ntod, 1)) - if (init_s_sky_prop_) allocate(self%s_sky_prop(self%ntod, self%ndet, 2:self%ndelta)) - if (init_s_bp_prop_) allocate(self%s_bp_prop(self%ntod, self%ndet, 2:self%ndelta)) - if (init_s_sky_prop_) allocate(self%mask2(self%ntod, self%ndet)) - if (tod%sample_mono) allocate(self%s_mono(self%ntod, self%ndet)) - if (tod%subtract_zodi) allocate(self%s_zodi(self%ntod, self%ndet)) - self%s_tot = 0. - self%s_totA = 0. - self%s_totB = 0. - self%s_orb = 0. - self%s_orbA = 0. - self%s_orbB = 0. - - allocate(s_bufA(self%ntod, self%ndet)) - allocate(s_bufB(self%ntod, self%ndet)) - allocate(s_buf2A(self%ntod, self%ndet)) - allocate(s_buf2B(self%ntod, self%ndet)) + allocate(sd%tod(sd%ntod, sd%ndet)) + allocate(sd%n_corr(sd%ntod, sd%ndet)) + allocate(sd%s_sl(sd%ntod, sd%ndet)) + allocate(sd%s_sky(sd%ntod, sd%ndet)) + allocate(sd%s_bp(sd%ntod, sd%ndet)) + allocate(sd%s_orb(sd%ntod, sd%ndet)) + allocate(sd%s_tot(sd%ntod, sd%ndet)) + allocate(sd%s_totA(sd%ntod, sd%ndet)) + allocate(sd%s_totB(sd%ntod, sd%ndet)) + allocate(sd%s_orbA(sd%ntod, sd%ndet)) + allocate(sd%s_orbB(sd%ntod, sd%ndet)) + allocate(sd%mask(sd%ntod, sd%ndet)) + allocate(sd%pix(sd%ntod, 1, sd%nhorn)) + allocate(sd%psi(sd%ntod, 1, sd%nhorn)) + allocate(sd%flag(sd%ntod, 1)) + if (init_s_sky_prop_) allocate(sd%s_sky_prop(sd%ntod, sd%ndet, 2:sd%ndelta)) + if (init_s_bp_prop_) allocate(sd%s_bp_prop(sd%ntod, sd%ndet, 2:sd%ndelta)) + if (init_s_sky_prop_) allocate(sd%mask2(sd%ntod, sd%ndet)) + if (tod%sample_mono) allocate(sd%s_mono(sd%ntod, sd%ndet)) + if (tod%subtract_zodi) allocate(sd%s_zodi(sd%ntod, sd%ndet)) + sd%s_tot = 0. + sd%s_totA = 0. + sd%s_totB = 0. + sd%s_orb = 0. + sd%s_orbA = 0. + sd%s_orbB = 0. + + allocate(s_bufA(sd%ntod, sd%ndet)) + allocate(s_bufB(sd%ntod, sd%ndet)) + allocate(s_buf2A(sd%ntod, sd%ndet)) + allocate(s_buf2B(sd%ntod, sd%ndet)) ! Decompress pointing, psi and flags for current scan ! Only called for one detector, det=1, since the pointing and polarization ! angles are the same for all detectors - call tod%decompress_pointing_and_flags(scan, 1, self%pix(:,1,:), & - & self%psi(:,1,:), self%flag(:,1)) + call tod%decompress_pointing_and_flags(scan, 1, sd%pix(:,1,:), & + & sd%psi(:,1,:), sd%flag(:,1)) ! Prepare TOD if (tod%ndiode == 1 .or. trim(tod%level) == 'L2') then - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle if (tod%compressed_tod) then - call tod%decompress_tod(scan, j, self%tod(:,j)) + call tod%decompress_tod(scan, j, sd%tod(:,j)) else - self%tod(:,j) = tod%scans(scan)%d(j)%tod + sd%tod(:,j) = tod%scans(scan)%d(j)%tod end if end do else - call tod%diode2tod_inst(scan, map_sky, procmask, self%tod) + call tod%diode2tod_inst(scan, map_sky, procmask, sd%tod) end if ! Construct sky signal template if (init_s_bp_) then - call project_sky_differential(tod, map_sky(:,:,:,1), self%pix(:,1,:), self%psi(:,1,:), self%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, self%mask, s_bpA=s_buf2A, s_bpB=s_buf2B) + call project_sky_differential(tod, map_sky(:,:,:,1), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & + & procmask, scan, s_bufA, s_bufB, sd%mask, s_bpA=s_buf2A, s_bpB=s_buf2B) else - call project_sky_differential(tod, map_sky(:,:,:,1), self%pix(:,1,:), self%psi(:,1,:), self%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, self%mask) + call project_sky_differential(tod, map_sky(:,:,:,1), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & + & procmask, scan, s_bufA, s_bufB, sd%mask) end if - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_sky(:,j) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) - self%s_totA(:,j) = self%s_totA(:,j) + s_bufA(:,j) - self%s_totB(:,j) = self%s_totB(:,j) + s_bufB(:,j) - self%s_tot(:,j) = self%s_tot(:,j) + self%s_sky(:,j) - if (init_s_bp_) self%s_bp(:,j) = (1.+tod%x_im(j))*s_buf2A(:,j) - (1.-tod%x_im(j))*s_buf2B(:,j) + sd%s_sky(:,j) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) + sd%s_totA(:,j) = sd%s_totA(:,j) + s_bufA(:,j) + sd%s_totB(:,j) = sd%s_totB(:,j) + s_bufB(:,j) + sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_sky(:,j) + if (init_s_bp_) sd%s_bp(:,j) = (1.+tod%x_im(j))*s_buf2A(:,j) - (1.-tod%x_im(j))*s_buf2B(:,j) end do ! Set up (optional) bandpass sampling quantities (s_sky_prop, mask2 and bp_prop) if (init_s_bp_prop_) then - do k = 2, self%ndelta - call project_sky_differential(tod, map_sky(:,:,:,k), self%pix(:,1,:), self%psi(:,1,:), self%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, self%mask, s_bpA=s_buf2A, s_bpB=s_buf2B) - do j = 1, self%ndet + do k = 2, sd%ndelta + call project_sky_differential(tod, map_sky(:,:,:,k), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & + & procmask, scan, s_bufA, s_bufB, sd%mask, s_bpA=s_buf2A, s_bpB=s_buf2B) + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) - if (init_s_bp_) self%s_bp_prop(:,j,k) = (1.+tod%x_im(j))*s_buf2A(:,j) - (1.-tod%x_im(j))*s_buf2B(:,j) + sd%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) + if (init_s_bp_) sd%s_bp_prop(:,j,k) = (1.+tod%x_im(j))*s_buf2A(:,j) - (1.-tod%x_im(j))*s_buf2B(:,j) end do end do else if (init_s_sky_prop_) then - do k = 2, self%ndelta - call project_sky_differential(tod, map_sky(:,:,:,k), self%pix(:,1,:), self%psi(:,1,:), self%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, self%mask) - do j = 1, self%ndet + do k = 2, sd%ndelta + call project_sky_differential(tod, map_sky(:,:,:,k), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & + & procmask, scan, s_bufA, s_bufB, sd%mask) + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) + sd%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) end do end do end if ! Perform sanity tests - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - if (all(self%mask(:,j) == 0)) tod%scans(scan)%d(j)%accept = .false. + if (all(sd%mask(:,j) == 0)) tod%scans(scan)%d(j)%accept = .false. if (tod%scans(scan)%d(j)%N_psd%sigma0 <= 0.d0) tod%scans(scan)%d(j)%accept = .false. end do ! Construct orbital dipole template - call tod%construct_dipole_template_diff(scan, self%pix(:,:,1), self%psi(:,:,1), s_bufA, 1d3) - call tod%construct_dipole_template_diff(scan, self%pix(:,:,2), self%psi(:,:,2), s_bufB, 1d3) - self%s_orbA = s_bufA - self%s_orbB = s_bufB - self%s_totA = self%s_totA + self%s_orbA - self%s_totB = self%s_totB + self%s_orbB - do j = 1, self%ndet + call tod%construct_dipole_template_diff(scan, sd%pix(:,:,1), sd%psi(:,:,1), s_bufA, 1d3) + call tod%construct_dipole_template_diff(scan, sd%pix(:,:,2), sd%psi(:,:,2), s_bufB, 1d3) + sd%s_orbA = s_bufA + sd%s_orbB = s_bufB + sd%s_totA = sd%s_totA + sd%s_orbA + sd%s_totB = sd%s_totB + sd%s_orbB + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - self%s_orb(:,j) = (1.+tod%x_im(j))*self%s_orbA(:,j) - (1.-tod%x_im(j))*self%s_orbB(:,j) - self%s_tot(:,j) = self%s_tot(:,j) + self%s_orb(:,j) + sd%s_orb(:,j) = (1.+tod%x_im(j))*sd%s_orbA(:,j) - (1.-tod%x_im(j))*sd%s_orbB(:,j) + sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_orb(:,j) end do ! Construct zodical light template if (tod%subtract_zodi) then - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - call compute_zodi_template(tod%nside, self%pix(:,1:1,1), tod%scans(scan)%satpos, tod%nu_c(j:j), s_bufA) - call compute_zodi_template(tod%nside, self%pix(:,1:1,2), tod%scans(scan)%satpos, tod%nu_c(j:j), s_bufB) - self%s_zodi(:,j) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) - self%s_tot(:,j) = self%s_tot(:,j) + self%s_zodi(:,j) - self%s_totA(:,j) = self%s_totA(:,j) + s_bufA(:,j) - self%s_totB(:,j) = self%s_totB(:,j) + s_bufB(:,j) + call compute_zodi_template(tod%nside, sd%pix(:,1:1,1), tod%scans(scan)%satpos, tod%nu_c(j:j), s_bufA) + call compute_zodi_template(tod%nside, sd%pix(:,1:1,2), tod%scans(scan)%satpos, tod%nu_c(j:j), s_bufB) + sd%s_zodi(:,j) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) + sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_zodi(:,j) + sd%s_totA(:,j) = sd%s_totA(:,j) + s_bufA(:,j) + sd%s_totB(:,j) = sd%s_totB(:,j) + s_bufB(:,j) end do else - self%s_zodi = 0. + sd%s_zodi = 0. end if ! Construct sidelobe template if (tod%correct_sl) then - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - !call tod%construct_sl_template(tod%slconv(1)%p, self%pix(:,1,1), self%psi(:,1,1), s_bufA(:,j), 1.5707963267948966192d0) - !call tod%construct_sl_template(tod%slconv(3)%p, self%pix(:,1,2), self%psi(:,1,2), s_bufB(:,j), -1.5707963267948966192d0) - call tod%construct_sl_template(tod%slconv(1)%p, self%pix(:,1,1), self%psi(:,1,1), s_bufA(:,j), polang) - call tod%construct_sl_template(tod%slconv(3)%p, self%pix(:,1,2), self%psi(:,1,2), s_bufB(:,j), -polang) - self%s_sl(:,j) = (1d0+tod%x_im(j))*s_bufA(:,j) - (1d0-tod%x_im(j))*s_bufB(:,j) - self%s_tot(:,j) = self%s_tot(:,j) + self%s_sl(:,j) - self%s_totA(:,j) = self%s_totA(:,j) + s_bufA(:,j) - self%s_totB(:,j) = self%s_totB(:,j) + s_bufB(:,j) + !call tod%construct_sl_template(tod%slconv(1)%p, sd%pix(:,1,1), sd%psi(:,1,1), s_bufA(:,j), 1.5707963267948966192d0) + !call tod%construct_sl_template(tod%slconv(3)%p, sd%pix(:,1,2), sd%psi(:,1,2), s_bufB(:,j), -1.5707963267948966192d0) + call tod%construct_sl_template(tod%slconv(1)%p, sd%pix(:,1,1), sd%psi(:,1,1), s_bufA(:,j), polang) + call tod%construct_sl_template(tod%slconv(3)%p, sd%pix(:,1,2), sd%psi(:,1,2), s_bufB(:,j), -polang) + sd%s_sl(:,j) = (1d0+tod%x_im(j))*s_bufA(:,j) - (1d0-tod%x_im(j))*s_bufB(:,j) + sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_sl(:,j) + sd%s_totA(:,j) = sd%s_totA(:,j) + s_bufA(:,j) + sd%s_totB(:,j) = sd%s_totB(:,j) + s_bufB(:,j) end do else - self%s_sl = 0. + sd%s_sl = 0. end if ! Construct monopole correction template if (tod%sample_mono) then - do j = 1, self%ndet + do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - !self%s_mono(:,j) = tod%mono(j) - self%s_mono(:,j) = 0.d0 ! Disabled for now - self%s_tot(:,j) = self%s_tot(:,j) + self%s_mono(:,j) - self%s_totA(:,j) = self%s_totA(:,j) + self%s_mono(:,j) - self%s_totB(:,j) = self%s_totB(:,j) + self%s_mono(:,j) + !sd%s_mono(:,j) = tod%mono(j) + sd%s_mono(:,j) = 0.d0 ! Disabled for now + sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_mono(:,j) + sd%s_totA(:,j) = sd%s_totA(:,j) + sd%s_mono(:,j) + sd%s_totB(:,j) = sd%s_totB(:,j) + sd%s_mono(:,j) end do else - self%s_mono = 0.d0 + sd%s_mono = 0.d0 end if ! Clean-up @@ -460,29 +434,29 @@ subroutine init_scan_data_differential(self, tod, scan, map_sky, procmask, procm end subroutine init_scan_data_differential - subroutine dealloc_scan_data(self) + subroutine dealloc_scandata(sd) implicit none - class(comm_scandata), intent(inout) :: self + class(comm_scandata), intent(inout) :: sd - self%ntod = -1; self%ndet = -1; self%nhorn = -1 + sd%ntod = -1; sd%ndet = -1; sd%nhorn = -1 ! Deallocate data structures - deallocate(self%tod, self%n_corr, self%s_sl, self%s_sky) - deallocate(self%s_orb, self%s_tot, self%mask) - deallocate(self%pix, self%psi, self%flag) - if (allocated(self%s_sky_prop)) deallocate(self%s_sky_prop) - if (allocated(self%s_bp_prop)) deallocate(self%s_bp_prop) - if (allocated(self%s_bp)) deallocate(self%s_bp) - if (allocated(self%s_mono)) deallocate(self%s_mono) - if (allocated(self%mask2)) deallocate(self%mask2) - if (allocated(self%s_zodi)) deallocate(self%s_zodi) - if (allocated(self%s_totA)) deallocate(self%s_totA) - if (allocated(self%s_totB)) deallocate(self%s_totB) - if (allocated(self%s_inst)) deallocate(self%s_inst) - if (allocated(self%s_orbA)) deallocate(self%s_orbA) - if (allocated(self%s_orbB)) deallocate(self%s_orbB) - - end subroutine dealloc_scan_data + deallocate(sd%tod, sd%n_corr, sd%s_sl, sd%s_sky) + deallocate(sd%s_orb, sd%s_tot, sd%mask) + deallocate(sd%pix, sd%psi, sd%flag) + if (allocated(sd%s_sky_prop)) deallocate(sd%s_sky_prop) + if (allocated(sd%s_bp_prop)) deallocate(sd%s_bp_prop) + if (allocated(sd%s_bp)) deallocate(sd%s_bp) + if (allocated(sd%s_mono)) deallocate(sd%s_mono) + if (allocated(sd%mask2)) deallocate(sd%mask2) + if (allocated(sd%s_zodi)) deallocate(sd%s_zodi) + if (allocated(sd%s_totA)) deallocate(sd%s_totA) + if (allocated(sd%s_totB)) deallocate(sd%s_totB) + if (allocated(sd%s_inst)) deallocate(sd%s_inst) + if (allocated(sd%s_orbA)) deallocate(sd%s_orbA) + if (allocated(sd%s_orbB)) deallocate(sd%s_orbB) + + end subroutine dealloc_scandata !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -560,9 +534,9 @@ subroutine sample_calibration(tod, mode, handle, map_sky, procmask, procmask2, p ! Prepare data if (tod%nhorn == 1) then - call sd%init_singlehorn(tod, i, map_sky, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, procmask, procmask2) else - call sd%init_differential(tod, i, map_sky, procmask, procmask2) + call init_scan_data_differential(sd, tod, i, map_sky, procmask, procmask2) end if ! Set up filtered calibration signal, conditional contribution and mask @@ -636,7 +610,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, procmask, procmask2, p call wall_time(t2) tod%scans(i)%proctime = tod%scans(i)%proctime + t2-t1 tod%scans(i)%n_proctime = tod%scans(i)%n_proctime + 1 - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_invsqrtN, s_buf, mask_lowres) end do @@ -682,9 +656,9 @@ subroutine sample_baseline(tod, handle, map_sky, procmask, procmask2) ! Prepare data if (tod%nhorn == 1) then - call sd%init_singlehorn(tod, i, map_sky, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, procmask, procmask2) else - call sd%init_differential(tod, i, map_sky, procmask, procmask2) + call init_scan_data_differential(sd, tod, i, map_sky, procmask, procmask2) end if do j = 1, tod%ndet @@ -704,7 +678,7 @@ subroutine sample_baseline(tod, handle, map_sky, procmask, procmask2) call wall_time(t2) tod%scans(i)%proctime = tod%scans(i)%proctime + t2-t1 tod%scans(i)%n_proctime = tod%scans(i)%n_proctime + 1 - call sd%dealloc + call dealloc_scandata(sd) end do end subroutine sample_baseline diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 01cf337c4..bb74c66ff 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -50,12 +50,15 @@ module comm_tod_HFI_mod public comm_HFI_tod type, extends(comm_tod) :: comm_HFI_tod + integer(i4b), allocatable, dimension(:,:) :: mod_phase contains - procedure :: process_tod => process_HFI_tod - procedure :: read_tod_inst => read_tod_inst_HFI - procedure :: read_scan_inst => read_scan_inst_HFI - procedure :: initHDF_inst => initHDF_HFI - procedure :: dumpToHDF_inst => dumpToHDF_HFI + procedure :: process_tod => process_HFI_tod + procedure :: read_tod_inst => read_tod_inst_HFI + procedure :: read_scan_inst => read_scan_inst_HFI + procedure :: initHDF_inst => initHDF_HFI + procedure :: dumpToHDF_inst => dumpToHDF_HFI + procedure :: construct_corrtemp_inst => construct_corrtemp_hfi +! procedure :: apply_nonlin_corr_hfi end type comm_HFI_tod interface comm_HFI_tod @@ -139,7 +142,7 @@ function constructor(cpar, id_abs, info, tod_type) nmaps_beam = 3 pol_beam = .true. constructor%nside_beam = nside_beam - + ! Get detector labels call get_tokens(cpar%ds_tod_dets(id_abs), ",", constructor%label) @@ -161,11 +164,15 @@ function constructor(cpar, id_abs, info, tod_type) allocate(constructor%orb_dp) constructor%orb_dp => comm_orbdipole(constructor%mbeam) + ! Allocate modulation ph + allocate(constructor%mod_phase(constructor%ndet,constructor%nscan)) + ! Initialize all baseline corrections to zero do i = 1, constructor%nscan constructor%scans(i)%d%baseline = 0.d0 end do - + constructor%mod_phase = 1.d0 + end function constructor !************************************************** @@ -324,11 +331,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if !!$ ! Calling Simulation Routine @@ -366,10 +373,10 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Not implemented yet ! remove cosmic rays - do j=1, sd%ndet - call self%cray(j)%p%build_cray_templates() - call self%cray(j)%p%fit_cray_amplitudes() - end do +!!$ do j=1, sd%ndet +!!$ call self%cray(j)%p%build_cray_templates() +!!$ call self%cray(j)%p%fit_cray_amplitudes() +!!$ end do ! Fit and subtract 4K lines ! Not implemented yet @@ -421,7 +428,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(d_calib) end do @@ -526,155 +533,68 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! implicit none class(comm_scandata), intent(in) :: self - class(comm_tod), intent(inout) :: tod + class(comm_hfi_tod), intent(inout) :: tod integer(i4b), intent(in) :: scan type(planck_rng), intent(inout) :: handle - real(dp) :: sigma_0 + real(dp) :: invN, B(3), eta(3), X(3), A(3,3), sgn integer(i4b) :: i, j - real(dp), allocatable, dimension(:,:) :: T, even, uneven, tod_inv_N, matrix_buf, A, A_sqrt, s_tot_inv_N - real(dp), allocatable, dimension(:) :: B, eta, X - real(dp), allocatable, dimension(:) :: temp - real(dp) :: gain_median ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] ! sd = self --- self%s_tot - sky signal model ! self%s_tot(self%ntod, self%ndet) - how s_tot structured - - allocate(s_tot_inv_N(self%ntod, tod%ndet)) - allocate(tod_inv_N(self%ntod, tod%ndet)) - allocate(even(self%ntod, tod%ndet), uneven(self%ntod, tod%ndet)) - - s_tot_inv_N = self%s_tot - tod_inv_N = self%tod - - ! preparing utility and noise matrices, where noise is assumed constant - do i = 1, tod%ndet - sigma_0 = tod%scans(scan)%d(i)%N_psd%sigma0 - - do j = 1, self%ntod - even(j,i) = 0.d0 !/sigma_0/sigma_0 - uneven(j,i) = 1.d0/sigma_0/sigma_0 - s_tot_inv_N(j,i) = s_tot_inv_N(j,i)/sigma_0/sigma_0 - tod_inv_N(j,i) = tod_inv_N(j,i)/sigma_0/sigma_0 - end do - end do - - !call multiply_inv_N(tod, scan, s_tot_inv_N) - !call multiply_inv_N(tod, scan, tod_inv_N) - !call multiply_inv_N(tod, scan, even) - !call multiply_inv_N(tod, scan, uneven) - - do i = 1, tod%ndet - allocate(T(self%ntod,3)) - allocate(matrix_buf(self%ntod,3)) - allocate(A(3,3), A_sqrt(3,3)) - allocate(B(3), eta(3), X(3)) - - - ! fill the matrix T and flip every other sample + ! Build linear system + A = 0.d0 + B = 0.d0 + sgn = tod%mod_phase(i,scan) do j = 1, self%ntod - if (mod(j,2) /= 0) then - T(j,1) = -1.d0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain - T(j,2) = 1.d0 - T(j,3) = 0.d0 - else - T(j,1) = 1.d0 * self%s_tot(j, i) !* tod%scans(scan)%d(i)%gain - T(j,2) = 0.d0 - T(j,3) = 1.d0 - end if - - end do - - ! multiply matrices (N^-1 x T) possibly (T^t x N^-1) - do j = 1, self%ntod - if (mod(j,2) /= 0) then - matrix_buf(j,1) = -1.d0 * s_tot_inv_N(j,i) - matrix_buf(j,2) = uneven(j,i) - matrix_buf(j,3) = even(j,i) - else - matrix_buf(j,1) = 1.d0 * s_tot_inv_N(j,i) - matrix_buf(j,2) = even(j,i) - matrix_buf(j,3) = uneven(j,i) - end if + if (self%mask(j,i) == 0) then + sgn = -sgn + cycle + end if + A(1,1) = A(1,1) + self%s_tot(j,i) * self%s_tot(j,i) + B(1) = B(1) + sgn * self%s_tot(j,i) * self%tod(j,i) + if (mod(j,2) == 1) then + A(2,1) = A(2,1) + self%s_tot(j,i) + A(2,2) = A(2,2) + 1.d0 + B(2) = B(2) + self%tod(j,i) + else + A(3,1) = A(3,1) - self%s_tot(j,i) + A(3,3) = A(3,3) + 1.d0 + B(3) = B(3) + self%tod(j,i) + end if + sgn = -sgn end do - + A = A / tod%scans(scan)%d(i)%N_psd%sigma0**2 + b = b / tod%scans(scan)%d(i)%N_psd%sigma0**2 - ! multiply matrices T^t x N^-1 x T - do j = 1, 3 - A(1,j) = sum(T(:,1)*matrix_buf(:,j)) - A(2,j) = sum(T(:,2)*matrix_buf(:,j)) - A(3,j) = sum(T(:,3)*matrix_buf(:,j)) - - ! preparing for A_sqrt calculation - A_sqrt(1,j) = A(1,j) - A_sqrt(2,j) = A(2,j) - A_sqrt(3,j) = A(3,j) - - end do - - - ! multiply T^t x N^-1 x d - do j = 1, 3 - B(j) = sum(T(:,j)*tod_inv_N(:,i)) - end do - - - call compute_hermitian_root(A_sqrt, 0.5d0) - + ! solving the linear system + call solve_system_real(A, x, B) - ! fill random gaussian N(0,1) eta + ! Add fluctuation + call compute_hermitian_root(A, -0.5d0) do j = 1, 3 eta(j) = rand_gauss(handle) - end do - - ! multiply ((T^t x N^-1) x T)^0.5 eta - do j = 1, 3 - B(j) = B(j) + sum(A_sqrt(j,:)*eta(:)) - end do - - ! solving the linear system - call solve_system_real(A, X, B) - - - !write(*,*) "X=", X(1), " ", X(2), " ", X(3) + end do + x = x + matmul(A, eta) + !x(1) = abs(x(1)) ! Ensure positive galactic plane + ! saving the offset (and gain) to the tod object + write(*,*) "X=", real(X,sp) tod%scans(scan)%d(i)%gain = X(1) tod%scans(scan)%d(i)%baseline = X(2) tod%scans(scan)%d(i)%baseline2 = X(3) - - ! calculate gain as a median of all scans - ! (a temporary solution, before a proper sampling established) - if (scan == tod%nscan) then - allocate(temp(tod%nscan)) - - do j = 1, tod%nscan - temp(j) = tod%scans(j)%d(i)%gain - end do - - gain_median = median(temp) - - do j = 1, tod%nscan - tod%scans(j)%d(i)%gain = gain_median - end do - - deallocate(temp) + if (x(1) < 0.d0) then + tod%scans(scan)%d(i)%gain = -X(1) + tod%mod_phase(i,scan) = -tod%mod_phase(i,scan) end if - - - - deallocate(T, matrix_buf, A, A_sqrt) - deallocate(B, eta, X) - + end do - - deallocate(s_tot_inv_N, tod_inv_N, even, uneven) - end subroutine sample_hfi_baselines @@ -696,20 +616,22 @@ subroutine demodulate_tod(self, tod, scan) ! implicit none class(comm_scandata), intent(inout) :: self - class(comm_tod), intent(in) :: tod + class(comm_hfi_tod), intent(in) :: tod integer(i4b), intent(in) :: scan integer(i4b) :: i, j + real(sp) :: sgn logical :: exists do i = 1, tod%ndet - + sgn = tod%mod_phase(i,scan) + ! Subtract baselines and flip sign of even samples do j = 1, self%ntod - if (mod(j,2) /= 0) then - self%tod(j,i) = -(self%tod(j,i) - tod%scans(scan)%d(i)%baseline) + if (mod(j,2) == 1) then + self%tod(j,i) = sgn*(self%tod(j,i) - tod%scans(scan)%d(i)%baseline) else - self%tod(j,i) = (self%tod(j,i) - tod%scans(scan)%d(i)%baseline2) + self%tod(j,i) = -sgn*(self%tod(j,i) - tod%scans(scan)%d(i)%baseline2) end if end do @@ -813,4 +735,61 @@ subroutine dumpToHDF_HFI(self, chainfile, path) character(len=*), intent(in) :: path end subroutine dumpToHDF_HFI + subroutine construct_corrtemp_hfi(self, scan, pix, psi, s) + ! Construct an LFI instrument-specific correction template; for now contains 1Hz template only + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! pix: int + ! index for pixel + ! psi: int + ! integer label for polarization angle + ! + ! Returns: + ! -------- + ! s: real (sp) + ! output template timestream + implicit none + class(comm_hfi_tod), intent(in) :: self + integer(i4b), intent(in) :: scan + integer(i4b), dimension(:,:), intent(in) :: pix, psi + real(sp), dimension(:,:), intent(out) :: s + + integer(i4b) :: i, j, k, nbin, b + real(dp) :: dt, t_tot, t + + s = 0. + + end subroutine construct_corrtemp_hfi + + subroutine apply_hfi_nonlin_corr(self, sd) + ! Construct an LFI instrument-specific correction template; for now contains 1Hz template only + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! pix: int + ! index for pixel + ! psi: int + ! integer label for polarization angle + ! + ! Returns: + ! -------- + ! s: real (sp) + ! output template timestream + implicit none + class(comm_hfi_tod), intent(in) :: self + class(comm_scandata), intent(inout) :: sd + + return + + end subroutine apply_hfi_nonlin_corr + end module comm_tod_HFI_mod diff --git a/commander3/src/comm_tod_lb_mod.f90 b/commander3/src/comm_tod_lb_mod.f90 index 097f5b9a0..e0b00d7ad 100644 --- a/commander3/src/comm_tod_lb_mod.f90 +++ b/commander3/src/comm_tod_lb_mod.f90 @@ -333,11 +333,11 @@ subroutine process_LB_tod(self, chaindir, chain, iter, handle, map_in, delta, ma ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) @@ -393,7 +393,7 @@ subroutine process_LB_tod(self, chaindir, chain, iter, handle, map_in, delta, ma end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_buf, d_calib) end do diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index 9d6fba0fa..3ef999ec8 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -765,11 +765,11 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if ! Make simulations, or draw correlated noise @@ -834,7 +834,7 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(d_calib) end do @@ -1581,7 +1581,7 @@ module subroutine sample_1Hz_spikes(tod, handle, map_sky, procmask, procmask2) ! Prepare data tod%apply_inst_corr = .false. ! Disable 1Hz correction for just this call - call sd%init_singlehorn(tod, i, map_sky, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, procmask, procmask2) tod%apply_inst_corr = .true. ! Enable 1Hz correction again call timer%start(TOD_1HZ, tod%band) @@ -1638,7 +1638,7 @@ module subroutine sample_1Hz_spikes(tod, handle, map_sky, procmask, procmask2) !!$ end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(res) call timer%stop(TOD_1HZ, tod%band) end do diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 2f362e7d0..3d90d1208 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -34,7 +34,7 @@ module comm_tod_mod implicit none private - public comm_tod, comm_scan, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer + public comm_tod, comm_scan, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer, comm_scandata ! Structure for individual detectors @@ -219,7 +219,7 @@ module comm_tod_mod procedure :: read_jumplist procedure :: remove_fixed_scans end type comm_tod - + abstract interface subroutine process_tod(self, chaindir, chain, iter, handle, map_in, delta, map_out, rms_out, map_gain) import i4b, comm_tod, comm_map, map_ptr, dp, planck_rng @@ -240,6 +240,34 @@ end subroutine process_tod class(comm_tod), pointer :: p => null() end type tod_pointer + ! Class for uncompressed data for a given scan + type :: comm_scandata + integer(i4b) :: ntod, ndet, nhorn, ndelta + real(sp), allocatable, dimension(:,:) :: tod ! Raw data + real(sp), allocatable, dimension(:,:) :: n_corr ! Correlated noise in V + real(sp), allocatable, dimension(:,:) :: s_sl ! Sidelobe correction + real(sp), allocatable, dimension(:,:) :: s_sky ! Stationary sky signal + real(sp), allocatable, dimension(:,:,:) :: s_sky_prop ! Stationary sky signal proposal for bandpass sampling + real(sp), allocatable, dimension(:,:) :: s_orb ! Orbital dipole + real(sp), allocatable, dimension(:,:) :: s_mono ! Detector monopole correction + real(sp), allocatable, dimension(:,:) :: s_bp ! Bandpass correction + real(sp), allocatable, dimension(:,:,:) :: s_bp_prop ! Bandpass correction proposal + real(sp), allocatable, dimension(:,:) :: s_zodi ! Zodiacal light + real(sp), allocatable, dimension(:,:) :: s_inst ! Instrument-specific correction template + real(sp), allocatable, dimension(:,:) :: s_tot ! Total signal + real(sp), allocatable, dimension(:,:) :: mask ! TOD mask (flags + main processing mask) + real(sp), allocatable, dimension(:,:) :: mask2 ! Small TOD mask, for bandpass sampling + integer(i4b), allocatable, dimension(:,:,:) :: pix ! Discretized pointing + integer(i4b), allocatable, dimension(:,:,:) :: psi ! Discretized polarization angle + integer(i4b), allocatable, dimension(:,:) :: flag ! Quality flags + + real(sp), allocatable, dimension(:,:) :: s_totA ! Total signal, horn A (differential only) + real(sp), allocatable, dimension(:,:) :: s_totB ! Total signal, horn B (differential only) + real(sp), allocatable, dimension(:,:) :: s_orbA ! Orbital signal, horn A (differential only) + real(sp), allocatable, dimension(:,:) :: s_orbB ! Orbital signal, horn B (differential only) + end type comm_scandata + + contains subroutine initialize_tod_mod(cpar) @@ -1725,6 +1753,7 @@ subroutine construct_corrtemp_inst(self, scan, pix, psi, s) end subroutine construct_corrtemp_inst + subroutine construct_dipole_template(self, scan, pix, psi, s_dip) ! construct a CMB dipole template in the time domain ! diff --git a/commander3/src/comm_tod_quiet_smod.f90 b/commander3/src/comm_tod_quiet_smod.f90 index bc088b838..ef9344553 100644 --- a/commander3/src/comm_tod_quiet_smod.f90 +++ b/commander3/src/comm_tod_quiet_smod.f90 @@ -249,15 +249,15 @@ if (sample_rel_bandpass) then !call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true., init_s_bp_prop=.true.) - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then ! call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true., init_s_sky_prop=.true.) - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else ! call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true.) - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) @@ -347,7 +347,7 @@ end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_buf, d_calib) end do diff --git a/commander3/src/comm_tod_spider_smod.f90 b/commander3/src/comm_tod_spider_smod.f90 index d2a7eda90..f5bc00f59 100644 --- a/commander3/src/comm_tod_spider_smod.f90 +++ b/commander3/src/comm_tod_spider_smod.f90 @@ -378,18 +378,18 @@ module subroutine process_SPIDER_tod(self, chaindir, chain, iter, handle, map_in ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) ! Calling Simulation Routine if (self%enable_tod_simulations) then call simulate_tod(self, i, sd%s_tot, sd%n_corr, handle) - call sd%dealloc + call dealloc_scandata(sd) cycle end if @@ -658,7 +658,7 @@ module subroutine process_SPIDER_tod(self, chaindir, chain, iter, handle, map_in end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_buf, d_calib) deallocate(s_jump, jumps, tod_gapfill, jump_calib, test_array) diff --git a/commander3/src/comm_tod_wmap_mod.f90 b/commander3/src/comm_tod_wmap_mod.f90 index 2490a419c..cb1b360c9 100644 --- a/commander3/src/comm_tod_wmap_mod.f90 +++ b/commander3/src/comm_tod_wmap_mod.f90 @@ -424,13 +424,13 @@ subroutine process_WMAP_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Prepare data if (sample_rel_bandpass) then - call sd%init_differential(self, i, map_sky, procmask, procmask2, & + call init_scan_data_differential(sd, self, i, map_sky, procmask, procmask2, & & init_s_bp=.true., init_s_bp_prop=.true., polang=polang) else if (sample_abs_bandpass) then - call sd%init_differential(self, i, map_sky, procmask, procmask2, & + call init_scan_data_differential(sd, self, i, map_sky, procmask, procmask2, & & init_s_bp=.true., init_s_sky_prop=.true., polang=polang) else - call sd%init_differential(self, i, map_sky, procmask, procmask2, & + call init_scan_data_differential(sd, self, i, map_sky, procmask, procmask2, & & init_s_bp=.true., polang=polang) end if allocate(s_buf(sd%ntod,sd%ndet)) @@ -494,7 +494,7 @@ subroutine process_WMAP_tod(self, chaindir, chain, iter, handle, map_in, delta, end if ! Clean up - call sd%dealloc + call dealloc_scandata(sd) deallocate(s_buf, d_calib) end do From e7a7dedd87968a9674fbc66ab14c8c08051e65d8 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 27 Oct 2024 08:51:34 +0100 Subject: [PATCH 046/171] Implemented dedicated routine for setting the modulation phase --- commander3/src/comm_tod_driver_mod.f90 | 7 +- commander3/src/comm_tod_hfi_mod.f90 | 261 +++++++++++++++++++------ commander3/src/comm_tod_mod.f90 | 45 +++++ 3 files changed, 252 insertions(+), 61 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 1f23dd6ed..3a3148930 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -85,6 +85,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2 call tod%decompress_pointing_and_flags(scan, j, sd%pix(:,j,:), & & sd%psi(:,j,:), sd%flag(:,j)) end do + call timer%stop(TOD_DECOMP, tod%band) !call update_status(status, "todinit_decomp") !if (tod%myid == 78) write(*,*) 'c3', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires @@ -222,11 +223,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2 end do ! Apply non-linearity corrections -!!$ select type (tod) -!!$ class is (comm_hfi_tod) -!!$ call tod%apply_hfi_nonlin_corr(sd) -!!$ end select - + call tod%apply_nonlin_corr_inst(scan, sd) !call update_status(status, "todinit_stot") diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index bb74c66ff..e285ac82f 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -163,14 +163,14 @@ function constructor(cpar, id_abs, info, tod_type) allocate(constructor%orb_dp) constructor%orb_dp => comm_orbdipole(constructor%mbeam) - - ! Allocate modulation ph - allocate(constructor%mod_phase(constructor%ndet,constructor%nscan)) ! Initialize all baseline corrections to zero do i = 1, constructor%nscan constructor%scans(i)%d%baseline = 0.d0 end do + + ! Allocate modulation phase + allocate(constructor%mod_phase(constructor%ndet,constructor%nscan)) constructor%mod_phase = 1.d0 end function constructor @@ -278,7 +278,8 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m deallocate(m_buf) call map_in(1,1)%p%writeFITS(trim(self%outdir) // "/input_sky_model_"//trim(self%label(1))//".fits") - + !call self%procmask%writeFITS("mask.fits") + ! call mpi_finalize(ierr) ! stop @@ -357,6 +358,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Estimate baselines; separate for odd and even samples call sample_hfi_baselines(sd, self, i, handle) + call set_modulation_phase(sd, self, i) ! Demodulate TOD call demodulate_tod(sd, self, i) @@ -532,71 +534,211 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) ! tod%scans(scan)%d(:)%gain (temporary solution) ! implicit none - class(comm_scandata), intent(in) :: self - class(comm_hfi_tod), intent(inout) :: tod - integer(i4b), intent(in) :: scan - type(planck_rng), intent(inout) :: handle + class(comm_scandata), intent(in) :: self + class(comm_hfi_tod), intent(inout) :: tod + integer(i4b), intent(in) :: scan + type(planck_rng), intent(inout) :: handle + + real(dp) :: eta, A1, A2, x, b1, b2, sgn,gal_mean + integer(i4b) :: i, j, n + + ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] + ! sd = self --- self%s_tot - sky signal model + ! self%s_tot(self%ntod, self%ndet) - how s_tot structured - real(dp) :: invN, B(3), eta(3), X(3), A(3,3), sgn - integer(i4b) :: i, j + do i = 1, tod%ndet + if (.not. tod%scans(scan)%d(i)%accept) cycle + + ! Odd samples + A1 = 0.d0; b1 = 0; gal_mean = 0.d0; n = 0 + do j = 1, self%ntod, 2 + if (self%mask(j,i) == 0) cycle + A1 = A1 + 1.d0 + b1 = b1 + self%tod(j,i) + end do + A1 = A1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 + b1 = b1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 + tod%scans(scan)%d(i)%baseline = b1/A1 + rand_gauss(handle)/sqrt(A1) + + ! Even samples + A2 = 0.d0; b2 = 0.d0 + do j = 2, self%ntod, 2 + if (self%mask(j,i) == 0) cycle + A2 = A2 + 1.d0 + b2 = b2 + self%tod(j,i) + end do + A2 = A2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 + b2 = b2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 + tod%scans(scan)%d(i)%baseline2 = b2/A2 + rand_gauss(handle)/sqrt(A2) + + ! saving the offset (and gain) to the tod object + +!!$ if (b1/A1 < b2/A2 .and. tod%mod_phase(i,scan) == 1) then +!!$ tod%mod_phase(i,scan) = -1 +!!$ end if + write(*,*) "baseline=", tod%scans(scan)%d(i)%baseline, tod%scans(scan)%d(i)%baseline2, tod%mod_phase(i,scan) + + end do + + end subroutine sample_hfi_baselines + + subroutine set_modulation_phase(self, tod, scan) + ! + ! Estimates baselines for MODULATED data, separate for odd and even samples + ! + ! Arguments: + ! ---------- + ! self: derived class (comm_scandata) + ! HFI-specific TOD object + ! tod: comm_tod derived type + ! contains TOD-specific information + ! scan: scan ID + ! handle: planck_rng derived type + ! Healpix definition for random number generation + ! so that the same sequence can be resumed later on from that same + ! point + ! + ! + ! Returns + ! ---------- + ! None, but updates tod%scans(scan)%d(:)%baseline (for odd samples) + ! tod%scans(scan)%d(:)%baseline2 (for even samples) + ! tod%scans(scan)%d(:)%gain (temporary solution) + ! + implicit none + class(comm_scandata), intent(in) :: self + class(comm_hfi_tod), intent(inout) :: tod + integer(i4b), intent(in) :: scan + + real(dp) :: mu, n + integer(i4b) :: i, j + ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] ! sd = self --- self%s_tot - sky signal model ! self%s_tot(self%ntod, self%ndet) - how s_tot structured do i = 1, tod%ndet - - ! Build linear system - A = 0.d0 - B = 0.d0 - sgn = tod%mod_phase(i,scan) - do j = 1, self%ntod - if (self%mask(j,i) == 0) then - sgn = -sgn - cycle - end if - A(1,1) = A(1,1) + self%s_tot(j,i) * self%s_tot(j,i) - B(1) = B(1) + sgn * self%s_tot(j,i) * self%tod(j,i) - if (mod(j,2) == 1) then - A(2,1) = A(2,1) + self%s_tot(j,i) - A(2,2) = A(2,2) + 1.d0 - B(2) = B(2) + self%tod(j,i) - else - A(3,1) = A(3,1) - self%s_tot(j,i) - A(3,3) = A(3,3) + 1.d0 - B(3) = B(3) + self%tod(j,i) + if (.not. tod%scans(scan)%d(i)%accept) cycle + + mu = 0.d0; n = 0.d0 + do j = 1, self%ntod, 2 + if (self%pix(j,i,1) > 0.48*tod%info%npix .and. self%pix(j,i,1) < 0.52*tod%info%npix) then + if (mod(j,2) == 1) then + mu = mu + self%tod(j,1)-tod%scans(scan)%d(i)%baseline + else + mu = mu - self%tod(j,1)-tod%scans(scan)%d(i)%baseline + end if + n = n + 1.d0 end if - sgn = -sgn end do - A = A / tod%scans(scan)%d(i)%N_psd%sigma0**2 - b = b / tod%scans(scan)%d(i)%N_psd%sigma0**2 - - ! solving the linear system - call solve_system_real(A, x, B) - - ! Add fluctuation - call compute_hermitian_root(A, -0.5d0) - do j = 1, 3 - eta(j) = rand_gauss(handle) - end do - x = x + matmul(A, eta) - !x(1) = abs(x(1)) ! Ensure positive galactic plane - - ! saving the offset (and gain) to the tod object - write(*,*) "X=", real(X,sp) - tod%scans(scan)%d(i)%gain = X(1) - tod%scans(scan)%d(i)%baseline = X(2) - tod%scans(scan)%d(i)%baseline2 = X(3) - - if (x(1) < 0.d0) then - tod%scans(scan)%d(i)%gain = -X(1) - tod%mod_phase(i,scan) = -tod%mod_phase(i,scan) + + if (n == 0) then + write(*,*) "Scan disabled in set_modulation_phase" + tod%scans(scan)%d(i)%accept = .false. + else + mu = mu/n + + ! saving the offset (and gain) to the tod object + if (mu < 0.d0) then + tod%mod_phase(i,scan) = -1 + end if end if - end do - end subroutine sample_hfi_baselines + end subroutine set_modulation_phase + +!!$ subroutine sample_hfi_baselines(self, tod, scan, handle) +!!$ ! +!!$ ! Estimates baselines for MODULATED data, separate for odd and even samples +!!$ ! +!!$ ! Arguments: +!!$ ! ---------- +!!$ ! self: derived class (comm_scandata) +!!$ ! HFI-specific TOD object +!!$ ! tod: comm_tod derived type +!!$ ! contains TOD-specific information +!!$ ! scan: scan ID +!!$ ! handle: planck_rng derived type +!!$ ! Healpix definition for random number generation +!!$ ! so that the same sequence can be resumed later on from that same +!!$ ! point +!!$ ! +!!$ ! +!!$ ! Returns +!!$ ! ---------- +!!$ ! None, but updates tod%scans(scan)%d(:)%baseline (for odd samples) +!!$ ! tod%scans(scan)%d(:)%baseline2 (for even samples) +!!$ ! tod%scans(scan)%d(:)%gain (temporary solution) +!!$ ! +!!$ implicit none +!!$ class(comm_scandata), intent(in) :: self +!!$ class(comm_hfi_tod), intent(inout) :: tod +!!$ integer(i4b), intent(in) :: sca66n +!!$ type(planck_rng), intent(inout) :: handle +!!$ logical(lgt), intent(in), optional :: update_gain +!!$ +!!$ real(dp) :: invN, B(3), eta(3), X(3), A(3,3), sgn +!!$ integer(i4b) :: i, j +!!$ +!!$ ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] +!!$ ! sd = self --- self%s_tot - sky signal model +!!$ ! self%s_tot(self%ntod, self%ndet) - how s_tot structured +!!$ +!!$ do i = 1, tod%ndet +!!$ +!!$ ! Build linear system +!!$ A = 0.d0 +!!$ B = 0.d0 +!!$ sgn = tod%mod_phase(i,scan) +!!$ do j = 1, self%ntod +!!$ if (self%mask(j,i) == 0) then +!!$ sgn = -sgn +!!$ cycle +!!$ end if +!!$ A(1,1) = A(1,1) + self%s_tot(j,i) * self%s_tot(j,i) +!!$ B(1) = B(1) + sgn * self%s_tot(j,i) * self%tod(j,i) +!!$ if (mod(j,2) == 1) then +!!$ A(2,1) = A(2,1) + self%s_tot(j,i) +!!$ A(2,2) = A(2,2) + 1.d0 +!!$ B(2) = B(2) + self%tod(j,i) +!!$ else +!!$ A(3,1) = A(3,1) - self%s_tot(j,i) +!!$ A(3,3) = A(3,3) + 1.d0 +!!$ B(3) = B(3) + self%tod(j,i) +!!$ end if +!!$ sgn = -sgn +!!$ end do +!!$ A = A / tod%scans(scan)%d(i)%N_psd%sigma0**2 +!!$ b = b / tod%scans(scan)%d(i)%N_psd%sigma0**2 +!!$ +!!$ ! solving the linear system +!!$ call solve_system_real(A, x, B) +!!$ +!!$ ! Add fluctuation +!!$ call compute_hermitian_root(A, -0.5d0) +!!$ do j = 1, 3 +!!$ eta(j) = rand_gauss(handle) +!!$ end do +!!$ x = x + matmul(A, eta) +!!$ !x(1) = abs(x(1)) ! Ensure positive galactic plane +!!$ +!!$ if (x(1) < 0.d0) then +!!$ x(1) = -x(1) +!!$ tod%mod_phase(i,scan) = -tod%mod_phase(i,scan) +!!$ end if +!!$ +!!$ ! saving the offset (and gain) to the tod object +!!$ write(*,*) "X=", real(X,sp) +!!$ if (update_gain_) tod%scans(scan)%d(i)%gain = X(1) +!!$ tod%scans(scan)%d(i)%baseline = X(2) +!!$ tod%scans(scan)%d(i)%baseline2 = X(3) +!!$ +!!$ end do +!!$ +!!$ end subroutine sample_hfi_baselines + subroutine demodulate_tod(self, tod, scan) ! @@ -624,6 +766,7 @@ subroutine demodulate_tod(self, tod, scan) logical :: exists do i = 1, tod%ndet + if (.not. tod%scans(scan)%d(i)%accept) cycle sgn = tod%mod_phase(i,scan) ! Subtract baselines and flip sign of even samples @@ -637,6 +780,12 @@ subroutine demodulate_tod(self, tod, scan) end do +!!$ open(58,file='tod.dat') +!!$ do j = 1, self%ntod +!!$ write(58,*) j, self%tod(j,1), self%mask(j,1) +!!$ end do +!!$ close(58) + end subroutine demodulate_tod diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 3d90d1208..a2ab1da5c 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -202,6 +202,8 @@ module comm_tod_mod procedure(process_tod), deferred :: process_tod procedure :: construct_sl_template procedure :: construct_corrtemp_inst + procedure :: construct_nonlin_corr_inst + procedure :: apply_nonlin_corr_inst procedure :: construct_dipole_template procedure :: construct_dipole_template_diff procedure :: output_scan_list @@ -1753,6 +1755,49 @@ subroutine construct_corrtemp_inst(self, scan, pix, psi, s) end subroutine construct_corrtemp_inst + subroutine construct_nonlin_corr_inst(self, scan, sd) + ! Construct an instrument-specific correction template + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! pix: int + ! index for pixel + ! psi: int + ! integer label for polarization angle + ! + ! Returns: + ! -------- + ! s: real (sp) + ! output template timestream + implicit none + class(comm_tod), intent(inout) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + return + + end subroutine construct_nonlin_corr_inst + + subroutine apply_nonlin_corr_inst(self, scan, sd) + ! Apply an instrument-specific non_linear corrections + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + implicit none + class(comm_tod), intent(inout) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + return + + end subroutine apply_nonlin_corr_inst + subroutine construct_dipole_template(self, scan, pix, psi, s_dip) ! construct a CMB dipole template in the time domain From 054cec16b6e563c109bab9d10e8915e4fef81499 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 27 Oct 2024 10:01:35 +0100 Subject: [PATCH 047/171] Split off nonlin estimation from main loop --- commander3/src/comm_tod_driver_mod.f90 | 8 +- commander3/src/comm_tod_hfi_mod.f90 | 157 ++++++------------------- commander3/src/comm_tod_mod.f90 | 2 +- 3 files changed, 40 insertions(+), 127 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 3a3148930..c7cf7b823 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -20,7 +20,7 @@ module comm_tod_driver_mod ! Scan data routines !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2, & - & init_s_bp, init_s_bp_prop, init_s_sky_prop) + & init_s_bp, init_s_bp_prop, init_s_sky_prop, skip_nonlin) implicit none class(comm_scandata), intent(inout) :: sd class(comm_tod), intent(inout) :: tod @@ -31,9 +31,10 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2 logical(lgt), intent(in), optional :: init_s_bp logical(lgt), intent(in), optional :: init_s_bp_prop logical(lgt), intent(in), optional :: init_s_sky_prop + logical(lgt), intent(in), optional :: skip_nonlin integer(i4b) :: j, k, ndelta - logical(lgt) :: init_s_bp_, init_s_bp_prop_, init_s_sky_prop_ + logical(lgt) :: init_s_bp_, init_s_bp_prop_, init_s_sky_prop_, skip_nonlin_ if (tod%nhorn /= 1) then write(*,*) 'Error: init_scan_data_singlehorn only applicable for 1-horn experiments' @@ -44,6 +45,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2 init_s_bp_ = .false.; if (present(init_s_bp)) init_s_bp_ = init_s_bp init_s_sky_prop_ = .false.; if (present(init_s_sky_prop)) init_s_sky_prop_ = init_s_sky_prop + skip_nonlin_ = .false.; if (present(skip_nonlin)) skip_nonlin_ = skip_nonlin init_s_bp_prop_ = .false. if (present(init_s_bp_prop)) then init_s_bp_prop_ = init_s_bp_prop @@ -223,7 +225,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, procmask, procmask2 end do ! Apply non-linearity corrections - call tod%apply_nonlin_corr_inst(scan, sd) + if (.not. skip_nonlin_) call tod%apply_nonlin_corr_inst(scan, sd) !call update_status(status, "todinit_stot") diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index e285ac82f..61a2e3603 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -58,7 +58,7 @@ module comm_tod_HFI_mod procedure :: initHDF_inst => initHDF_HFI procedure :: dumpToHDF_inst => dumpToHDF_HFI procedure :: construct_corrtemp_inst => construct_corrtemp_hfi -! procedure :: apply_nonlin_corr_hfi + procedure :: apply_nonlin_corr_inst => apply_nonlin_corr_hfi end type comm_HFI_tod interface comm_HFI_tod @@ -305,6 +305,26 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Perform main sampling steps !------------------------------------ + ! Fit low-level non-linearity parameters + do i = 1, self%nscan + + ! Skip scan if no accepted data + if (.not. any(self%scans(i)%d%accept)) cycle + call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, skip_nonlin=.true.) + + ! Estimate modulation baselines; separate for odd and even samples + call sample_hfi_baselines(sd, self, i, handle) + + ! Fix modulation phase + if (self%first_call) call set_modulation_phase(sd, self, i) + + ! Estimate ADC corrections + ! Not implemented yet + + ! Clean up + call dealloc_scandata(sd) + end do + ! Sample gain components in separate TOD loops; marginal with respect to n_corr !call sample_calibration(self, 'abscal', handle, map_sky, procmask, procmask2) !call sample_calibration(self, 'relcal', handle, map_sky, procmask, procmask2) @@ -321,7 +341,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m slist = '' end if - ! Perform loop over scans + ! Fit higher-level corrections if (self%myid == 0) write(*,*) ' --> Sampling ncorr, xi_n, maps' do i = 1, self%nscan @@ -350,19 +370,6 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Perform low-level TOD processing; raw modulated TOD -> clean demodulated TOD ! ************************************************************************************ - ! Estimate ADC corrections - ! Not implemented yet - - ! Apply ADC corrections to raw self%tod - ! Not implemented yet - - ! Estimate baselines; separate for odd and even samples - call sample_hfi_baselines(sd, self, i, handle) - call set_modulation_phase(sd, self, i) - - ! Demodulate TOD - call demodulate_tod(sd, self, i) - if (self%first_call) then ! Search for jumps ! Not implemented yet @@ -571,13 +578,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) b2 = b2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 tod%scans(scan)%d(i)%baseline2 = b2/A2 + rand_gauss(handle)/sqrt(A2) - ! saving the offset (and gain) to the tod object - -!!$ if (b1/A1 < b2/A2 .and. tod%mod_phase(i,scan) == 1) then -!!$ tod%mod_phase(i,scan) = -1 -!!$ end if - - write(*,*) "baseline=", tod%scans(scan)%d(i)%baseline, tod%scans(scan)%d(i)%baseline2, tod%mod_phase(i,scan) + !write(*,*) "baseline=", tod%scans(scan)%d(i)%baseline, tod%scans(scan)%d(i)%baseline2, tod%mod_phase(i,scan) end do @@ -614,10 +615,6 @@ subroutine set_modulation_phase(self, tod, scan) real(dp) :: mu, n integer(i4b) :: i, j - ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] - ! sd = self --- self%s_tot - sky signal model - ! self%s_tot(self%ntod, self%ndet) - how s_tot structured - do i = 1, tod%ndet if (.not. tod%scans(scan)%d(i)%accept) cycle @@ -639,7 +636,7 @@ subroutine set_modulation_phase(self, tod, scan) else mu = mu/n - ! saving the offset (and gain) to the tod object + ! saving the phase to the tod object if (mu < 0.d0) then tod%mod_phase(i,scan) = -1 end if @@ -648,97 +645,6 @@ subroutine set_modulation_phase(self, tod, scan) end subroutine set_modulation_phase -!!$ subroutine sample_hfi_baselines(self, tod, scan, handle) -!!$ ! -!!$ ! Estimates baselines for MODULATED data, separate for odd and even samples -!!$ ! -!!$ ! Arguments: -!!$ ! ---------- -!!$ ! self: derived class (comm_scandata) -!!$ ! HFI-specific TOD object -!!$ ! tod: comm_tod derived type -!!$ ! contains TOD-specific information -!!$ ! scan: scan ID -!!$ ! handle: planck_rng derived type -!!$ ! Healpix definition for random number generation -!!$ ! so that the same sequence can be resumed later on from that same -!!$ ! point -!!$ ! -!!$ ! -!!$ ! Returns -!!$ ! ---------- -!!$ ! None, but updates tod%scans(scan)%d(:)%baseline (for odd samples) -!!$ ! tod%scans(scan)%d(:)%baseline2 (for even samples) -!!$ ! tod%scans(scan)%d(:)%gain (temporary solution) -!!$ ! -!!$ implicit none -!!$ class(comm_scandata), intent(in) :: self -!!$ class(comm_hfi_tod), intent(inout) :: tod -!!$ integer(i4b), intent(in) :: sca66n -!!$ type(planck_rng), intent(inout) :: handle -!!$ logical(lgt), intent(in), optional :: update_gain -!!$ -!!$ real(dp) :: invN, B(3), eta(3), X(3), A(3,3), sgn -!!$ integer(i4b) :: i, j -!!$ -!!$ ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] -!!$ ! sd = self --- self%s_tot - sky signal model -!!$ ! self%s_tot(self%ntod, self%ndet) - how s_tot structured -!!$ -!!$ do i = 1, tod%ndet -!!$ -!!$ ! Build linear system -!!$ A = 0.d0 -!!$ B = 0.d0 -!!$ sgn = tod%mod_phase(i,scan) -!!$ do j = 1, self%ntod -!!$ if (self%mask(j,i) == 0) then -!!$ sgn = -sgn -!!$ cycle -!!$ end if -!!$ A(1,1) = A(1,1) + self%s_tot(j,i) * self%s_tot(j,i) -!!$ B(1) = B(1) + sgn * self%s_tot(j,i) * self%tod(j,i) -!!$ if (mod(j,2) == 1) then -!!$ A(2,1) = A(2,1) + self%s_tot(j,i) -!!$ A(2,2) = A(2,2) + 1.d0 -!!$ B(2) = B(2) + self%tod(j,i) -!!$ else -!!$ A(3,1) = A(3,1) - self%s_tot(j,i) -!!$ A(3,3) = A(3,3) + 1.d0 -!!$ B(3) = B(3) + self%tod(j,i) -!!$ end if -!!$ sgn = -sgn -!!$ end do -!!$ A = A / tod%scans(scan)%d(i)%N_psd%sigma0**2 -!!$ b = b / tod%scans(scan)%d(i)%N_psd%sigma0**2 -!!$ -!!$ ! solving the linear system -!!$ call solve_system_real(A, x, B) -!!$ -!!$ ! Add fluctuation -!!$ call compute_hermitian_root(A, -0.5d0) -!!$ do j = 1, 3 -!!$ eta(j) = rand_gauss(handle) -!!$ end do -!!$ x = x + matmul(A, eta) -!!$ !x(1) = abs(x(1)) ! Ensure positive galactic plane -!!$ -!!$ if (x(1) < 0.d0) then -!!$ x(1) = -x(1) -!!$ tod%mod_phase(i,scan) = -tod%mod_phase(i,scan) -!!$ end if -!!$ -!!$ ! saving the offset (and gain) to the tod object -!!$ write(*,*) "X=", real(X,sp) -!!$ if (update_gain_) tod%scans(scan)%d(i)%gain = X(1) -!!$ tod%scans(scan)%d(i)%baseline = X(2) -!!$ tod%scans(scan)%d(i)%baseline2 = X(3) -!!$ -!!$ end do -!!$ -!!$ end subroutine sample_hfi_baselines - - subroutine demodulate_tod(self, tod, scan) ! @@ -769,7 +675,7 @@ subroutine demodulate_tod(self, tod, scan) if (.not. tod%scans(scan)%d(i)%accept) cycle sgn = tod%mod_phase(i,scan) - ! Subtract baselines and flip sign of even samples + ! Subtract baselines and flip sign of every other sample do j = 1, self%ntod if (mod(j,2) == 1) then self%tod(j,i) = sgn*(self%tod(j,i) - tod%scans(scan)%d(i)%baseline) @@ -915,8 +821,8 @@ subroutine construct_corrtemp_hfi(self, scan, pix, psi, s) end subroutine construct_corrtemp_hfi - subroutine apply_hfi_nonlin_corr(self, sd) - ! Construct an LFI instrument-specific correction template; for now contains 1Hz template only + subroutine apply_nonlin_corr_hfi(self, scan, sd) + ! Construct and apply HFI instrument-specific non-linear corrections ! ! Arguments: ! ---------- @@ -935,10 +841,15 @@ subroutine apply_hfi_nonlin_corr(self, sd) ! output template timestream implicit none class(comm_hfi_tod), intent(in) :: self + integer(i4b), intent(in) :: scan class(comm_scandata), intent(inout) :: sd - return + ! Apply ADC corrections to raw self%tod + ! Not implemented yet + + ! Demodulate TOD + call demodulate_tod(sd, self, scan) - end subroutine apply_hfi_nonlin_corr + end subroutine apply_nonlin_corr_hfi end module comm_tod_HFI_mod diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index a2ab1da5c..90db8d878 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -1790,7 +1790,7 @@ subroutine apply_nonlin_corr_inst(self, scan, sd) ! self: comm_tod object ! implicit none - class(comm_tod), intent(inout) :: self + class(comm_tod), intent(in) :: self integer(i4b), intent(in) :: scan class(comm_scandata), intent(inout) :: sd From 21b4e612d37c2641fe5d1390f58fffd1f0799880 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 27 Oct 2024 10:35:16 +0100 Subject: [PATCH 048/171] Enabled absolute calibration --- commander3/config/config.ita_internal | 4 ++-- commander3/src/comm_tod_hfi_mod.f90 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index 6d647d271..afa6a5b17 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -53,11 +53,11 @@ export MPCC := mpiicc #export F90FLAGS := -fpe0 -march=native -g -O2 -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -xHost #export F90FLAGS := -g -O2 -traceback #export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -prof-gen=srcpos -prof-dir=/mn/stornext/u3/hke/xsan/commander3/BP9/prof -#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -diag-disable=10448 +export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -diag-disable=10448 #debug # -export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 +#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 61a2e3603..db5fe1251 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -326,7 +326,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end do ! Sample gain components in separate TOD loops; marginal with respect to n_corr - !call sample_calibration(self, 'abscal', handle, map_sky, procmask, procmask2) + call sample_calibration(self, 'abscal', handle, map_sky, procmask2, procmask2) !call sample_calibration(self, 'relcal', handle, map_sky, procmask, procmask2) !call sample_calibration(self, 'deltaG', handle, map_sky, procmask, procmask2) From 4c9aa3deca24e92b6b68f80372b72596abc46c2c Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 27 Oct 2024 11:08:53 +0100 Subject: [PATCH 049/171] Subtract signal in baseline estimation --- commander3/src/comm_tod_hfi_mod.f90 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index db5fe1251..52c6e0498 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -313,7 +313,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, skip_nonlin=.true.) ! Estimate modulation baselines; separate for odd and even samples - call sample_hfi_baselines(sd, self, i, handle) + if (self%first_call) then + call sample_hfi_baselines(sd, self, i, handle, subtract_s_tot=.false.) + else + call sample_hfi_baselines(sd, self, i, handle) + end if ! Fix modulation phase if (self%first_call) call set_modulation_phase(sd, self, i) @@ -517,7 +521,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end subroutine process_HFI_tod - subroutine sample_hfi_baselines(self, tod, scan, handle) + subroutine sample_hfi_baselines(self, tod, scan, handle, subtract_s_tot) ! ! Estimates baselines for MODULATED data, separate for odd and even samples ! @@ -545,9 +549,14 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) class(comm_hfi_tod), intent(inout) :: tod integer(i4b), intent(in) :: scan type(planck_rng), intent(inout) :: handle + logical(lgt), intent(in), optional :: subtract_s_tot real(dp) :: eta, A1, A2, x, b1, b2, sgn,gal_mean integer(i4b) :: i, j, n + logical(lgt) :: sub_s + + sub_s = .true.; if (present(subtract_s_tot)) sub_s = subtract_s_tot + ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] ! sd = self --- self%s_tot - sky signal model @@ -555,6 +564,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) do i = 1, tod%ndet if (.not. tod%scans(scan)%d(i)%accept) cycle + sgn = tod%mod_phase(i,scan) ! Odd samples A1 = 0.d0; b1 = 0; gal_mean = 0.d0; n = 0 @@ -562,6 +572,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) if (self%mask(j,i) == 0) cycle A1 = A1 + 1.d0 b1 = b1 + self%tod(j,i) + if (sub_s) b1 = b1 - sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) end do A1 = A1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 b1 = b1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 @@ -573,6 +584,7 @@ subroutine sample_hfi_baselines(self, tod, scan, handle) if (self%mask(j,i) == 0) cycle A2 = A2 + 1.d0 b2 = b2 + self%tod(j,i) + if (sub_s) b1 = b1 + sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) end do A2 = A2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 b2 = b2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 From b48307279cf4d5a99385667f7a0996c45a08c5da Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 2 Nov 2024 08:41:33 +0100 Subject: [PATCH 050/171] Added support for linear MBBtab --- .../dust/dust_coldtab_DIRBE.defaults | 1 + commander3/src/comm_diffuse_comp_mod.f90 | 6 +- commander3/src/comm_line_comp_mod.f90 | 6 +- commander3/src/comm_mbbtab_comp_mod.f90 | 25 ++++++-- commander3/src/comm_mh_specind_mod.f90 | 16 ++--- commander3/src/comm_param_mod.f90 | 5 +- commander3/src/commander.f90 | 61 +++++++++++-------- 7 files changed, 77 insertions(+), 43 deletions(-) diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults index 7147c561a..c3528c818 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults @@ -1,6 +1,7 @@ # Cold thermal dust component COMP_LABEL&& = dust COMP_TYPE&& = MBBtab +COMP_MBBTAB_TYPE = binned COMP_CLASS&& = diffuse # {diffuse, ptsrc} COMP_POLARIZATION&& = .false. COMP_CG_SCALE_T&& = 1.d0 diff --git a/commander3/src/comm_diffuse_comp_mod.f90 b/commander3/src/comm_diffuse_comp_mod.f90 index f98568002..6c321a38b 100644 --- a/commander3/src/comm_diffuse_comp_mod.f90 +++ b/commander3/src/comm_diffuse_comp_mod.f90 @@ -113,9 +113,9 @@ module comm_diffuse_comp_mod ! only interfaces in this file, accompanying smod.f logical(lgt), dimension(:,:), allocatable :: F_null ! Don't allocate space for null mixmat's type(F_int_ptr), dimension(:,:,:), allocatable :: F_int ! SED integrator integer(i4b) :: ntab - real(dp), allocatable, dimension(:,:) :: SEDtab - real(dp), allocatable, dimension(:,:) :: SEDtab_buff - real(dp) :: SEDtab_prior ! Single value for MH proposals, per comp + real(dp), allocatable, dimension(:,:) :: SEDtab ! (2+npar_tab, nbin) + real(dp), allocatable, dimension(:,:) :: SEDtab_buff ! + real(dp) :: SEDtab_prior ! (npar_tab), Single value for MH proposals, per comp contains procedure :: initDiffuse procedure :: initPixregSampling diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index ef9aaca74..dbf25b1ca 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -326,7 +326,11 @@ subroutine sampleLineRatios(self, cpar, handle, id, iter) end do end if - write(*,*) ' Line ratio i = ', id, ' = ', par + if (band == self%ref_band) then + write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' + else + write(*,*) ' Line ratio i = ', id, ' = ', par + end if end if ! Distribute new relative line ratio, and update diff --git a/commander3/src/comm_mbbtab_comp_mod.f90 b/commander3/src/comm_mbbtab_comp_mod.f90 index adbd048de..ec2f1fbc9 100644 --- a/commander3/src/comm_mbbtab_comp_mod.f90 +++ b/commander3/src/comm_mbbtab_comp_mod.f90 @@ -29,7 +29,8 @@ module comm_MBBtab_comp_mod ! Modified Black Body (MBBtab) component !************************************************** type, extends (comm_diffuse_comp) :: comm_MBBtab_comp - !integer(i4b) :: ntab + character(len=128) :: mbbtab_type + integer(i4b) :: npar_tab !real(dp), allocatable, dimension(:,:) :: SEDtab !real(dp), allocatable, dimension(:,:) :: SEDtab_buff contains @@ -75,6 +76,17 @@ function constructor_mbbtab(cpar, id, id_abs) result(c) call c%initDiffuse(cpar, id, id_abs) + ! Set up MBBtab type + c%mbbtab_type = cpar%cs_mbbtab_type(id_abs) + if (trim(c%mbbtab_type) == 'binned') then + c%npar_tab = 1 + else if (trim(c%mbbtab_type) == 'linear') then + c%npar_tab = 2 + else + write(*,*) 'Error: Unknown MBBtab type =', trim(c%mbbtab_type) + stop + end if + ! Component specific parameters allocate(c%theta_def(2), c%p_gauss(2,2), c%p_uni(2,2)) allocate(c%indlabel(2)) @@ -165,7 +177,12 @@ function evalSED_mbbtab(self, nu, band, pol, theta) do i = 1, self%ntab if (nu > self%SEDtab(1,i) .and. nu <= self%SEDtab(2,i)) then ! Table defined in flux density - evalSED_mbbtab = self%SEDtab(3,i) * (self%nu_ref(pol)/nu)**2 + if (trim(self%mbbtab_type) == 'binned') then + evalSED_mbbtab = self%SEDtab(3,i) + else if (trim(self%mbbtab_type) == 'linear') then + evalSED_mbbtab = self%SEDtab(3,i) + self%SEDtab(4,i) * (nu-self%SEDtab(1,i))/(self%SEDtab(2,i)-self%SEDtab(1,i)) + end if + evalSED_mbbtab = evalSED_mbbtab * (self%nu_ref(pol)/nu)**2 return end if end do @@ -205,8 +222,8 @@ subroutine read_SED_table(self, filename) end do 1 close(unit) - allocate(self%SEDtab(3,self%ntab)) - allocate(self%SEDtab_buff(3,self%ntab)) + allocate(self%SEDtab(2+self%npar_tab,self%ntab)) + allocate(self%SEDtab_buff(2+self%npar_tab,self%ntab)) open(unit, file=trim(filename)) i = 0 do while (.true.) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 67111c6ad..2d8d97292 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -413,15 +413,17 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) write(*,*) '| MBBtab original' do i = 1, c%ntab if (c%theta_steplen(c%npar+i,l) > 0) then - write(*,*) '| ', c%SEDtab(3,i) + write(*,*) '| ', c%SEDtab(3:,i) end if end do write(*,*) '| MBBtab proposal' do i = 1, c%ntab - if (c%theta_steplen(c%npar+i,l) > 0) then - c%SEDtab(3,i) = c%SEDtab(3,i) + rand_gauss(handle) * c%theta_steplen(c%npar+i,l) - write(*,*) '| ', c%SEDtab(3,i) - end if + if (c%theta_steplen(c%npar+i,l) > 0) then + do j = 3, size(c%SEDtab(:,i)) + c%SEDtab(j,i) = c%SEDtab(j,i) + rand_gauss(handle) * c%theta_steplen(c%npar+i,l) + end do + write(*,*) '| ', c%SEDtab(3:,i) + end if end do end if @@ -481,7 +483,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) if (maxval(c%theta_steplen(c%npar+1:,l)) > 0) then if (cpar%myid_chain .eq. 0) then do i = 1, c%ntab - c%SEDtab(3,i) = c%SEDtab_buff(3,i) + c%SEDtab(3:,i) = c%SEDtab_buff(3:,i) end do end if @@ -765,7 +767,7 @@ subroutine initialize_mh_mod(cpar) class(comm_map), pointer :: indmask, mask_ud - integer(i4b) :: i, j, k, nside, lmax, nmaps, n, m, n_tokens, n_in_group, ierr, num_gains + integer(i4b) :: i, j, k, nside, lmax, nmaps, n, m, npar, n_tokens, n_in_group, ierr, num_gains integer(i4b) :: wire_to_ind, wire_from_ind integer(i4b), allocatable, dimension(:,:) :: bands_to_sample real(dp) :: sigma diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index f72e41e10..43ab720af 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -251,6 +251,7 @@ module comm_param_mod character(len=512), allocatable, dimension(:) :: cs_prior_amp character(len=512), allocatable, dimension(:,:) :: cs_input_ind character(len=512), allocatable, dimension(:,:) :: cs_SED_template + character(len=512), allocatable, dimension(:) :: cs_MBBtab_type real(dp), allocatable, dimension(:) :: cs_SED_prior real(dp), allocatable, dimension(:,:) :: cs_theta_def real(dp), allocatable, dimension(:,:) :: cs_nu_break @@ -815,7 +816,7 @@ subroutine read_component_params_hash(htbl, cpar) allocate(cpar%cs_input_amp(n), cpar%cs_prior_amp(n), cpar%cs_input_ind(MAXPAR,n)) allocate(cpar%cs_theta_def(MAXPAR,n), cpar%cs_p_uni(n,2,MAXPAR), cpar%cs_p_gauss(n,2,MAXPAR)) allocate(cpar%cs_catalog(n), cpar%cs_init_catalog(n), cpar%cs_SED_template(4,n), cpar%cs_cg_scale(3,n)) - allocate(cpar%cs_SED_prior(n)) + allocate(cpar%cs_SED_prior(n), cpar%cs_MBBtab_type(n)) allocate(cpar%cs_ptsrc_template(n), cpar%cs_output_ptsrc_beam(n), cpar%cs_min_src_dist(n)) allocate(cpar%cs_auxpar(MAXAUXPAR,n), cpar%cs_apply_pos_prior(n)) allocate(cpar%cs_nu_min_beta(n,MAXPAR), cpar%cs_nu_max_beta(n,MAXPAR), cpar%cs_burn_in(n)) @@ -2637,6 +2638,8 @@ subroutine read_mbb_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_ if (trim(cpar%cs_type(i)) == 'MBBtab') then call get_parameter_hashtable(htbl, 'COMP_SED_TEMPLATE'//itext, len_itext=len_itext, & & par_string=cpar%cs_SED_template(1,i), path=.true.) + call get_parameter_hashtable(htbl, 'COMP_MBBTAB_TYPE'//itext, len_itext=len_itext, & + & par_string=cpar%cs_MBBtab_type(i)) call get_parameter_hashtable(htbl, 'COMP_SED_PRIOR'//itext, len_itext=len_itext, & & par_dp=cpar%cs_SED_prior(i)) end if diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 2efd39b17..f2696ef5e 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -411,20 +411,50 @@ program commander call timer%stop(TOT_ZODI_SAMP) end if - + if (mod(iter+1,modfact) == 0) then + ! Sample linear parameters with CG search; loop over CG sample groups + !call output_FITS_sample(cpar, 1000+iter, .true.) + if (cpar%sample_signal_amplitudes .and. iter > 1) then + + ! Do CG group sampling + call sample_all_amps_by_CG(cpar, handle, handle_noise) + + ! Perform joint alm-Cl Metropolis move + call timer%start(TOT_CLS) + do i = 1, 3 + if (cpar%resamp_CMB .and. cpar%sample_powspec) call sample_joint_alm_Cl(handle) + end do + call timer%stop(TOT_CLS) + end if + + ! Sample power spectra + call timer%start(TOT_CLS) + if (cpar%sample_powspec) call sample_powspec(handle, ok) + call timer%stop(TOT_CLS) + + if (iter > 1) then + !if (iter > 3) then + do i = 1, cpar%mcmc_num_samp_groups + if (index(cpar%mcmc_samp_groups(i), ':scale%') .ne. 0) then + if (cpar%myid == 0) write(*,*) '| MH sampling scaling amplitudes' + call sample_template_mh(cpar%outdir, cpar, handle, handle_noise, i) + end if + end do + end if ! Sample non-linear parameters - if (iter > 3 .and. cpar%sample_specind) then + if (iter > 1 .and. cpar%sample_specind) then call timer%start(TOT_SPECIND) call sample_nonlin_params(cpar, iter, handle, handle_noise) call timer%stop(TOT_SPECIND) end if !if (mod(iter,cpar%thinning) == 0) call output_FITS_sample(cpar, 100+iter, .true.) - - if (iter > 3) then + + if (iter > 1) then + !if (iter > 3) then do i = 1, cpar%mcmc_num_samp_groups if (index(cpar%mcmc_samp_groups(i), 'gain:') .ne. 0) then if (cpar%myid == 0) write(*,*) '| MH sampling map-based gains' @@ -432,9 +462,6 @@ program commander else if (index(cpar%mcmc_samp_groups(i), ':tab@') .ne. 0) then if (cpar%myid == 0) write(*,*) '| MH sampling tabulated SEDs' call sample_mbbtab_mh(cpar%outdir, cpar, handle, handle_noise, i) - else if (index(cpar%mcmc_samp_groups(i), ':scale%') .ne. 0) then - if (cpar%myid == 0) write(*,*) '| MH sampling scaling amplitudes' - call sample_template_mh(cpar%outdir, cpar, handle, handle_noise, i) else if (cpar%myid == 0) write(*,*) '| MH sampling spectral indices' call sample_specind_mh(cpar%outdir, cpar, handle, handle_noise, i) @@ -442,26 +469,6 @@ program commander end do end if - ! Sample linear parameters with CG search; loop over CG sample groups - !call output_FITS_sample(cpar, 1000+iter, .true.) - if (cpar%sample_signal_amplitudes .and. iter > 1) then - - ! Do CG group sampling - call sample_all_amps_by_CG(cpar, handle, handle_noise) - - ! Perform joint alm-Cl Metropolis move - call timer%start(TOT_CLS) - do i = 1, 3 - if (cpar%resamp_CMB .and. cpar%sample_powspec) call sample_joint_alm_Cl(handle) - end do - call timer%stop(TOT_CLS) - end if - - ! Sample power spectra - call timer%start(TOT_CLS) - if (cpar%sample_powspec) call sample_powspec(handle, ok) - call timer%stop(TOT_CLS) - end if ! Output sample to disk From 190eb90cb76fb07857246929d9eedae2aca1d9fa Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Tue, 12 Nov 2024 12:39:27 +0100 Subject: [PATCH 051/171] pointing script --- commander3/src/comm_hdf_mod.f90 | 5416 +++++++++++++++++ commander3/src/comm_hdf_mod.f90.in | 24 +- .../todscripts/hfi/hfitohdf5_pointing.py | 487 ++ 3 files changed, 5926 insertions(+), 1 deletion(-) create mode 100644 commander3/todscripts/hfi/hfitohdf5_pointing.py diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index e69de29bb..949a68dcf 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -0,0 +1,5416 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ +! Due to the extreme amount of redundancy in hdf_mod, it is now generated +! by using the handy tempita template language. All the machinery for +! doing this is included in the repository, so this should just work. +module comm_hdf_mod + use comm_utils + use hdf5 + implicit none + + type hdf_file + character(len=512) :: filename, setname + integer(hid_t) :: filehandle, sethandle + integer :: status + end type hdf_file + + type :: byte_pointer + byte, allocatable, dimension(:) :: p + ! contains + ! final :: dealloc_byte_pointer + end type byte_pointer + + interface read_hdf + module procedure read_hdf_0d_dp + module procedure read_hdf_0d_sp + module procedure read_hdf_0d_int + module procedure read_hdf_0d_char + module procedure read_hdf_1d_dp + module procedure read_hdf_1d_sp + module procedure read_hdf_1d_int + module procedure read_hdf_1d_char + module procedure read_hdf_2d_dp + module procedure read_hdf_2d_sp + module procedure read_hdf_2d_int + module procedure read_hdf_2d_char + module procedure read_hdf_3d_dp + module procedure read_hdf_3d_sp + module procedure read_hdf_3d_int + module procedure read_hdf_3d_char + module procedure read_hdf_4d_dp + module procedure read_hdf_4d_sp + module procedure read_hdf_4d_int + module procedure read_hdf_4d_char + module procedure read_hdf_5d_dp + module procedure read_hdf_5d_sp + module procedure read_hdf_5d_int + module procedure read_hdf_5d_char + module procedure read_hdf_6d_dp + module procedure read_hdf_6d_sp + module procedure read_hdf_6d_int + module procedure read_hdf_6d_char + module procedure read_hdf_7d_dp + module procedure read_hdf_7d_sp + module procedure read_hdf_7d_int + module procedure read_hdf_7d_char + module procedure read_hdf_slice_0d_dp + module procedure read_hdf_slice_0d_sp + module procedure read_hdf_slice_0d_int + module procedure read_hdf_slice_0d_char + module procedure read_hdf_slice_1d_dp + module procedure read_hdf_slice_1d_sp + module procedure read_hdf_slice_1d_int + module procedure read_hdf_slice_1d_char + module procedure read_hdf_slice_2d_dp + module procedure read_hdf_slice_2d_sp + module procedure read_hdf_slice_2d_int + module procedure read_hdf_slice_2d_char + module procedure read_hdf_slice_3d_dp + module procedure read_hdf_slice_3d_sp + module procedure read_hdf_slice_3d_int + module procedure read_hdf_slice_3d_char + module procedure read_hdf_slice_4d_dp + module procedure read_hdf_slice_4d_sp + module procedure read_hdf_slice_4d_int + module procedure read_hdf_slice_4d_char + module procedure read_hdf_slice_5d_dp + module procedure read_hdf_slice_5d_sp + module procedure read_hdf_slice_5d_int + module procedure read_hdf_slice_5d_char + module procedure read_hdf_slice_6d_dp + module procedure read_hdf_slice_6d_sp + module procedure read_hdf_slice_6d_int + module procedure read_hdf_slice_6d_char + module procedure read_hdf_slice_7d_dp + module procedure read_hdf_slice_7d_sp + module procedure read_hdf_slice_7d_int + module procedure read_hdf_slice_7d_char + end interface + + interface read_alloc_hdf + module procedure read_alloc_hdf_1d_dp + module procedure read_alloc_hdf_1d_sp + module procedure read_alloc_hdf_1d_int + module procedure read_alloc_hdf_1d_char + module procedure read_alloc_hdf_2d_dp + module procedure read_alloc_hdf_2d_sp + module procedure read_alloc_hdf_2d_int + module procedure read_alloc_hdf_2d_char + module procedure read_alloc_hdf_3d_dp + module procedure read_alloc_hdf_3d_sp + module procedure read_alloc_hdf_3d_int + module procedure read_alloc_hdf_3d_char + module procedure read_alloc_hdf_4d_dp + module procedure read_alloc_hdf_4d_sp + module procedure read_alloc_hdf_4d_int + module procedure read_alloc_hdf_4d_char + module procedure read_alloc_hdf_5d_dp + module procedure read_alloc_hdf_5d_sp + module procedure read_alloc_hdf_5d_int + module procedure read_alloc_hdf_5d_char + module procedure read_alloc_hdf_6d_dp + module procedure read_alloc_hdf_6d_sp + module procedure read_alloc_hdf_6d_int + module procedure read_alloc_hdf_6d_char + module procedure read_alloc_hdf_7d_dp + module procedure read_alloc_hdf_7d_sp + module procedure read_alloc_hdf_7d_int + module procedure read_alloc_hdf_7d_char + end interface + + interface write_hdf + module procedure write_hdf_0d_dp + module procedure write_hdf_0d_sp + module procedure write_hdf_0d_int + module procedure write_hdf_0d_char + module procedure write_hdf_1d_dp + module procedure write_hdf_1d_sp + module procedure write_hdf_1d_int + module procedure write_hdf_1d_char + module procedure write_hdf_2d_dp + module procedure write_hdf_2d_sp + module procedure write_hdf_2d_int + module procedure write_hdf_2d_char + module procedure write_hdf_3d_dp + module procedure write_hdf_3d_sp + module procedure write_hdf_3d_int + module procedure write_hdf_3d_char + module procedure write_hdf_4d_dp + module procedure write_hdf_4d_sp + module procedure write_hdf_4d_int + module procedure write_hdf_4d_char + module procedure write_hdf_5d_dp + module procedure write_hdf_5d_sp + module procedure write_hdf_5d_int + module procedure write_hdf_5d_char + module procedure write_hdf_6d_dp + module procedure write_hdf_6d_sp + module procedure write_hdf_6d_int + module procedure write_hdf_6d_char + module procedure write_hdf_7d_dp + module procedure write_hdf_7d_sp + module procedure write_hdf_7d_int + module procedure write_hdf_7d_char + module procedure write_hdf_slice_0d_dp + module procedure write_hdf_slice_0d_sp + module procedure write_hdf_slice_0d_int + module procedure write_hdf_slice_0d_char + module procedure write_hdf_slice_1d_dp + module procedure write_hdf_slice_1d_sp + module procedure write_hdf_slice_1d_int + module procedure write_hdf_slice_1d_char + module procedure write_hdf_slice_2d_dp + module procedure write_hdf_slice_2d_sp + module procedure write_hdf_slice_2d_int + module procedure write_hdf_slice_2d_char + module procedure write_hdf_slice_3d_dp + module procedure write_hdf_slice_3d_sp + module procedure write_hdf_slice_3d_int + module procedure write_hdf_slice_3d_char + module procedure write_hdf_slice_4d_dp + module procedure write_hdf_slice_4d_sp + module procedure write_hdf_slice_4d_int + module procedure write_hdf_slice_4d_char + module procedure write_hdf_slice_5d_dp + module procedure write_hdf_slice_5d_sp + module procedure write_hdf_slice_5d_int + module procedure write_hdf_slice_5d_char + module procedure write_hdf_slice_6d_dp + module procedure write_hdf_slice_6d_sp + module procedure write_hdf_slice_6d_int + module procedure write_hdf_slice_6d_char + module procedure write_hdf_slice_7d_dp + module procedure write_hdf_slice_7d_sp + module procedure write_hdf_slice_7d_int + module procedure write_hdf_slice_7d_char + end interface + + interface slice + module procedure slice_0d + module procedure slice_1d + module procedure slice_2d + module procedure slice_3d + module procedure slice_4d + module procedure slice_5d + module procedure slice_6d + module procedure slice_7d + end interface + +contains + + ! ***************************************************** + ! Initialization and cleanup routines + ! ***************************************************** + subroutine initialize_comm_hdf_mod + implicit none + logical(lgt), save :: initialized = .false. + integer(i4b) :: status + if(initialized) return + call h5open_f(status) + call assert(status==0, 'comm_hdf_mod: Could not initialize hdf module') + initialized = .true. + end subroutine initialize_comm_hdf_mod + + subroutine cleanup_comm_hdf_mod + implicit none + integer(i4b) :: status + call h5close_f(status) + call assert(status==0, 'comm_hdf_mod: Could not close hdf module') + end subroutine cleanup_comm_hdf_mod + + subroutine copy_hdf_struct(file_in, file_out) + implicit none + type(hdf_file), intent(in) :: file_in + type(hdf_file), intent(out) :: file_out + + file_out%filename = file_in%filename + file_out%setname = file_in%setname + file_out%filehandle = file_in%filehandle + file_out%sethandle = file_in%sethandle + file_out%status = file_in%status + + end subroutine copy_hdf_struct + + + ! ***************************************************** + ! Basic file open and close routines + ! ***************************************************** + subroutine open_hdf_file(filename, file, mode) + implicit none + character(len=*), intent(in) :: filename + character(len=1), intent(in) :: mode + type(hdf_file) :: file + + ! Initialize + call initialize_comm_hdf_mod + + ! Open file in either read or write mode + file%filename = filename + file%status = 0 + if (mode == 'r') then + call h5fopen_f(file%filename, H5F_ACC_RDONLY_F, file%filehandle, file%status) + else if (mode == 'w') then + call h5fcreate_f(file%filename, H5F_ACC_TRUNC_F, file%filehandle, file%status) + else if (mode == 'b') then + call h5fopen_f(file%filename, H5F_ACC_RDWR_F, file%filehandle, file%status) + else + write(*,*) 'comm_hdf_mod: Unknown hdf file mode =', mode + stop + end if + + ! Initalize sethandle to empty value + file%setname = '' + file%sethandle = -1 + end subroutine open_hdf_file + + subroutine close_hdf_file(file) + implicit none + type(hdf_file) :: file + call close_hdf_set(file) + call h5fclose_f(file%filehandle, file%status) + call assert(file%status>=0, 'comm_hdf_mod: Could not close file') + end subroutine close_hdf_file + + subroutine open_hdf_set(file, setname) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + if (trim(file%setname) == trim(setname)) return + call close_hdf_set(file) + file%setname = setname + call h5dopen_f(file%filehandle, file%setname, file%sethandle, file%status) + end subroutine open_hdf_set + + subroutine close_hdf_set(file) + implicit none + type(hdf_file) :: file + if (file%sethandle == -1) return + call h5dclose_f(file%sethandle, file%status) + call assert(file%status>=0, 'comm_hdf_mod: Could not close set') + file%sethandle = -1 + file%setname = '' + end subroutine close_hdf_set + + ! ***************************************************** + ! Query operations + ! ***************************************************** + function get_rank_hdf(file, setname) result(rank) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) :: rank + integer(hid_t) :: space + call open_hdf_set(file, setname) + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_ndims_f(space, rank, file%status) + call h5sclose_f(space, file%status) + end function + + subroutine get_size_hdf(file, setname, ext) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(out) :: ext(:) + integer(i4b) :: rank + integer(hid_t) :: space, n + integer(hsize_t), allocatable, dimension(:) :: ext_hdf, mext_hdf + call open_hdf_set(file, setname) + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_ndims_f(space, rank, file%status) + allocate(ext_hdf(rank), mext_hdf(rank)) + call h5sget_simple_extent_dims_f(space, ext_hdf, mext_hdf, file%status) + call h5sclose_f(space, file%status) + if (file%status == -1) then + write(*,*) 'Error reading file ', trim(file%filename), trim(setname) + stop + end if + n = min(size(ext),rank) + ext(:n) = int(ext_hdf(:n),i4b) + deallocate(ext_hdf, mext_hdf) + end subroutine get_size_hdf + + function hdf_group_exists(file, group) result(exists) + type(hdf_file) :: file + character(len=*), intent(in) :: group + logical(lgt) :: exists + integer(i4b) :: hdferr + TYPE(h5o_info_t) :: object_info + + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, trim(adjustl(group)), object_info, hdferr) + exists = hdferr == 0 + end function hdf_group_exists + + ! ***************************************************** + ! Set read operations + ! ***************************************************** + + subroutine read_hdf_dp_2d_buffer(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(dp), dimension(:,:), intent(out) :: val + real(dp), dimension(:,:), allocatable :: buffer + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + return + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + call get_size_hdf(file, setname, ext) + allocate(buffer(ext(1),ext(2))) + ext2 = ext + ! Validate that sizes are consistent + !call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, buffer, ext2, file%status) + val = buffer(1:s(1),1:s(2)) + deallocate(buffer) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_int_2d_buffer(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + integer(i4b), dimension(:,:), intent(out) :: val + integer(i4b), dimension(:,:), allocatable :: buffer + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + return + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + call get_size_hdf(file, setname, ext) + allocate(buffer(ext(1),ext(2))) + ext2 = ext + ! Validate that sizes are consistent + !call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, buffer, ext2, file%status) + val = buffer(1:s(1),1:s(2)) + deallocate(buffer) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + real(dp) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + real(sp) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + integer(i4b) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_0d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(0), ext2(0) + integer(i4b) :: ext(0) + character(len=*) , intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + real(dp) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + real(sp) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + integer(i4b) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_1d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(1), ext2(1) + integer(i4b) :: ext(1) + character(len=*) ,dimension(:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(dp) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + real(sp) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + integer(i4b) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_2d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(2), ext2(2) + integer(i4b) :: ext(2) + character(len=*) ,dimension(:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + real(dp) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + real(sp) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + integer(i4b) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_3d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(3), ext2(3) + integer(i4b) :: ext(3) + character(len=*) ,dimension(:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + real(dp) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + real(sp) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + integer(i4b) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_4d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(4), ext2(4) + integer(i4b) :: ext(4) + character(len=*) ,dimension(:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + real(dp) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + real(sp) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_5d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(5), ext2(5) + integer(i4b) :: ext(5) + character(len=*) ,dimension(:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_6d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(6), ext2(6) + integer(i4b) :: ext(6) + character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_dp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_sp(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_int(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_hdf_7d_char(file, setname, val, opt) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + logical(lgt), intent(in), optional :: opt + TYPE(h5o_info_t) :: object_info + integer(i4b) :: hdferr, v(100) + integer(hsize_t) :: s(7), ext2(7) + integer(i4b) :: ext(7) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: val + logical(lgt) :: opt_ + + if(.not. present(opt)) then + opt_ = .false. + else + opt_ = opt + end if + call h5eset_auto_f(0, hdferr) + call h5oget_info_by_name_f(file%filehandle, setname, object_info, hdferr) + if (hdferr /= 0) then + if(.not. opt_) then + write(*,*) 'Warning: HDF field does not exist in '//trim(file%filename)//' = ', trim(setname) + else + return + end if + end if + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_1d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:), allocatable, intent(out) :: val + integer(i4b) :: n(1) + integer(hsize_t) :: s(1) + integer(i4b) :: ext(1) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + ! reads a 1-d array of string into an unallocated buffer + ! this now actually works so if you need to read a n-d array of strings + ! you could use this as a starting point + + subroutine read_alloc_hdf_1d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:), allocatable, target, intent(out) :: val + integer(i4b) :: n(1), i, j, length + integer(hsize_t), dimension(1:1) :: dims, maxdims + integer(i4b) :: ext(1) + type(c_ptr) :: f_ptr + integer(hid_t) :: space, memtype, filetype + integer(size_t), parameter :: sdim = 8 + integer(size_t) :: datasize + TYPE(C_PTR), DIMENSION(:), ALLOCATABLE, TARGET :: rdata ! Read buffer + + character(len=8, kind=c_char), pointer :: readable_data + + if(allocated(val)) deallocate(val) + + call open_hdf_set(file, setname) + + call h5dget_type_f(file%sethandle, filetype, file%status) + + call h5dget_space_f(file%sethandle, space, file%status) + call h5sget_simple_extent_dims_f(space, dims, maxdims, file%status) + + allocate(rdata(dims(1))) + + call H5Tget_size_f(filetype, datasize, file%status) + + f_ptr = C_LOC(rdata(1)) + + call h5dread_f(file%sethandle, filetype, f_ptr, file%status)!, space) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + + allocate(val(dims(1))) + + ! convert each c string to a fortran string + do i=1, dims(1) + call c_f_pointer(rdata(i), readable_data) + length = 0 + do + ! determine lengths by looking for c end of string character + if(readable_data(length+1:length+1) == C_NULL_CHAR .or. length >= sdim) exit + length = length +1 + end do + val(i) = readable_data(1:length) + end do + + deallocate(rdata) + + end subroutine + + subroutine read_alloc_hdf_2d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_2d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:), allocatable, intent(out) :: val + integer(i4b) :: n(2) + integer(hsize_t) :: s(2) + integer(i4b) :: ext(2) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_3d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(3) + integer(hsize_t) :: s(3) + integer(i4b) :: ext(3) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_4d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(4) + integer(hsize_t) :: s(4) + integer(i4b) :: ext(4) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_5d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(5) + integer(hsize_t) :: s(5) + integer(i4b) :: ext(5) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_6d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(6) + integer(hsize_t) :: s(6) + integer(i4b) :: ext(6) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_dp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(dp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_sp(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + real(sp) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_int(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + subroutine read_alloc_hdf_7d_char(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*) ,dimension(:,:,:,:,:,:,:), allocatable, intent(out) :: val + integer(i4b) :: n(7) + integer(hsize_t) :: s(7) + integer(i4b) :: ext(7) + if(allocated(val)) deallocate(val) + call get_size_hdf(file, setname, n) + allocate(val(n(1),n(2),n(3),n(4),n(5),n(6),n(7))) + call open_hdf_set(file, setname) + s = int(shape(val)) + ! Validate that sizes are consistent + call get_size_hdf(file, setname, ext) + if (any(ext /= s)) then + write(*,*) 'HDF error -- inconsistent array sizes' + write(*,*) ' Filename = ', trim(file%filename) + write(*,*) ' Setname = ', trim(setname) + write(*,*) ' HDF size = ', ext + write(*,*) ' Requested size = ', int(s,i4b) + !write(*,*) opt_, 'Optional parameter' + end if + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, val, s, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname) + end subroutine + + + subroutine read_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, allocatable, dimension(:), target, intent(out) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, dtype, file%status) + call h5tget_size_f(dtype, len, file%status) + numint = len + allocate(val(numint)) + f_ptr = c_loc(val) + call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + call h5tclose_f(dtype, file%status) + end subroutine read_hdf_opaque + + + subroutine write_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, dimension(:), target, intent(in) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + !call open_hdf_set(file, setname) + !call h5dget_type_f(file%sethandle, dtype, file%status) + !call h5tget_size_f(dtype, len, file%status) + !numint = len + !allocate(val(numint)) + !f_ptr = c_loc(val) + !call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + !call h5tclose_f(dtype, file%status) + end subroutine write_hdf_opaque + + subroutine read_hdf_vlen(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + type(byte_pointer), dimension(:), intent(inout) :: val + + INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles + INTEGER :: hdferr + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims + INTEGER :: i, j + integer, dimension(:), pointer :: ptr_r + + ! vl data + TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures + TYPE(C_PTR) :: f_ptr + !type(byte_pointer), allocatable, dimension(:) :: r_ptr + byte, pointer, dimension(:) :: r_ptr + + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, filetype, hdferr) + CALL h5dget_space_f(file%sethandle, space, hdferr) + + CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + allocate(rdata(dims(1))) + + CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) + ! Get address of the C pointer corresponding + ! to the first element of our data + f_ptr = C_LOC(rdata(1)) + CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) + ! + ! Write the variable-length data to the fortran array + ! + allocate(r_ptr(dims(1))) + DO i = 1, dims(1) + !WRITE(*,'(A,"(",I0,"):",/,"{")', ADVANCE="no") setname,i + !CALL c_f_pointer(rdata(i)%p, r_ptr(i)%p, [rdata(i)%len] ) + CALL c_f_pointer(rdata(i)%p, r_ptr, [rdata(i)%len] ) + !allocate(val(i)%p(size(r_ptr(i)%p))) + allocate(val(i)%p(size(r_ptr))) + !val(i)%p(:) = r_ptr(i)%p(:) + val(i)%p(:) = r_ptr + + !DO j = 1, rdata(i)%len + ! WRITE(*,'(1X,I0)', ADVANCE='no') val(i)%p(j) + ! IF ( j .LT. rdata(i)%len) WRITE(*,'(",")', ADVANCE='no') + !ENDDO + !WRITE(*,'( " }")') + + ENDDO + ! + ! Close and release resources. Note the use of H5Dvlen_reclaim + ! removes the need to manually deallocate the previously allocated + ! data. + ! + ! Not clear if this line is good or not. It could be de-allocating the read + ! memory that we are now pointing to, but I am not sure + CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) + CALL h5dclose_f(dset , hdferr) + CALL h5sclose_f(space, hdferr) + CALL h5tclose_f(filetype, hdferr) + call close_hdf_set(file) + CALL h5tclose_f(memtype, hdferr) + !deallocate(r_ptr, rdata) + deallocate(rdata) + ! deallocate(rdata) + + end subroutine read_hdf_vlen + + subroutine get_hdf_vlen_ext(file, setname, ext) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), dimension(:), intent(out) :: ext + + INTEGER(HID_T) :: filetype, memtype, space, dset ! Handles + INTEGER :: hdferr + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims, dims + INTEGER :: i, j + integer, dimension(:), pointer :: ptr_r + + ! vl data + TYPE(hvl_t), dimension(:), allocatable, target :: rdata ! Pointer to vlen structures + TYPE(C_PTR) :: f_ptr + + call open_hdf_set(file, setname) + call h5dget_type_f(file%sethandle, filetype, hdferr) + CALL h5dget_space_f(file%sethandle, space, hdferr) + CALL h5sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + allocate(rdata(dims(1))) + CALL h5tvlen_create_f(H5T_STD_U8LE, memtype, hdferr) + f_ptr = C_LOC(rdata(1)) + CALL h5dread_f(file%sethandle, memtype, f_ptr, hdferr) + ext(:) = rdata(:)%len + + CALL h5dvlen_reclaim_f(memtype, space, H5P_DEFAULT_F, f_ptr, hdferr) + CALL h5dclose_f(dset , hdferr) + CALL h5sclose_f(space, hdferr) + CALL h5tclose_f(filetype, hdferr) + call close_hdf_set(file) + CALL h5tclose_f(memtype, hdferr) + deallocate(rdata) + + end subroutine get_hdf_vlen_ext + + subroutine read_hdf_string(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*), intent(out) :: val + + integer(i4b), parameter :: mlen=10000 + integer(hid_t) :: filetype, space + integer(size_t), dimension(1) :: len + integer(hsize_t), dimension(1:2) :: data_dims + integer :: hdferr + character(mlen), allocatable, dimension(:) :: rdata + + call open_hdf_set(file, setname) + CALL H5Dget_type_f(file%sethandle, filetype, hdferr) + CALL H5Dget_space_f(file%sethandle, space, hdferr) + ALLOCATE(rdata(1)) + len=mlen + data_dims = [mlen,1] + CALL h5dread_vl_f(file%sethandle, filetype, rdata, data_dims, len, hdferr, space) + val = rdata(1) + DEALLOCATE(rdata) + call close_hdf_set(file) + CALL h5sclose_f(space, hdferr) + CALL H5Tclose_f(filetype, hdferr) + + end subroutine read_hdf_string + + + subroutine read_hdf_string2(file, setname, val, n) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + character(len=*), intent(out) :: val + integer(i4b), intent(out) :: n + + integer(i4b), parameter :: mlen=100000 + integer(hid_t) :: filetype, space + INTEGER(SIZE_T) :: size + !integer(size_t), dimension(1) :: len + !integer(hsize_t), dimension(1:2) :: data_dims + INTEGER(HSIZE_T), DIMENSION(1:1) :: dims = (/mlen/) + INTEGER(HSIZE_T), DIMENSION(1:1) :: maxdims + integer :: hdferr + !character(len=mlen), dimension(1) :: rdata + character(len=mlen) :: rdata + + call open_hdf_set(file, setname) + CALL H5Dget_type_f(file%sethandle, filetype, hdferr) + CALL H5Tget_size_f(filetype, size, hdferr) + CALL H5Dget_space_f(file%sethandle, space, hdferr) + CALL H5Sget_simple_extent_dims_f(space, dims, maxdims, hdferr) + + call h5dread_f(file%sethandle, filetype, rdata, dims, hdferr, H5S_ALL_F, H5S_ALL_F, H5P_DEFAULT_F) + val = rdata(1:size) + n = int(size,i4b) + + call close_hdf_set(file) + CALL h5sclose_f(space, hdferr) + CALL H5Tclose_f(filetype, hdferr) + + end subroutine read_hdf_string2 + + ! ***************************************************** + ! Set write operations + ! ***************************************************** + + subroutine write_hdf_0d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) , intent(in) :: val + real(dp), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) , intent(in) :: val + real(sp), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) , intent(in) :: val + integer(i4b), allocatable :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_0d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) , intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_1d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:), intent(in) :: val + real(dp), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:), intent(in) :: val + real(sp), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:), intent(in) :: val + integer(i4b), allocatable ,dimension(:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_1d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_2d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_2d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_3d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_3d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_4d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_4d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_5d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_5d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_6d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_6d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + subroutine write_hdf_7d_dp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + real(dp), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F64LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_sp(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + real(sp), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_IEEE_F32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_int(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: i + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + integer(i4b), allocatable ,dimension(:,:,:,:,:,:,:) :: v + + allocate(ext_hdf(size(shape(val)))) + allocate(v, source=val) + ext_hdf = int(shape(val), hsize_t) + + call create_hdf_set(file, setname, shape(val), H5T_STD_I32LE) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, v, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf, v) + + end subroutine + + subroutine write_hdf_7d_char(file, setname, val) + + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: val + integer(hid_t) :: str_dtype + integer :: hdferr + + allocate(ext_hdf(size(shape(val)))) + ext_hdf = int(shape(val), hsize_t) + + call H5Tcopy_f(H5T_FORTRAN_S1, str_dtype, hdferr) + call H5Tset_size_f(str_dtype, int(len(val), size_t), hdferr) + + call create_hdf_set(file, setname, shape(val), str_dtype) + call h5dwrite_f(file%sethandle, str_dtype, val, ext_hdf, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot write data set") + deallocate(ext_hdf) + + end subroutine + + + ! ***************************************************** + ! Sliced set operations. + ! These are like read/write, but the dataset is + ! indexed with a slice. Note that the dataset must + ! exist beforehand. Use create_hdf_set for this. + ! ***************************************************** + + subroutine read_hdf_slice_0d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_0d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) , intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_1d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_2d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_3d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_4d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_5d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_6d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine read_hdf_slice_7d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(out) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dread_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_0d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) , intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(0) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_1d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(1) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_2d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(2) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_3d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(3) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_4d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(4) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_5d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(5) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_6d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(6) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_dp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(dp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_DOUBLE, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_sp(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + real(sp) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_REAL, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_int(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + integer(i4b) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_INTEGER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + subroutine write_hdf_slice_7d_char(file, setname, slice, arr) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), intent(in) :: slice(:,:) + character(len=*) ,dimension(:,:,:,:,:,:,:), intent(in) :: arr + integer(hid_t) :: dspace, mspace + integer(i4b), allocatable :: ext(:) + integer(hsize_t) :: hslice(3,size(slice,2)) + integer(hsize_t) :: s(7) + ! Set up data spaces for memory and disk + s = int(shape(arr)) + call h5screate_simple_f(size(shape(arr)), s, mspace, file%status) + call open_hdf_set(file, setname) + allocate(ext(get_rank_hdf(file, setname))) + call get_size_hdf(file, setname, ext) + call h5screate_simple_f(size(ext), int(ext,hsize_t), dspace, file%status) + ! Specify the slice + hslice = int(parse_hdf_slice(slice, ext),hsize_t) + call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, hslice(1,:), hslice(2,:), & + & file%status, stride=hslice(3,:)) + call h5dwrite_f(file%sethandle, H5T_NATIVE_CHARACTER, arr, s, & + & file%status, file_space_id=dspace, mem_space_id=mspace) + call h5sclose_f(dspace, file%status) + call h5sclose_f(mspace, file%status) + deallocate(ext) + end subroutine + + + ! ***************************************************** + ! Optional Reads + ! ***************************************************** + + + ! ***************************************************** + ! Dataset creation operation + ! ***************************************************** + subroutine create_hdf_set(file, setname, ext, type_id) + implicit none + + type(hdf_file) :: file + character(len=*), intent(in) :: setname + integer(i4b), dimension(:), intent(in) :: ext + integer(hid_t) :: type_id + integer(hid_t) :: space + integer(hsize_t), allocatable, dimension(:) :: ext_hdf + if (trim(file%setname) /= trim(setname)) call close_hdf_set(file) + !write(*,*) trim(file%setname), trim(setname) + file%setname = setname + allocate(ext_hdf(size(shape(ext)))) + ext_hdf = int(ext, hsize_t) + call h5screate_simple_f(size(ext), ext_hdf, space, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot create data space, "//trim(file%filename)//', '//trim(setname)) + !write(*,*) trim(file%setname), type_id, space, file%sethandle, file%status, ext + call h5dcreate_f(file%filehandle, file%setname, type_id, space, file%sethandle, file%status) + !write(*,*) ' HDF status = ', file%status + call h5eprint_f(file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot create data set "//trim(file%filename)//', '//trim(setname)) + call h5sclose_f(space, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot close data space") + deallocate(ext_hdf) + end subroutine create_hdf_set + + ! Group creation. Once created, they can be used by specifying "group/dset" instead + ! of just "dset". + subroutine create_hdf_group(file, group) + implicit none + type(hdf_file) :: file + character(len=*) :: group + integer(hid_t) :: gid + call h5gcreate_f(file%filehandle, group, gid, file%status) + call h5gclose_f(gid, file%status) + end subroutine + + ! ********************** + ! Helper functions + ! ********************** + + function slice_0d() result(res) + implicit none + integer(i4b) :: res(3,0) + res = 0 + end function + + function slice_1d(s0) result(res) + implicit none + integer(i4b), dimension(:) :: s0(:) + integer(i4b) :: res(3,1) + select case(size(s0)) + case(0); res(:,1) = [1,-1,1] + case(1); res(:,1) = [s0(1),s0(1),1] + case(2); res(:,1) = [s0(1),s0(2),1] + case(3:); res(:,1) = s0 + end select + end function + + function slice_2d(s0,s1) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1 + integer(i4b) :: res(3,2) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + end function + + function slice_3d(s0,s1,s2) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2 + integer(i4b) :: res(3,3) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + end function + + function slice_4d(s0,s1,s2,s3) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3 + integer(i4b) :: res(3,4) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + end function + + function slice_5d(s0,s1,s2,s3,s4) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4 + integer(i4b) :: res(3,5) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + end function + + function slice_6d(s0,s1,s2,s3,s4,s5) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5 + integer(i4b) :: res(3,6) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + res(:,6:6) = slice_1d(s5) + end function + + function slice_7d(s0,s1,s2,s3,s4,s5,s6) result(res) + implicit none + integer(i4b), dimension(:) :: s0,s1,s2,s3,s4,s5,s6 + integer(i4b) :: res(3,7) + res(:,1:1) = slice_1d(s0) + res(:,2:2) = slice_1d(s1) + res(:,3:3) = slice_1d(s2) + res(:,4:4) = slice_1d(s3) + res(:,5:5) = slice_1d(s4) + res(:,6:6) = slice_1d(s5) + res(:,7:7) = slice_1d(s6) + end function + + function parse_hdf_slice(slice, ext) result(hslice) + implicit none + integer(i4b), intent(in) :: slice(:,:), ext(:) + integer(i4b) :: hslice(3,size(slice,2)) + hslice = slice + ! Negative indices count from the end, with -1 being the last valid index + where(hslice([1,2],:) < 0) hslice([1,2],:) = hslice([1,2],:) + spread(ext,1,2) + 1 + ! We need to translate "to" into "count" + hslice(2,:) = (hslice(2,:)-hslice(1,:)+hslice(3,:))/hslice(3,:) + ! 0 based + hslice(1,:) = hslice(1,:) - 1 + end function + +end module comm_hdf_mod + diff --git a/commander3/src/comm_hdf_mod.f90.in b/commander3/src/comm_hdf_mod.f90.in index 970461013..97f877604 100644 --- a/commander3/src/comm_hdf_mod.f90.in +++ b/commander3/src/comm_hdf_mod.f90.in @@ -213,6 +213,10 @@ contains allocate(ext_hdf(rank), mext_hdf(rank)) call h5sget_simple_extent_dims_f(space, ext_hdf, mext_hdf, file%status) call h5sclose_f(space, file%status) + if (file%status == -1) then + write(*,*) 'Error reading file ', trim(file%filename), trim(setname) + stop + end if n = min(size(ext),rank) ext(:n) = int(ext_hdf(:n),i4b) deallocate(ext_hdf, mext_hdf) @@ -390,7 +394,6 @@ contains type(hdf_file) :: file character(len=*), intent(in) :: setname byte, allocatable, dimension(:), target, intent(out) :: val - !byte, dimension(:), pointer, intent(out) :: val integer(hid_t) :: dtype integer(size_t) :: len, numint @@ -405,6 +408,25 @@ contains call h5tclose_f(dtype, file%status) end subroutine read_hdf_opaque + subroutine write_hdf_opaque(file, setname, val) + implicit none + type(hdf_file) :: file + character(len=*), intent(in) :: setname + byte, dimension(:), target, intent(in) :: val + + integer(hid_t) :: dtype + integer(size_t) :: len, numint + type(c_ptr) :: f_ptr + !call open_hdf_set(file, setname) + !call h5dget_type_f(file%sethandle, dtype, file%status) + !call h5tget_size_f(dtype, len, file%status) + !numint = len + !allocate(val(numint)) + !f_ptr = c_loc(val) + !call h5dread_f(file%sethandle, dtype, f_ptr, file%status) + !call h5tclose_f(dtype, file%status) + end subroutine write_hdf_opaque + subroutine read_hdf_vlen(file, setname, val) implicit none type(hdf_file) :: file diff --git a/commander3/todscripts/hfi/hfitohdf5_pointing.py b/commander3/todscripts/hfi/hfitohdf5_pointing.py new file mode 100644 index 000000000..e30f079cd --- /dev/null +++ b/commander3/todscripts/hfi/hfitohdf5_pointing.py @@ -0,0 +1,487 @@ +#================================================================================ +# +# Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +# +# This file is part of Commander3. +# +# Commander3 is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Commander3 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Commander3. If not, see . +# +#================================================================================ + +from commander_tools.tod_tools.hfi import hfi +from commander_tools.tod_tools import commander_tod as tod +import argparse +import multiprocessing as mp +import os +import numpy as np +import math +from astropy.io import fits +import healpy as hp +import sys +import random +import h5py +import sqlite3 +import traceback +import cProfile +import glob +from scipy.spatial.transform import Rotation as rot +import pickle +import codecs + +import matplotlib.pyplot as plt + +def main(): + + parser = argparse.ArgumentParser() + + parser.add_argument('--planck_dir', type=str, action='store', help='path to the legacy planck data in hdf format', default='/mn/stornext/d16/cmbco/bp/HFI/hfi_miss03_adc') + + parser.add_argument('--gains-dir', type=str, action='store', help='path to a directory with the initial gain estimates', default='/mn/stornext/d16/cmbco/bp/HFI/aux/gains') + + parser.add_argument('--rimo', type=str, action='store', help='path to on disk rimo file', default='/mn/stornext/d16/cmbco/bp/HFI/aux/RIMO_npipe2.fits') + + parser.add_argument('--pid-database', type=str, action='store', help='path to the sql database storing the PID info', default='/mn/stornext/d16/cmbco/bp/HFI/aux/hfi_raw_rings_v3.db') + + parser.add_argument('--extra-flags', type=str, action='store', help='path to extra flagging in txt file', default='/mn/stornext/d16/cmbco/bp/HFI/aux/hfi_bad_intervals_15s_elephants.txt') + + #https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/preproc_modules/transf1_nodemod.py + parser.add_argument('--calib-params', type=str, action='store', help='hash dump of HFI housekeeping imo from npipe', default='/mn/stornext/d16/cmbco/bp/HFI/aux/hficalibparams.dat') + + parser.add_argument('--out-dir', type=str, action='store', default='/mn/stornext/d5/data/artemba/HFI_data_pointing_DPC/143', help='path to output data structure you want to generate') + + parser.add_argument('--num-procs', type=int, action='store', default=1, help='number of processes to use') + + parser.add_argument('--freqs', type=int, nargs='+', default=[545], help='which hfi frequencies to operate on') + + parser.add_argument('--ods', type=int, nargs=2, default=[91, 975], help='the operational days to operate on') # [92,93] - test ODs; [91, 975] - full + + parser.add_argument('--no-compress', action='store_true', default=False, help='Produce uncompressed data output') + + parser.add_argument('--restart', action='store_true', default=False, help="restart from a previous run that didn't finish") + + parser.add_argument('--produce-filelist', action='store_true', default=True, help='force the production of a filelist even if only some files are present') + + parser.add_argument('--pointing_dir', type=str, action='store', default='/mn/stornext/d5/data/artemba/HFI_pointing/143') + # 545: '/mn/stornext/u3/hke/data_d5/HFI/pointing/545' + # 143: '/mn/stornext/d5/data/artemba/HFI_pointing/143' + + in_args = parser.parse_args() + + in_args.version = 1 + + random.seed() + + os.environ['OMP_NUM_THREADS'] = '1' + + pool = mp.Pool(processes=in_args.num_procs) + manager = mp.Manager() + + ods = range(in_args.ods[0], in_args.ods[1], 1) + + manager = mp.Manager() + dicts = {} + for freq in hfi.freqs: + dicts[freq] = manager.dict() + + comm_tod = tod.commander_tod(in_args.out_dir, 'HFI', in_args.version, dicts, not in_args.restart) + + x = [[pool.apply_async(make_od, args=[comm_tod, freq, od, in_args]) for freq in in_args.freqs] for od in ods] + + for res1 in np.array(x): + for res in res1: + res.get() + + pool.close() + pool.join() + + if ((in_args.ods[0] == 91 and in_args.ods[1] == 975) or in_args.produce_filelist) : + comm_tod.make_filelists() + #write file lists + +def make_od(comm_tod, freq, od, args): + + try: + + #load housekeeping imo from file + calibfile = open(args.calib_params, mode='r') + calibparams = calibfile.read() + calibfile.close() + calibparams = bytes(calibparams, encoding='utf-8') + hsk = pickle.loads(codecs.decode(bytes(calibparams), 'base64'), fix_imports=True, encoding='bytes') + + nside = hfi.nsides[freq] + + comm_tod.init_file(freq, od, mode='w') + + if(args.restart and comm_tod.exists): + comm_tod.finalize_file() + print('Skipping existing file ' + comm_tod.outName) + return + + rimo = fits.open(args.rimo) + + #make common group for things we only read once + #polang, mbeamang, nside, fsamp + prefix = '/common' + rimo_i = np.where(rimo[1].data.field('detector').flatten() == str(freq) + '-' + hfi.dets[freq][0])[0] + + #sampling frequency + fsamp = rimo[1].data.field('f_samp')[rimo_i] + comm_tod.add_field(prefix + '/fsamp', fsamp) + + #nside + comm_tod.add_field(prefix + '/nside', [nside]) + + detNames = '' + polangs = [] + mainbeamangs = [] + for det in hfi.dets[freq]: + rimo_i = np.where(rimo[1].data.field('detector').flatten() == str(freq) + '-' + det)[0] + detNames += str(freq) + '-' + det + ', ' + if len(rimo_i) == 1: rimo_i = rimo_i[0] + polangs.append(math.radians(rimo[1].data.field('psi_pol')[rimo_i])) + mainbeamangs.append(math.radians(rimo[1].data.field('psi_uv')[rimo_i])) + + compArr=[hfi.huffman] + if args.no_compress: + compArr = None + + #make detector names lookup + comm_tod.add_field(prefix + '/det', np.string_(detNames[0:-2])) + + #make polarization angle + comm_tod.add_field(prefix + '/polang', polangs) + comm_tod.add_attribute(prefix + '/polang', 'index', detNames[0:-2]) + + #make main beam angle + comm_tod.add_field(prefix + '/mbang', mainbeamangs) + comm_tod.add_attribute(prefix + '/mbang', 'index', detNames[0:-2]) + + dataFileName = glob.glob(os.path.join(args.planck_dir, str(od).zfill(4), 'H' + str(freq) + '_' + str(od).zfill(4) + '_R_201505??.fits'))[0] + + try: + exFile = fits.open(dataFileName) + except (OSError): + print("Failed to open file " + dataFileName) + return + + try: + pointingFile = fits.open(os.path.join(args.planck_dir, str(od).zfill(4), 'pointing-' + str(od).zfill(4) + '.fits')) + except (OSError): + print("Failed to open file " + os.path.join(args.planck_dir, str(od).zfill(4), 'pointing-' + str(od).zfill(4) + '.fits')) + return + + try: + extraFlagsFile = h5py.File(os.path.join(args.planck_dir, str(od).zfill(4), 'extra_flags_' + str(od).zfill(4) + '.h5'), 'r') + except (OSError): + print("Failed to open file " + os.path.join(args.planck_dir, str(od).zfill(4), 'extra_flags_' + str(od).zfill(4) + '.h5')) + return + + + dpc_times = np.array([]) + angle_dict = dict() + for ods in range(od-1, od+2): + + if ods == 90 or ods == 976: + continue + + try: + DPC_pointing_file = fits.open(os.path.join(args.pointing_dir, 'HFI_TOI_' + str(freq) + '-PTG_R2.01_OD'+ str(ods).zfill(4) + '.fits')) + except (OSError): + print("Failed to open file " + os.path.join(args.pointing_dir, 'HFI_TOI_' + str(freq) + '-PTG_R2.01_OD'+ str(ods).zfill(4) + '.fits')) + return + + dpc_times = np.concatenate([dpc_times, DPC_pointing_file[1].data['OBT']/2.**16]) + + try: + for i, det in enumerate(hfi.dets[freq]): + if det in angle_dict.keys(): + angle_dict[det]['phi'] = np.concatenate([angle_dict[det]['phi'], DPC_pointing_file[i+2].data['PHI']]) + angle_dict[det]['theta'] = np.concatenate([angle_dict[det]['theta'], DPC_pointing_file[i+2].data['THETA']]) + angle_dict[det]['psi'] = np.concatenate([angle_dict[det]['psi'], DPC_pointing_file[i+2].data['PSI']]) + else: + angle_dict[det] = dict() + angle_dict[det]['phi'] = DPC_pointing_file[i+2].data['PHI'] + angle_dict[det]['theta'] = DPC_pointing_file[i+2].data['THETA'] + angle_dict[det]['psi'] = DPC_pointing_file[i+2].data['PSI'] + except: + print("failed to allocate array at od", od) + print("od:", od) + return + + + DPC_pointing_file.close() + + + def closest_argmin(A, B): + # fucntion to find the closest time value between the two arrays + L = B.size + sidx_B = B.argsort() + sorted_B = B[sidx_B] + sorted_idx = np.searchsorted(sorted_B, A) + sorted_idx[sorted_idx==L] = L-1 + mask = (sorted_idx > 0) & \ + ((np.abs(A - sorted_B[sorted_idx-1]) < np.abs(A - sorted_B[sorted_idx])) ) + return sidx_B[sorted_idx-mask] + + + + #open database with pid info in it + conn = sqlite3.connect(args.pid_database) + c = conn.cursor() + + starttime = pointingFile[1].data['obt'][0]/1e9 + endtime = pointingFile[1].data['obt'][-1]/1e9 + + #per pid + for dbentry in c.execute("SELECT * FROM ring_times_hfi WHERE stop_time >= '{0}' AND start_time < '{1}'".format(starttime, endtime)): + pid = dbentry[0] + + #if pid != 10666: continue + + start_time = dbentry[2] + end_time = dbentry[3] + + startIndex = np.where(exFile[1].data['obt']/1e9 > start_time) + endIndex = np.where(exFile[1].data['obt']/1e9 > end_time) + if len(startIndex[0]) > 0: + pid_start = startIndex[0][0] + else:#catch days with no pids + continue + if len(endIndex[0]) != 0: + pid_end = endIndex[0][0] + else:#catch final pid per od + pid_end = len(exFile[1].data['obt']) + if pid_start == pid_end:#catch chunks with no data like od 1007 + continue + + pid_times = exFile[1].data['obt'][pid_start:pid_end]/1e9 + + # find inicies corresponding to the same time staps in DPC files + indices_dpc = closest_argmin(pid_times, dpc_times) + + # fix shift by 3 samples + indices_dpc -= 3 + + + #if pid == 10666: + # print(max(pid_times - dpc_times[indices_dpc])) + # print(pid_times - dpc_times[indices_dpc]) + + prefix = str(pid).zfill(6) + '/common' + + #time field + comm_tod.add_field(prefix + '/time', [exFile[1].data['obt'][pid_start]/1.e+9]) + comm_tod.add_attribute(prefix + '/time','index','OBT in s') + + #length of the tod + comm_tod.add_field(prefix + '/ntod', [pid_end - pid_start]) + + #velocity field + #rotate from ecliptic to galactic + #might be required, I'm not sure what coordinate system these are in + r = hp.Rotator(coord=['E', 'G']) + comm_tod.add_field(prefix + '/vsun', r([pointingFile[4].data['x_vel'][pid_start], pointingFile[4].data['y_vel'][pid_start], pointingFile[4].data['z_vel'][pid_start]])) + + #add some metadata so someone might be able to figure out what is going on + comm_tod.add_attribute(prefix + '/vsun','index', '[x, y, z]') + comm_tod.add_attribute(prefix + '/vsun','coords','galactic') + + #satelite position + comm_tod.add_field(prefix + '/satpos', [pointingFile[5].data['x_pos'][pid_start], pointingFile[5].data['y_pos'][pid_start], pointingFile[5].data['z_pos'][pid_start]]) + #add metadata + comm_tod.add_attribute(prefix + '/satpos','index','X, Y, Z') + comm_tod.add_attribute(prefix + '/satpos','coords','heliocentric') + comm_tod.add_attribute(prefix + '/satpos', 'units', 'AU') + ''' + #read boresight pointing for this chunk + quat_x = pointingFile[3].data['quaternion_x'][pid_start:pid_end] + quat_y = pointingFile[3].data['quaternion_y'][pid_start:pid_end] + quat_z = pointingFile[3].data['quaternion_z'][pid_start:pid_end] + quat_s = pointingFile[3].data['quaternion_s'][pid_start:pid_end] + + quat_arr = np.array([quat_x, quat_y, quat_z, quat_s]).transpose() + + r_boresight = rot.from_quat(quat_arr) + ''' + extra_flags = extraFlagsFile[str(pid).zfill(6) + '/flag_extra'][()] + + + #per detector fields + for det in hfi.dets[freq]: + prefix = str(pid).zfill(6) + '/' + str(freq) + '-' + det + + #get RIMO index + #print(rimo[1].data.field('detector').flatten().shape, rimo[1].data.field('detector').flatten(), 'LFI' +str(horn) + hornType) + rimo_i = np.where(rimo[1].data.field('detector').flatten() == str(freq) + '-' + det)[0] + data_i = exFile.index_of(str(freq) + '-' + det) + + #make flag data + flagArray = exFile[data_i].data.field('flag')[pid_start:pid_end] + + # naughty od list (all pointing is 0) + if od in [157, 266, 267, 366, 367, 368]: + flagArray = np.ones(len(flagArray)) + + #add extra flagging from txt files + ex_flags = extra_flags + if(det == '353-1'): + ex_flags = extraFlagsFile[str(pid).zfill(6) + '/flags_extra_353-1'] + flagArray += ex_flags + + + #with np.printoptions(threshold=np.inf): + # print(flagArray) + + if (len(flagArray) > 0): + comm_tod.add_field(prefix + '/flag', flagArray, compArr) + + + #make pixel number + + #create detector pointing offset quaternion + # Follows this npipe function: + # https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/utilities.py#L1503-L1575 + ''' + phi = math.radians(rimo[1].data.field('phi_uv')[rimo_i]) + theta = math.radians(rimo[1].data.field('theta_uv')[rimo_i]) + psi = math.radians(rimo[1].data.field('psi_uv')[rimo_i] + rimo[1].data.field('psi_pol')[rimo_i]) - phi + + det_s = np.cos(0.5 * theta) * np.cos(0.5 * (phi + psi)) + # vector part + det_x = -np.sin(0.5 * theta) * np.sin(0.5 * (phi - psi)) + det_y = np.sin(0.5 * theta) * np.cos(0.5 * (phi - psi)) + det_z = np.cos(0.5 * theta) * np.sin(0.5 * (phi + psi)) + + #convert from boresight pointing to per detector pointing + r_det = rot.from_quat([det_x, det_y, det_z, det_s]) + + r_total = r_boresight * r_det + + #convert to theta, phi, psi + angs = r_total.as_euler('ZYZ') # could also be 'ZXZ' if we are supposed to be using intrinsic rotations instead of extrinsic + # idk what the difference is + + phi_array = angs[:,0] + theta_array = angs[:,1] + psi_array = angs[:,2] + + r = hp.rotator.Rotator(coord=['E', 'G'], deg=False) + + galTheta, galPhi = r(theta_array, phi_array) + pixels = hp.pixelfunc.ang2pix(nside, galTheta, galPhi) + + print('Old pointing:') + print(galPhi) + print(galTheta) + print(pixels) + print() + ''' + + galPhi = angle_dict[det]['phi'][indices_dpc] + galTheta = angle_dict[det]['theta'][indices_dpc] + psi_array = angle_dict[det]['psi'][indices_dpc] + try: + pixels = hp.pixelfunc.ang2pix(nside, galTheta, galPhi) + except: + print('Theta:', galTheta, min(galTheta), max(galTheta)) + print('Phi:', galPhi, min(galPhi), max(galPhi)) + + #print(galPhi) + #print(galTheta) + + + if len(pixels > 0): + #compute average outer product + try: + outAng = hfi.ring_outer_product(galTheta, galPhi) + except: + print('Outer product error:', galTheta, min(galTheta), max(galTheta)) + print('od, pid', od, pid) + comm_tod.add_field(prefix + '/outP', data=outAng) + if(args.no_compress): + comm_tod.add_field(prefix+'/theta', data=galTheta) + comm_tod.add_field(prefix+'/phi', data=galPhi) + comm_tod.add_field(prefix + '/pix', pixels, compArr) + + + #make pol angle + if(len(psi_array) > 0): + psi_array = np.where(psi_array < 0, 2*np.pi + psi_array, psi_array) + psi_array = np.where(psi_array >= 2*np.pi, psi_array - 2*np.pi, psi_array) + compArray = None + if not args.no_compress: + compArray = [hfi.psiDigitize, hfi.huffman] + comm_tod.add_field(prefix + '/psi', psi_array, compArray) + + #scalars + + #make gain + + #TODO: figure this shit out + # yikes the gain is complicated as hell + # There is more information needed here from the housekeeping data + # From Reijo: + # To convert DSP-valued HFI data into K_CMB, you also need to calibrate twice. First from DSP into pseudo-Volts. Then from Volts to K_CMB. + + # The first step is performed in this operator: https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/preproc_modules/transf1_nodemod.py The second step involves multiplying the data with the factors in the gain files you mention. After these, there will be small time-dependent fluctuations coming from residual ADC nonlinearity and (possibly) from real gain fluctuations. + + # Aside from calibration, you will need to demodulate out the square wave modulation between the two calibration steps and correct for bolometric nonlinearity. Please see this part of the preprocessing operator: https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/preproc.py#L921-L939. + + gainFile = fits.open(os.path.join(args.gains_dir, 'npipe5_gains_' + str(freq) + '.fits')) + gain = gainFile[gainFile.index_of(str(freq) +'-' + det)].data[0][0] + + gain1, offset = hfi.compute_l1_gain(str(freq) + '-' + det, exFile[1].data['obt'][pid_start:pid_end], hsk) + + + #print(gain, gain1, offset, gain/gain1) + + gain = gain/gain1[0] + + #make white noise + sigma0 = rimo[1].data.field('net')[rimo_i][0] * math.sqrt(fsamp[0]) + + #make f_knee + #fknee = rimo[1].data.field('f_knee')[rimo_i][0] + fknee = 0.5 + + #make 1/f noise exponent + #alpha = rimo[1].data.field('alpha')[rimo_i][0] + alpha = -1 + + #print(gain, sigma0, fknee, alpha) + comm_tod.add_field(prefix + '/scalars', np.array([gain, sigma0, fknee, alpha]).flatten()) + comm_tod.add_attribute(prefix + '/scalars','index','gain, sigma0, fknee, alpha') + + #make psd noise + + #make tod data + tod = exFile[exFile.index_of(str(freq)+'-' + det)].data.field('signal')[pid_start:pid_end] #- offset + + #compArray = [hfi.todDtype, hfi.rice] + compArray = [hfi.todDtype, hfi.huffTod] + if(args.no_compress): + compArray = [hfi.todDtype] + comm_tod.add_field(prefix + '/tod', tod, compArray) + + print(freq, od, pid) + comm_tod.finalize_chunk(pid, loadBalance=outAng) + comm_tod.finalize_file() + except: + exc_type, exc_val, exc_tb = sys.exc_info() + raise Exception("".join(traceback.format_exception(exc_type, exc_val, exc_tb))) + + +if __name__ == '__main__': + main() From 633a61eb9dab0bb6d256bbf640d04cf5d8ce9414 Mon Sep 17 00:00:00 2001 From: Artem Basyrov Date: Tue, 12 Nov 2024 12:42:10 +0100 Subject: [PATCH 052/171] pointing script --- cmake/libraries.cmake | 6 ------ commander3/python/commander_tools/tod_tools/hfi.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cmake/libraries.cmake b/cmake/libraries.cmake index ecf269533..7f26866c1 100644 --- a/cmake/libraries.cmake +++ b/cmake/libraries.cmake @@ -91,12 +91,6 @@ message(STATUS "OPENMP Fortran LIBRARIES are: ${OpenMP_Fortran_LIBRARIES}") #------------------------------------------------------------------------------ add_custom_target(tempita ALL "") set(comm_hdf_mod "${COMMANDER3_SOURCE_DIR}/comm_hdf_mod.f90") -# running python command at configure time -execute_process( - COMMAND ${TEMPITA_DIR}/tempita_proc.py < $< > $@ - INPUT_FILE ${comm_hdf_mod}.in - OUTPUT_FILE ${comm_hdf_mod} - ) #------------------------------------------------------------------------------ # Creating a Unified target #------------------------------------------------------------------------------ diff --git a/commander3/python/commander_tools/tod_tools/hfi.py b/commander3/python/commander_tools/tod_tools/hfi.py index 96b31ac7b..f992356f0 100644 --- a/commander3/python/commander_tools/tod_tools/hfi.py +++ b/commander3/python/commander_tools/tod_tools/hfi.py @@ -32,7 +32,7 @@ class hfi(object): dets = {100:['1a', '1b', '2a', '2b', '3a', '3b', '4a', '4b'], 143:['1a', '1b', '2a', '2b', '3a', '3b', '4a', '4b', '5', '6', '7'], 217:['1', '2', '3', '4', '5a', '5b', '6a', '6b', '7a', '7b', '8a', '8b'], 353:['1', '2', '3a', '3b', '4a', '4b', '5a', '5b', '6a', '6b', '7', '8'], 545:['1', '2', '4'], 857:['1', '2', '3', '4']} npsi = 4096 ntodsigma = 100 - nsides = {100:1024, 143:1024, 217:1024, 353:1024, 545:2048, 857:2048} + nsides = {100:1024, 143:2048, 217:1024, 353:1024, 545:2048, 857:2048} #compression arrays huffman = ['huffman', {'dictNum':1}] huffTod = ['huffman', {'dictNum':2}] From f2c991a2030e2732769e6b07456acac2e869ee43 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 17 Nov 2024 15:55:24 +0100 Subject: [PATCH 053/171] Updating the write script --- commander3/src/comm_tod_dirbe_mod.f90 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 7beaf8f3a..ddb607b11 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -422,19 +422,21 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call open_hdf_file(trim(chaindir)//'/res_'//trim(self%label(1))//scantext//'.h5', tod_file, 'w') call write_hdf(tod_file, '/tod', sd%tod) call write_hdf(tod_file, '/pix', sd%pix(:,:,1)) + call write_hdf(tod_file, '/pix_sol', self%scans(i)%d(1)%pix_sol) call write_hdf(tod_file, '/todz', d_calib(1, :, :)) call write_hdf(tod_file, '/s_sky', sd%s_sky) - call write_hdf(tod_file, '/n_corr', sd%n_corr) - call write_hdf(tod_file, '/s_sl', sd%s_sl) - call write_hdf(tod_file, '/s_orb', sd%s_orb) + !call write_hdf(tod_file, '/n_corr', sd%n_corr) + !call write_hdf(tod_file, '/s_sl', sd%s_sl) + !call write_hdf(tod_file, '/s_orb', sd%s_orb) call write_hdf(tod_file, '/res', d_calib(2, :, :)) call write_hdf(tod_file, '/zodi', d_calib(7, :, :)) call write_hdf(tod_file, '/mask', sd%mask) + call write_hdf(tod_file, '/flag', sd%flag) call write_hdf(tod_file, '/sigma0', self%scans(i)%d(1)%N_psd%sigma0) - do k = 1, size(sd%s_zodi_therm, dim=2) - call int2string(k, scantext) - call write_hdf(tod_file , '/zodi'//scantext, d_calib(8 + k, :, :)) - end do + !do k = 1, size(sd%s_zodi_therm, dim=2) + ! call int2string(k, scantext) + ! call write_hdf(tod_file , '/zodi'//scantext, d_calib(8 + k, :, :)) + !end do call close_hdf_file(tod_file) end if end if From a181b10e7dde9616ae85c047162b4c5a519c71ec Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 18 Nov 2024 08:43:25 +0100 Subject: [PATCH 054/171] Updated write_tod scripts --- .../todscripts/dirbe/metin/dirbe_utils.py | 73 +++++++++++++++++++ .../dirbe/metin/write_tods_final.py | 41 +++++++++-- 2 files changed, 108 insertions(+), 6 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index 1423ae2c8..e73a21e99 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -18,6 +18,7 @@ get_body, HeliocentricMeanEcliptic, ) +from astroquery.mpc import MPC DIRBE_SKYMAP_INFO = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/DIRBE_SKYMAP_INFO.FITS" DIRBE_BANDPASSES = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/bandpass/DIRBE_SYSTEM_SPECTRAL_RESPONSE_TABLE.ASC" @@ -94,6 +95,32 @@ "neptune": 1, } +COMET_RADII = { + '73P/Schwassmann–Wachmann 3':2, + 'C/1989 Q1':2, + 'C/1989 T1':2, + 'C/1989 X1':15, + 'C/1990 K1':2 + } +ASTEROID_RADII = { + '1 Ceres':1, + '2 Pallas':1, + '4 Vesta':1, + '15 Eunomia':1, + '31 Euphrosyne':1, + '41 Daphne':1, + '42 Isis':1, + '85 Io':1, + '185 Eunike':1, + '194 Prokne':1, + '372 Palma':1, + '405 Thia':1, + '511 Davida':1, + '704 Interamnia':1, + '747 Winchester':1, + '1021 Flammario':1, + } + SIGMA_0 = { 1: 0.1820848274487808, 2: 0.1785923183102134, @@ -127,6 +154,52 @@ def get_planet_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: return interpolaters +def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: + times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( + datetime + ) + astropy_times = Time(times, format="datetime", scale="utc") + interpolaters_comet = {} + interpolaters_asteroids = {} + rotator = hp.Rotator(coord=["E", "G"]) + for c in COMET_RADII: + interpolaters_comet[c] = {} + lons = [] + lats = [] + dists = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(c, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + dist = eph['r'] + interpolaters_comet[c]['lon'] = interp1d(astropy_times_i.mjd, lon) + lons += lon.tolist() + lats += lat.tolist() + dists += dist.tolist() + lons = np.array(lons) + lats = np.array(lats) + dists = np.array(dists) + interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) + interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) + + for a in ASTEROID_RADII: + interpolaters_asteroids[a] = {} + lons = [] + lats = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(a, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + lons += lon.tolist() + lats += lat.tolist() + lons = np.array(lons) + latss = np.array(lats) + interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) + return interpolaters_comet, interpolaters_asteroids @cache def band_to_bit(band: int) -> int: diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index d61d2fadc..50161b40f 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -39,8 +39,7 @@ # zodi_model = zodipy.Zodipy(extrapolate=True) # Path objects -DIRBE_DATA_PATH = Path("/mn/stornext/d5/data/metins/dirbe/data/") -HDF5_PATH = Path("/mn/stornext/d16/cmbco/bp/gustavbe/master/dirbe_hdf5_files/") +DIRBE_DATA_PATH = Path("/mn/stornext/d5//data/duncanwa/DIRBE/hdf_files/") BANDPASS_PATH = Path("/mn/stornext/d5/data/metins/dirbe/data/") CIO_PATH = Path("/mn/stornext/d16/cmbco/ola/dirbe/cio") @@ -93,6 +92,11 @@ "space_craft_descending": 24, "leading_los": 25, "trailing_los": 26, + '73P/Schwassmann–Wachmann 3':27, + 'C/1989 Q1':28, + 'C/1989 T1':29, + 'C/1989 X1':30, + 'C/1990 K1':31, } @@ -143,12 +147,14 @@ def get_yday_data( files: range, nside_out: int, planet_time_delta: timedelta, color_corr: bool ) -> list[YdayData]: planet_interps = dirbe_utils.get_planet_interps(planet_time_delta) + comet_interps, asteroid_interps = dirbe_utils.get_smallbody_interps(planet_time_delta) with multiprocessing.Pool(processes=N_PROC) as pool: proc_chunks = [ pool.apply_async( get_yday_cio_data, - args=(file_number, nside_out, planet_interps, color_corr), + args=(file_number, nside_out, planet_interps, comet_interps, + asteroid_interps, color_corr), ) for file_number in files ] @@ -159,6 +165,8 @@ def get_yday_cio_data( file_number: int, nside_out: int, planet_interps: dict[str, dict[str, interp1d]], + comet_interps: dict[str, dict[str, interp1d]], + asteroid_interps: dict[str, dict[str, interp1d]], color_corr: bool, ) -> YdayData: """Function which extracts and reorders the CIO data from one day CIO file.""" @@ -292,9 +300,30 @@ def get_yday_cio_data( lonlat=True, ) - planet_indices = ang_dist <= np.deg2rad(radius) + if (body == 'moon') & ((band == 4) | (band == 5)): + r = 15 + else: + r = radius + planet_indices = ang_dist <= np.deg2rad(r) flag[planet_indices] += 2 ** FLAG_BITS[body] + + # Get planet flags + for body, radius in dirbe_utils.COMET_RADII.items(): + comet_lon = comet_interps[body]["lon"](time) + comet_lat = comet_interps[body]["lat"](time) + comet_dist = comet_interps[body]["lon"](time) + if comet_dist.min() < 2: + + ang_dist = hp.rotator.angdist( + np.array([lon, lat]), + np.array([comet_lon, comet_lat]), + lonlat=True, + ) + + comet_indices = ang_dist <= np.deg2rad(radius) + flag[comet_indices] += 2 ** FLAG_BITS[body] + # Find which flags correspond to the detector and get the inds of those flags xs_noise_inds = (xs_noise_flags & band_bit) > 0 flag[xs_noise_inds] += 2 ** FLAG_BITS["excess_noise"] @@ -508,11 +537,11 @@ def write_to_commander_tods( def main() -> None: time_delta = timedelta(hours=1) files = range(N_CIO_FILES) - nside_out = 256 + nside_out = 512 start_time = time.perf_counter() color_corr = True - version = 18 + version = 21 print(f"{'Writing DIRBE h5 files':=^50}") print(f"{version=}, {nside_out=}") From fbbc5841c1af0af027d7049e60d4abbfdad82ed5 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 19 Nov 2024 07:29:09 +0100 Subject: [PATCH 055/171] Fixed bug in DIRBE output script --- commander3/src/comm_tod_dirbe_mod.f90 | 2 +- .../dirbe/metin/write_tods_final.py | 60 ++++++++++--------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index ddb607b11..3f4aa8089 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -414,7 +414,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call compute_calibrated_data(self, i, sd, d_calib) ! For debugging: write TOD to hdf - if (.false.) then + if (.true.) then ! scan id appears to be the worst chi2 if (self%scanid(i) < 10000) then !print *, self%scanid(i) diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index 50161b40f..ecaf4b8f9 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -77,26 +77,26 @@ "saturn": 10, "uranus": 11, "neptune": 12, + '73P/Schwassmann–Wachmann 3':13, + 'C/1989 Q1':14, + 'C/1989 T1':15, + 'C/1989 X1':16, + 'C/1990 K1':17, # Orbit and attitude flag (each observation has either of each pair turned on) - "non_definitive_attitude": 13, - "definite_attitude": 14, - "course_attitude": 15, - "fine_attitude": 16, - "merged_attitude": 17, - "external_uax_attitude": 18, - "space_craft_slewing": 19, - "space_craft_not_slewing": 20, - "special_pointing": 21, - "normal_pointing": 22, - "space_craft_ascending": 23, - "space_craft_descending": 24, - "leading_los": 25, - "trailing_los": 26, - '73P/Schwassmann–Wachmann 3':27, - 'C/1989 Q1':28, - 'C/1989 T1':29, - 'C/1989 X1':30, - 'C/1990 K1':31, + "non_definitive_attitude": 18, + "definite_attitude": 19, + "course_attitude": 20, + "fine_attitude": 21, + "merged_attitude": 22, + "external_uax_attitude": 23, + "space_craft_slewing": 24, + "space_craft_not_slewing": 25, + "special_pointing": 26, + "normal_pointing": 27, + #"space_craft_ascending": 28, + #"space_craft_descending": 29, + #"leading_los": 25, + #"trailing_los": 26, } @@ -308,21 +308,25 @@ def get_yday_cio_data( flag[planet_indices] += 2 ** FLAG_BITS[body] - # Get planet flags + # Get comet flags for body, radius in dirbe_utils.COMET_RADII.items(): comet_lon = comet_interps[body]["lon"](time) comet_lat = comet_interps[body]["lat"](time) - comet_dist = comet_interps[body]["lon"](time) + comet_dist = comet_interps[body]["dist"](time) if comet_dist.min() < 2: + r = radius + else: + r = 1 + - ang_dist = hp.rotator.angdist( - np.array([lon, lat]), - np.array([comet_lon, comet_lat]), - lonlat=True, - ) + ang_dist = hp.rotator.angdist( + np.array([lon, lat]), + np.array([comet_lon, comet_lat]), + lonlat=True, + ) - comet_indices = ang_dist <= np.deg2rad(radius) - flag[comet_indices] += 2 ** FLAG_BITS[body] + comet_indices = ang_dist <= np.deg2rad(r) + flag[comet_indices] += 2 ** FLAG_BITS[body] # Find which flags correspond to the detector and get the inds of those flags xs_noise_inds = (xs_noise_flags & band_bit) > 0 From 51efb6a1e64e3a7974e8a8b1aa3acc871931f177 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 26 Nov 2024 04:17:31 +0100 Subject: [PATCH 056/171] testing the interpolation --- .../todscripts/dirbe/metin/dirbe_utils.py | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index e73a21e99..63be7181f 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -158,47 +158,49 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( datetime ) + astropy_times = Time(times, format="datetime", scale="utc") interpolaters_comet = {} interpolaters_asteroids = {} rotator = hp.Rotator(coord=["E", "G"]) - for c in COMET_RADII: - interpolaters_comet[c] = {} - lons = [] - lats = [] - dists = [] - for i in range(len(astropy_times)//1441+1): - astropy_times_i = astropy_times[i*1441:(i+1)*1441] - eph = MPC.get_ephemeris(c, start=astropy_times_i[0], - number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) - dist = eph['r'] - interpolaters_comet[c]['lon'] = interp1d(astropy_times_i.mjd, lon) - lons += lon.tolist() - lats += lat.tolist() - dists += dist.tolist() - lons = np.array(lons) - lats = np.array(lats) - dists = np.array(dists) - interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) - interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) - interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) - - for a in ASTEROID_RADII: - interpolaters_asteroids[a] = {} - lons = [] - lats = [] - for i in range(len(astropy_times)//1441+1): - astropy_times_i = astropy_times[i*1441:(i+1)*1441] - eph = MPC.get_ephemeris(a, start=astropy_times_i[0], - number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) - lons += lon.tolist() - lats += lat.tolist() - lons = np.array(lons) - latss = np.array(lats) - interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) - interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) + with solar_system_ephemeris.set('de432s'): + for c in COMET_RADII: + interpolaters_comet[c] = {} + lons = [] + lats = [] + dists = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(c, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + dist = eph['r'] + interpolaters_comet[c]['lon'] = interp1d(astropy_times_i.mjd, lon) + lons += lon.tolist() + lats += lat.tolist() + dists += dist.tolist() + lons = np.array(lons) + lats = np.array(lats) + dists = np.array(dists) + interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) + interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) + + for a in ASTEROID_RADII: + interpolaters_asteroids[a] = {} + lons = [] + lats = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(a, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + lons += lon.tolist() + lats += lat.tolist() + lons = np.array(lons) + latss = np.array(lats) + interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) return interpolaters_comet, interpolaters_asteroids @cache From a7e6697e295f9079d2dc68d47bc3064efeb4299c Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 26 Nov 2024 13:30:37 +0100 Subject: [PATCH 057/171] Fixing issue with rotations --- commander3/todscripts/dirbe/metin/dirbe_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index 63be7181f..76d8c2976 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -95,6 +95,9 @@ "neptune": 1, } +# Note that Ceres, Pallas, and Vesta were flagged in the original analysis, all +# other asteroids were discovered later on. All comets except C/1989 T1 were +# discovered by Lisse COMET_RADII = { '73P/Schwassmann–Wachmann 3':2, 'C/1989 Q1':2, @@ -162,7 +165,7 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d astropy_times = Time(times, format="datetime", scale="utc") interpolaters_comet = {} interpolaters_asteroids = {} - rotator = hp.Rotator(coord=["E", "G"]) + rotator = hp.Rotator(coord=["C", "G"]) with solar_system_ephemeris.set('de432s'): for c in COMET_RADII: interpolaters_comet[c] = {} @@ -175,7 +178,6 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d number=len(astropy_times_i), step='1h') lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) dist = eph['r'] - interpolaters_comet[c]['lon'] = interp1d(astropy_times_i.mjd, lon) lons += lon.tolist() lats += lat.tolist() dists += dist.tolist() From d53e4ea88643b9535a0ab8220c6ab20490a1d822 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 26 Nov 2024 16:53:52 +0100 Subject: [PATCH 058/171] Added instrument labels, adjusted priors --- .../defaults/bands/HFI/HFI_100-2_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_100-3_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_100-4_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_217-5_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_217-6_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_217-7_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_217-8_DIRBE.defaults | 1 + .../defaults/bands/HFI/HFI_353-1_DIRBE.defaults | 2 +- .../defaults/bands/HFI/HFI_353-2_DIRBE.defaults | 2 +- .../defaults/bands/HFI/HFI_353-3_DIRBE.defaults | 3 ++- .../defaults/bands/HFI/HFI_353-4_DIRBE.defaults | 3 ++- .../defaults/bands/HFI/HFI_353-5_DIRBE.defaults | 3 ++- .../defaults/bands/HFI/HFI_353-6_DIRBE.defaults | 3 ++- .../defaults/bands/HFI/HFI_353-7_DIRBE.defaults | 2 +- .../defaults/bands/HFI/HFI_353-8_DIRBE.defaults | 2 +- .../parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults | 1 + .../parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults | 1 + .../parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults | 1 + .../parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults | 1 + .../defaults/bands/haslam/haslam_0.4_map.defaults | 1 + .../defaults/components/dust/dust_coldtab_DIRBE.defaults | 4 ++-- 30 files changed, 35 insertions(+), 10 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_DIRBE.defaults index 95712d2a6..35e3d8533 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_DIRBE.defaults @@ -1,5 +1,6 @@ # 100-2 single-horn map parameters BAND_LABEL&&& = 100-2 +BAND_INSTRUMENT_LABEL&&& = 100-2 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_DIRBE.defaults index c0a2fb989..f3f6307c3 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_DIRBE.defaults @@ -1,5 +1,6 @@ # 100-3 single-horn map parameters BAND_LABEL&&& = 100-3 +BAND_INSTRUMENT_LABEL&&& = 100-3 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_DIRBE.defaults index d95557cea..99188930b 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_DIRBE.defaults @@ -1,5 +1,6 @@ # 100-4 single-horn map parameters BAND_LABEL&&& = 100-4 +BAND_INSTRUMENT_LABEL&&& = 100-4 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE.defaults index 033f7e3b1..10128f200 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE.defaults @@ -1,5 +1,6 @@ # 217-5 single-horn map parameters BAND_LABEL&&& = 217-5 +BAND_INSTRUMENT_LABEL&&& = 217-5 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE.defaults index abd0ace37..a0333cde4 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE.defaults @@ -1,5 +1,6 @@ # 217-6 single-horn map parameters BAND_LABEL&&& = 217-6 +BAND_INSTRUMENT_LABEL&&& = 217-6 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE.defaults index cc7227eea..9d07cb909 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE.defaults @@ -1,5 +1,6 @@ # 217-7 single-horn map parameters BAND_LABEL&&& = 217-7 +BAND_INSTRUMENT_LABEL&&& = 217-7 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE.defaults index a3ed4aa5c..eef833da9 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE.defaults @@ -1,5 +1,6 @@ # 217-8 single-horn map parameters BAND_LABEL&&& = 217-8 +BAND_INSTRUMENT_LABEL&&& = 217-8 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE.defaults index e749b7d67..401c68276 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE.defaults @@ -19,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-1.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE.defaults index 61de1c3b3..27592d7a2 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE.defaults @@ -19,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-2.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE.defaults index feb3613cf..dc36afd65 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE.defaults @@ -1,5 +1,6 @@ # 353-3 single-horn map parameters BAND_LABEL&&& = 353-3 +BAND_INSTRUMENT_LABEL&&& = 353-3 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -18,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-3_SHORN.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE.defaults index 599262989..a94edc340 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE.defaults @@ -1,5 +1,6 @@ # 353-4 single-horn map parameters BAND_LABEL&&& = 353-4 +BAND_INSTRUMENT_LABEL&&& = 353-4 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -18,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-4_SHORN.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE.defaults index 2eaced8b0..a512a54ff 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE.defaults @@ -1,5 +1,6 @@ # 353-5 single-horn map parameters BAND_LABEL&&& = 353-5 +BAND_INSTRUMENT_LABEL&&& = 353-5 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -18,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-5_SHORN.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE.defaults index 8f572b2df..2d6da93ee 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE.defaults @@ -1,5 +1,6 @@ # 353-6 single-horn map parameters BAND_LABEL&&& = 353-6 +BAND_INSTRUMENT_LABEL&&& = 353-6 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -18,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-6_SHORN.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE.defaults index 73a0e7608..466c8d602 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE.defaults @@ -19,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-7.dat diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE.defaults index 5ffd27adf..bb2604926 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE.defaults @@ -19,7 +19,7 @@ BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb -BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} BAND_NOMINAL_FREQ&&& = 353 BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-8.dat diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults index 8ac3bce96..63e89f0dc 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults @@ -1,6 +1,7 @@ #LFI 30 GHz TOD default parameters BAND_LABEL&&& = 030 +BAND_INSTRUMENT_LABEL&&& = 030 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults index 645641961..4257eea4e 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults @@ -1,4 +1,5 @@ BAND_LABEL&&& = 044 +BAND_INSTRUMENT_LABEL&&& = 044 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults index ca5565d22..0e4ccbd82 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults @@ -1,5 +1,6 @@ # 70 GHz parameters BAND_LABEL&&& = 070 +BAND_INSTRUMENT_LABEL&&& = 070 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 1024 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults index 8255e3b86..a8e4dc28d 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults @@ -1,5 +1,6 @@ #WMAP K TOD default parameters BAND_LABEL&&& = 023-WMAP_K +BAND_INSTRUMENT_LABEL&&& = 023-WMAP_K BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults index e41d13a87..2f81b1b29 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Ka TOD default parameters BAND_LABEL&&& = 030-WMAP_Ka +BAND_INSTRUMENT_LABEL&&& = 030-WMAP_Ka BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults index f3a69e246..6d4cf2b95 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Q1 TOD default parameters BAND_LABEL&&& = 040-WMAP_Q1 +BAND_INSTRUMENT_LABEL&&& = 040-WMAP_Q1 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults index 6e2e7dd21..f67f22af0 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Q2 TOD default parameters BAND_LABEL&&& = 040-WMAP_Q2 +BAND_INSTRUMENT_LABEL&&& = 040-WMAP_Q2 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults index 0d28ebb47..3e8e657d9 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults @@ -1,6 +1,7 @@ #WMAP V1 TOD default parameters BAND_LABEL&&& = 060-WMAP_V1 +BAND_INSTRUMENT_LABEL&&& = 060-WMAP_V1 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults index 6c2b3bbb0..b072c9dcb 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults @@ -1,6 +1,7 @@ #WMAP V2 TOD default parameters BAND_LABEL&&& = 060-WMAP_V2 +BAND_INSTRUMENT_LABEL&&& = 060-WMAP_V2 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults index 32e4fdf69..abc27eb19 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Ka TOD default parameters BAND_LABEL&&& = 090-WMAP_W1 +BAND_INSTRUMENT_LABEL&&& = 090-WMAP_W1 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults index 28caccffb..1b22fa975 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Ka TOD default parameters BAND_LABEL&&& = 090-WMAP_W2 +BAND_INSTRUMENT_LABEL&&& = 090-WMAP_W2 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults index 9b2dad089..03d28c529 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Ka TOD default parameters BAND_LABEL&&& = 090-WMAP_W3 +BAND_INSTRUMENT_LABEL&&& = 090-WMAP_W3 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults index 149c1dfe8..a3125e6ef 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults @@ -1,6 +1,7 @@ #WMAP Ka TOD default parameters BAND_LABEL&&& = 090-WMAP_W4 +BAND_INSTRUMENT_LABEL&&& = 090-WMAP_W4 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults b/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults index 0b713769e..d0ce5935b 100644 --- a/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults +++ b/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults @@ -1,5 +1,6 @@ # Haslam 0.4 GHz BAND_LABEL&&& = 0.4-Haslam +BAND_INSTRUMENT_LABEL&&& = 0.4-Haslam BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 512 diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults index c3528c818..3018554df 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults @@ -52,8 +52,8 @@ COMP_BETA_SMOOTHING_SCALE&& = 1 COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} COMP_T_DEFAULT&& = 16. -COMP_T_PRIOR_UNI_LOW&& = 10. -COMP_T_PRIOR_UNI_HIGH&& = 35. +COMP_T_PRIOR_UNI_LOW&& = 8. +COMP_T_PRIOR_UNI_HIGH&& = 20. COMP_T_PRIOR_GAUSS_MEAN&& = 18 COMP_T_PRIOR_GAUSS_RMS&& = 1. COMP_T_SMOOTHING_SCALE&& = 1 From 36eb85d7b491749669a5ee0b527a26153deebede Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 27 Nov 2024 15:22:01 +0100 Subject: [PATCH 059/171] Added positivity prior on MBBtab in MH sampling --- commander3/src/comm_mh_specind_mod.f90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 2d8d97292..b0c7bba92 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -348,7 +348,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) real(dp) :: chisq, my_chisq, chisq_old, chisq_new, chisq_prop, mval, mval_0 integer(i4b) :: band, ierr, i, j, k, m, pol, pix - logical(lgt) :: include_comp, reject, todo + logical(lgt) :: include_comp, reject, todo, negative character(len=512) :: tokens(10), str_buff, operation class(comm_comp), pointer :: c => null() class(comm_map), pointer :: invN_res => null(), map => null(), sig => null(), res => null() @@ -363,7 +363,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) mval_0 = -1d0 k = 0 - + c => compList do while (associated(c)) k = k + 1 @@ -398,6 +398,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) call store_buffer() + negative = .false. c => compList do while (associated(c)) @@ -427,7 +428,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) end do end if - + negative = negative .or. any(c%SEDtab(3:,:) < 0.d0) end if call mpi_bcast(c%SEDtab, size(c%SEDtab), MPI_DOUBLE_PRECISION, & & 0, data(1)%info%comm, ierr) @@ -461,7 +462,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) end if ! Check MH statistic - reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 + reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 .or. negative call mpi_bcast(reject, 1, MPI_LOGICAL, 0, data(1)%info%comm, ierr) From 08f59596056f2a7afe0647e460d69e0bffdda0c1 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 29 Nov 2024 00:12:01 +0100 Subject: [PATCH 060/171] Added missing initialization of l_apod --- commander3/src/comm_cl_mod.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/commander3/src/comm_cl_mod.f90 b/commander3/src/comm_cl_mod.f90 index e7f4d069d..33c435108 100644 --- a/commander3/src/comm_cl_mod.f90 +++ b/commander3/src/comm_cl_mod.f90 @@ -129,6 +129,7 @@ function constructor(cpar, info, id, id_abs) constructor%lmin = cpar%cs_lmin_amp(id_abs) constructor%lmax = cpar%cs_lmax_amp(id_abs) constructor%lmax_prior = cpar%cs_lmax_amp_prior(id_abs) + constructor%l_apod = cpar%cs_l_apod(id_abs) constructor%unit = cpar%cs_unit(id_abs) constructor%nu_ref = cpar%cs_nu_ref(id_abs,:) constructor%nmaps = 1; if (cpar%cs_polarization(id_abs)) constructor%nmaps = 3 From 25e728e673446eeac0cf9e7b2edb3204f9822e2b Mon Sep 17 00:00:00 2001 From: Duncan Date: Sat, 30 Nov 2024 06:27:35 +0100 Subject: [PATCH 061/171] Comet debugging --- .../todscripts/dirbe/metin/dirbe_utils.py | 6 +- .../dirbe/metin/write_tods_final.py | 78 +++++++++++++++---- 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index 76d8c2976..ef237ef24 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -167,7 +167,7 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d interpolaters_asteroids = {} rotator = hp.Rotator(coord=["C", "G"]) with solar_system_ephemeris.set('de432s'): - for c in COMET_RADII: + for ci, c in enumerate(COMET_RADII): interpolaters_comet[c] = {} lons = [] lats = [] @@ -176,7 +176,7 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d astropy_times_i = astropy_times[i*1441:(i+1)*1441] eph = MPC.get_ephemeris(c, start=astropy_times_i[0], number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) dist = eph['r'] lons += lon.tolist() lats += lat.tolist() @@ -184,6 +184,8 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d lons = np.array(lons) lats = np.array(lats) dists = np.array(dists) + locs = np.array([lons, lats]) + np.save(f'comet_{ci}', locs) interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index ecaf4b8f9..47a371fda 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -80,19 +80,21 @@ '73P/Schwassmann–Wachmann 3':13, 'C/1989 Q1':14, 'C/1989 T1':15, - 'C/1989 X1':16, - 'C/1990 K1':17, + 'C/1990 K1':16, + '1 Ceres':17, + '2 Pallas':18, + '4 Vesta':19, # Orbit and attitude flag (each observation has either of each pair turned on) - "non_definitive_attitude": 18, - "definite_attitude": 19, - "course_attitude": 20, - "fine_attitude": 21, - "merged_attitude": 22, - "external_uax_attitude": 23, - "space_craft_slewing": 24, - "space_craft_not_slewing": 25, - "special_pointing": 26, - "normal_pointing": 27, + "non_definitive_attitude": 20, + # "definite_attitude": 19, + "coarse_attitude": 21, + # "fine_attitude": 21, + # "merged_attitude": 22, + # "external_uax_attitude": 23, + # "space_craft_slewing": 24, + # "space_craft_not_slewing": 25, + # "special_pointing": 26, + # "normal_pointing": 27, #"space_craft_ascending": 28, #"space_craft_descending": 29, #"leading_los": 25, @@ -104,6 +106,7 @@ class YdayData: tods: dict[str, np.ndarray] pixels: dict[str, np.ndarray] + psis: dict[str, np.ndarray] flags: dict[str, np.ndarray] time_start: float time_stop: float @@ -117,6 +120,7 @@ class YdayData: class CIO: tods: list[np.ndarray] pixels: list[np.ndarray] + psis: list[np.ndarray] flags: list[np.ndarray] time_start: list[float] time_stop: list[float] @@ -131,6 +135,7 @@ def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: f"{band:02}": CIO( tods=[yday.tods[f"{band:02}"] for yday in yday_data], pixels=[yday.pixels[f"{band:02}"] for yday in yday_data], + psis=[yday.psis[f"{band:02}"] for yday in yday_data], flags=[yday.flags[f"{band:02}"] for yday in yday_data], time_start=[yday.time_start for yday in yday_data], time_stop=[yday.time_stop for yday in yday_data], @@ -146,8 +151,8 @@ def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: def get_yday_data( files: range, nside_out: int, planet_time_delta: timedelta, color_corr: bool ) -> list[YdayData]: - planet_interps = dirbe_utils.get_planet_interps(planet_time_delta) comet_interps, asteroid_interps = dirbe_utils.get_smallbody_interps(planet_time_delta) + planet_interps = dirbe_utils.get_planet_interps(planet_time_delta) with multiprocessing.Pool(processes=N_PROC) as pool: proc_chunks = [ @@ -210,6 +215,7 @@ def get_yday_cio_data( bad_data_padding = padd_vals(base_padding, BAD_DATA_SENTINEL) pix_padding = padd_vals(base_padding, 0, dtype=np.int64) flag_padding = padd_vals(base_padding, 2 ** FLAG_BITS["bad_data"], dtype=np.int16) + psi_padding = padd_vals(base_padding, 0, dtype=np.int64) # Get cio flags rad_zone_flags = data["RadZone"].astype(np.int8)[time_sorted_inds] @@ -241,6 +247,7 @@ def get_yday_cio_data( # Extract tods, and modify pointing vectors per detector according to beam data tods: dict[str, np.ndarray] = {} pixels: dict[str, np.ndarray] = {} + psis: dict[str, np.ndarray] = {} flags: dict[str, np.ndarray] = {} for band in dirbe_utils.BANDS: band_label = f"{band:02}" @@ -277,7 +284,7 @@ def get_yday_cio_data( ) # Rotate ecliptic vectors to galactic (commander convention) and apply time ordered sorting - unit_vectors = los[:, time_sorted_inds] + unit_vectors = new_los[:, time_sorted_inds] unit_vectors_gal = ROTATOR(unit_vectors) # Convert unit vectors to requested nside resolution healpix pixels @@ -286,6 +293,19 @@ def get_yday_cio_data( tod = data[f"Phot{cio_band_label}"].astype(np.float64)[time_sorted_inds] + # Compute polarization angle + lonrad = np.deg2rad(lon) + latrad = np.deg2rad(lat) + colat = np.pi/2 - latrad + att_x = natv[:,0]*np.cos(lonrad) + natv[:,1]*np.sin(lonrad) + att_y = natv[:,1]*np.cos(lonrad) - natv[:,0]*np.sin(lonrad) + + xp = att_x*np.cos(colat) - natv[:,2]*np.sin(colat) + psi = np.arctan2(att_y, xp) + psi[psi < 0] += 2*np.pi + psi = psi % (2*np.pi) + + # Remove the iras convention color correction iras_color_corr_factor = dirbe_utils.get_iras_factor(band) flag = common_flags.copy() @@ -310,6 +330,8 @@ def get_yday_cio_data( # Get comet flags for body, radius in dirbe_utils.COMET_RADII.items(): + if body not in FLAG_BITS.keys(): + continue comet_lon = comet_interps[body]["lon"](time) comet_lat = comet_interps[body]["lat"](time) comet_dist = comet_interps[body]["dist"](time) @@ -328,6 +350,23 @@ def get_yday_cio_data( comet_indices = ang_dist <= np.deg2rad(r) flag[comet_indices] += 2 ** FLAG_BITS[body] + for body, radius in dirbe_utils.ASTEROID_RADII.items(): + if body not in FLAG_BITS.keys(): + continue + aster_lon = asteroid_interps[body]["lon"](time) + aster_lat = asteroid_interps[body]["lat"](time) + + + ang_dist = hp.rotator.angdist( + np.array([lon, lat]), + np.array([aster_lon, aster_lat]), + lonlat=True, + ) + + aster_indices = ang_dist <= np.deg2rad(r) + flag[aster_indices] += 2 ** FLAG_BITS[body] + + # Find which flags correspond to the detector and get the inds of those flags xs_noise_inds = (xs_noise_flags & band_bit) > 0 flag[xs_noise_inds] += 2 ** FLAG_BITS["excess_noise"] @@ -357,6 +396,10 @@ def get_yday_cio_data( padding=bad_data_padding, ) + psis[band_label] = padd_array_gaps( + np.split(psi, split_inds), padding=psi_padding + ) + flags[band_label] = padd_array_gaps( np.split(flag, split_inds), padding=flag_padding ) @@ -364,6 +407,7 @@ def get_yday_cio_data( return YdayData( tods, pixels, + psis, flags, time_start=time[0], time_stop=time[-1], @@ -463,7 +507,7 @@ def write_band( ] comm_tod.add_field( pid_det_group + "/psi", - np.zeros_like(cio.tods[pid]), + cio.psis[pid], [psi_digitize_compression, HUFFMAN_COMPRESSION], ) @@ -544,7 +588,7 @@ def main() -> None: nside_out = 512 start_time = time.perf_counter() - color_corr = True + color_corr = False version = 21 print(f"{'Writing DIRBE h5 files':=^50}") @@ -605,7 +649,7 @@ def main() -> None: "neptune", "non_definitive_attitude", # "definite_attitude", - "course_attitude", + "coarse_attitude", # "fine_attitude", # "merged_attitude", # "external_uax_attitude", From 5f59a064542f8ce937ae9f23b110357220ebc4be Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 30 Nov 2024 23:31:24 +0100 Subject: [PATCH 062/171] Added support for Wright (1998) zodi model --- .../bands/DIRBE/DIRBE_08_CIO_512.defaults | 2 +- commander3/src/comm_param_mod.f90 | 30 +- commander3/src/comm_tod_driver_mod.f90 | 9 + commander3/src/comm_zodi_comp_mod.f90 | 314 +++++++++++++++++- commander3/src/comm_zodi_mod.f90 | 105 +++++- 5 files changed, 430 insertions(+), 30 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults index 6516310f1..1f4257b9f 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults @@ -50,7 +50,7 @@ BAND_TOD_LEVEL&&& = L2 BAND_MAPFILE&&& = DIRBE_08_512_v1.fits BAND_NOISEFILE&&& = DIRBE_08_SIGMA_512_v1.fits -BAND_REG_NOISEFILE&&& = none +BAND_REG_NOISEFILE&&& = none DIRBE_08_regnoise_v1.fits BAND_NOISE_RMS&&&_SMOOTH01 = DIRBE_08_SIGMA_512_v1_1deg_n256_v2.fits BAND_NOISE_RMS&&&_SMOOTH02 = none BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 43ab720af..81364ef1e 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -41,16 +41,18 @@ module comm_param_mod type(status_file) :: status type InterplanetaryDustParamLabels - character(len=128), dimension(2) :: general = [character(len=128) :: "T_0", "T_DELTA"] - character(len=128), dimension(6) :: common = [character(len=128) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] - character(len=128), dimension(4) :: cloud = [character(len=128) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] - character(len=128), dimension(4) :: band = [character(len=128) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] - character(len=128), dimension(5) :: ring = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(5) :: feature = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(2) :: interstellar = [character(len=128) :: 'R', 'ALPHA'] - character(len=128), dimension(5) :: fan = [character(len=128) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] - character(len=128), dimension(4) :: comet = [character(len=128) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] - character(len=128), dimension(4) :: comp_types = [character(len=128) :: 'CLOUD', 'BAND', 'RING', 'FEATURE'] + character(len=128), dimension(2) :: general = [character(len=128) :: "T_0", "T_DELTA"] + character(len=128), dimension(6) :: common = [character(len=128) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] + character(len=128), dimension(4) :: cloud = [character(len=128) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] + character(len=128), dimension(4) :: band = [character(len=128) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] + character(len=128), dimension(5) :: ring = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=128), dimension(5) :: feature = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=128), dimension(2) :: interstellar = [character(len=128) :: 'R', 'ALPHA'] + character(len=128), dimension(5) :: fan = [character(len=128) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] + character(len=128), dimension(4) :: comet = [character(len=128) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] + character(len=128), dimension(16) :: WrightCloudRing = [character(len=128) :: 'p1', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p13', 'p14', 'p15', 'p16', 'p17', 'p18', 'p19'] + character(len=128), dimension(6) :: WrightBand = [character(len=128) :: 'q1', 'q5', 'q6', 'q7', 'q8', 'R_1'] + character(len=128), dimension(6) :: comp_types = [character(len=128) :: 'CLOUD', 'BAND', 'RING', 'FEATURE', 'WRIGHTCLOUDRING', 'WRIGHTBAND'] contains procedure :: get_labels @@ -2935,7 +2937,7 @@ subroutine read_zodi_params_hash(htbl, cpar) type(hash_tbl_sll), intent(in) :: htbl type(comm_params), intent(inout) :: cpar - integer(i4b) :: i, j, k, comp_idx, len_itext, n_params, n_tokens, N_COMMON_PARAMETERS, N_CLOUD_PARAMETERS, N_BAND_PARAMETERS, N_RING_PARAMETERS, N_FEATURE_PARAMETERS, N_DIRBE_BANDS, num_e, num_a + integer(i4b) :: i, j, k, comp_idx, len_itext, n_params, n_tokens, N_COMMON_PARAMETERS, N_CLOUD_PARAMETERS, N_BAND_PARAMETERS, N_RING_PARAMETERS, N_WRIGHTCLOUDRING_PARAMETERS, N_WRIGHTBAND_PARAMETERS, N_FEATURE_PARAMETERS, N_DIRBE_BANDS, num_e, num_a character(len=2) :: itext2 character(len=3) :: itext character(len=64), allocatable :: parameter_labels(:) @@ -4118,7 +4120,11 @@ function get_labels(self, comp_type, add_common) result(labels) case ('FAN') labels = self%fan case ('COMET') - labels = self%comet + labels = self%comet + case ('WRIGHTCLOUDRING') + labels = self%wrightcloudring + case ('WRIGHTBAND') + labels = self%wrightband case default print *, 'Unknown component type: ', comp_type stop diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 1b7d562c7..c51535ffc 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -255,6 +255,15 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, map_gain, procmas !!$ & albedo=tod%zodi_albedo & !!$ &) call get_s_tot_zodi(zodi_model, tod, j, scan, self%s_zodi(:, j), pix_dynamic=self%pix(:,j,:), pix_static=tod%scans(scan)%d(j)%pix_sol, s_scat=self%s_zodi_scat(:,:,j), s_therm=self%s_zodi_therm(:,:,j)) +!!$ if (tod%myid == 0) then +!!$ open(58,file='zodi.dat') +!!$ do k = 1, size(self%s_zodi(:,j)) +!!$ write(58,*) k, self%s_zodi(k,j), self%mask(k,j) +!!$ end do +!!$ close(58) +!!$ end if +!!$ call mpi_finalize(k) +!!$ stop end do call timer%stop(TOD_ZODI, tod%band) end if diff --git a/commander3/src/comm_zodi_comp_mod.f90 b/commander3/src/comm_zodi_comp_mod.f90 index 7c24b6da1..3131d3c0f 100644 --- a/commander3/src/comm_zodi_comp_mod.f90 +++ b/commander3/src/comm_zodi_comp_mod.f90 @@ -136,6 +136,26 @@ end subroutine m2p_interface procedure :: model2param => model2param_comet end type ZodiComet + type, extends(ZodiComponent) :: ZodiWrightCloudRing + real(dp) :: p1, p3, p4, p5, p6, p7, p8, p9, p10, p13, p14, p15, p16, p17, p18, p19 + contains + procedure :: init => init_WrightCloudRing + procedure :: get_density => get_density_WrightCloudRing + procedure :: init_priors_and_scales => init_WrightCloudRing_priors_and_scales + procedure :: param2model => param2model_WrightCloudRing + procedure :: model2param => model2param_WrightCloudRing + end type ZodiWrightCloudRing + + type, extends(ZodiComponent) :: ZodiWrightBand + real(dp) :: q1, q5, q6, q7, q8, R_1 + contains + procedure :: init => init_WrightBand + procedure :: get_density => get_density_WrightBand + procedure :: init_priors_and_scales => init_WrightBand_priors_and_scales + procedure :: param2model => param2model_WrightBand + procedure :: model2param => model2param_WrightBand + end type ZodiWrightBand + contains subroutine init_base_comp(self) @@ -177,21 +197,32 @@ subroutine init_interstellar(self) end subroutine init_interstellar subroutine init_fan(self) - class(ZodiFan) :: self - call self%init_base_comp() - end subroutine init_fan + class(ZodiFan) :: self + call self%init_base_comp() + end subroutine init_fan + + subroutine init_comet(self) + class(ZodiComet) :: self + call self%init_base_comp() + end subroutine init_comet + + subroutine init_WrightCloudRing(self) + class(ZodiWrightCloudRing) :: self + call self%init_base_comp() + end subroutine init_WrightCloudRing - subroutine init_comet(self) - class(ZodiComet) :: self - call self%init_base_comp() - end subroutine init_comet + subroutine init_WrightBand(self) + class(ZodiWrightBand) :: self + call self%init_base_comp() + end subroutine init_WrightBand - subroutine init_cloud_priors_and_scales(self, start_ind, prior, scale) - implicit none - class(ZodiCloud), intent(in) :: self - integer(i4b), intent(in) :: start_ind - real(dp), dimension(1:,1:), intent(inout) :: prior - real(dp), dimension(1:,1:), intent(inout) :: scale + + subroutine init_cloud_priors_and_scales(self, start_ind, prior, scale) + implicit none + class(ZodiCloud), intent(in) :: self + integer(i4b), intent(in) :: start_ind + real(dp), dimension(1:,1:), intent(inout) :: prior + real(dp), dimension(1:,1:), intent(inout) :: scale ! Common parameters prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 @@ -405,6 +436,99 @@ subroutine init_comet_priors_and_scales(self, start_ind, prior, scale) scale(start_ind+9,:) = [1.d0, 0.d0] end subroutine init_comet_priors_and_scales + ! See Appendix in Wright (1998) for details; https://iopscience.iop.org/article/10.1086/305345/pdf + subroutine init_WrightCloudRing_priors_and_scales(self, start_ind, prior, scale) + implicit none + class(ZodiWrightCloudRing), intent(in) :: self + integer(i4b), intent(in) :: start_ind + real(dp), dimension(1:,1:), intent(inout) :: prior + real(dp), dimension(1:,1:), intent(inout) :: scale + + ! Common parameters + prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-8, -1.d0] ! n_0 + scale(start_ind+0,:) = [1.d-9, 4.d-9] + prior(:,start_ind+1) = [0.d0,0.d0, 0.d0, -1.d0] ! Incl -- don't fit in Wright model, it's part of the internal parameterization + scale(start_ind+1,:) = [1.d0, 0.d0] + prior(:,start_ind+2) = [0.d0, 0.d0, 0.d0, -1.d0] ! Omega + scale(start_ind+2,:) = [1.d0, 0.d0] + prior(:,start_ind+3) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! X_0 + scale(start_ind+3,:) = [1.d0, 0.d0] + prior(:,start_ind+4) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Y_0 + scale(start_ind+4,:) = [1.d0, 0.d0] + prior(:,start_ind+5) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Z_0 + scale(start_ind+5,:) = [1.d0, 0.d0] + ! Component-specific parameters + prior(:,start_ind+6) = [ 1.d0, 1.5d0, 1.2186d0, -1.d0] ! p1 - radial density exponent + scale(start_ind+6,:) = [1.d0, 0.01d0] + prior(:,start_ind+7) = [ 3.d0, 4d0, 3.6122d0, -1.d0] ! p3 - vertical "scale height" + scale(start_ind+7,:) = [1.d0, 0.01d0] + prior(:,start_ind+8) = [ 0.7d0, 1.1d0, 0.9285d0, -1.d0] ! p4 - vertical density exponent + scale(start_ind+8,:) = [1.d0, 0.01d0] + prior(:,start_ind+9) = [-1.8d0, -1.2d0, -1.4766d0, -1.d0] ! p5 - ln(sin i) at break + scale(start_ind+9,:) = [1.d0, 0.01d0] + prior(:,start_ind+10) = [ -1.d0, 1.d0, 0.3705d0, -1.d0] ! p6 - 10 x cloud pole x component + scale(start_ind+10,:) = [1.d0, 0.01d0] + prior(:,start_ind+11) = [ -1.d0, 1.d0, -0.0736d0, -1.d0] ! p7 - 10 x cloud pole y component + scale(start_ind+11,:) = [1.d0, 0.01d0] + prior(:,start_ind+12) = [ -1.d0, 1.d0, -0.0235d0, -1.d0] ! p8 - 10 x cloud offset x component + scale(start_ind+12,:) = [1.d0, 0.01d0] + prior(:,start_ind+13) = [-1.d0, 1.d0, -0.0081d0, -1.d0] ! p9 - 10 x cloud offset y component + scale(start_ind+13,:) = [1.d0, 0.01d0] + prior(:,start_ind+14) = [ 0.1d0, 3.d0, 0.7548d0, -1.d0] ! p10 - 10 x density contrast of Dermott ring + scale(start_ind+14,:) = [1.d0, 0.01d0] + prior(:,start_ind+15) = [ 0.1d0, 1.d0, 0.4284d0, -1.d0] ! p13 - "dimple" in Dermott ring + scale(start_ind+15,:) = [1.d0, 0.01d0] + prior(:,start_ind+16) = [ 0.d0, 50.d0, 27.7741d0, -1.d0] ! p14 - vertical scale for Dermott ring + scale(start_ind+16,:) = [1.d0, 1.d0] + prior(:,start_ind+17) = [-0.1d0, 0.1d0, -0.0251d0, -1.d0] ! p15 - spherical term in vertical density + scale(start_ind+17,:) = [1.d0, 0.01d0] + prior(:,start_ind+18) = [-0.2d0, 0.2d0, 0.0249d0, -1.d0] ! p16 - (sin i)**2 term in vertical density + scale(start_ind+18,:) = [1.d0, 0.01d0] + prior(:,start_ind+19) = [-0.2d0, 0.2d0, -0.0456d0, -1.d0] ! p17 - Additional density at sin i ~ 0.5 + scale(start_ind+19,:) = [1.d0, 0.01d0] + prior(:,start_ind+20) = [-0.2d0, 0.2d0, -0.1276d0, -1.d0] ! p18 - Additional density at sin i ~ 0.25 + scale(start_ind+20,:) = [1.d0, 0.01d0] + prior(:,start_ind+21) = [-0.2d0, 0.2d0, -0.0103d0, -1.d0] ! p19 - Additional density at sin i ~ 0.17 + scale(start_ind+21,:) = [1.d0, 0.01d0] + end subroutine init_WrightCloudRing_priors_and_scales + + ! See Appendix in Wright (1998) for details; https://iopscience.iop.org/article/10.1086/305345/pdf + subroutine init_WrightBand_priors_and_scales(self, start_ind, prior, scale) + implicit none + class(ZodiWrightBand), intent(in) :: self + integer(i4b), intent(in) :: start_ind + real(dp), dimension(1:,1:), intent(inout) :: prior + real(dp), dimension(1:,1:), intent(inout) :: scale + + ! Common parameters + prior(:,start_ind+0) = [1.d-11, 1.d-5, 1.d-9, -1.d0] ! n_0 + scale(start_ind+0,:) = [1.d-9, 4.d-9] + prior(:,start_ind+1) = [0.d0,0.d0, 0.d0, -1.d0] ! Incl -- don't fit in Wright model, these are part of the internal parameterization + scale(start_ind+1,:) = [1.d0, 0.d0] + prior(:,start_ind+2) = [0.d0, 0.d0, 0.d0, -1.d0] ! Omega + scale(start_ind+2,:) = [1.d0, 0.d0] + prior(:,start_ind+3) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! X_0 + scale(start_ind+3,:) = [1.d0, 0.d0] + prior(:,start_ind+4) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Y_0 + scale(start_ind+4,:) = [1.d0, 0.d0] + prior(:,start_ind+5) = [0.d0, 0.d0, 0.d0, -1.d0] ! ! Z_0 + scale(start_ind+5,:) = [1.d0, 0.d0] + ! Component-specific parameters + prior(:,start_ind+6) = [ 1.d0, 2.0d0, 1.3849d0, -1.d0] ! q1 - 10 x (sin i)_max for band 1 + scale(start_ind+6,:) = [1.d0, 0.01d0] + prior(:,start_ind+7) = [-0.3d0, 0.3d0, 0.1735d0, -1.d0] ! q5 - 10 x band pole x component + scale(start_ind+7,:) = [1.d0, 0.01d0] + prior(:,start_ind+8) = [-0.3d0, 0.3d0, -0.2088d0, -1.d0] ! q6 - 10 x band pole y component + scale(start_ind+8,:) = [1.d0, 0.01d0] + prior(:,start_ind+9) = [-2.d0, 2.d0, -1.5723d0, -1.d0] ! q7 - 10 x band offset x component + scale(start_ind+9,:) = [1.d0, 0.1d0] + prior(:,start_ind+10) = [ -2.d0, 2.d0, -0.2225d0, -1.d0] ! q8 - 10 x band offset y component + scale(start_ind+10,:) = [1.d0, 0.01d0] + prior(:,start_ind+11) = [ 2.d0, 4.d0, 3.14d0, -1.d0] ! R_1 - Outer radius + scale(start_ind+11,:) = [1.d0, 0.01d0] + end subroutine init_WrightBand_priors_and_scales + + subroutine param2model_cloud(self, x) implicit none class(ZodiCloud), intent(inout) :: self @@ -627,6 +751,96 @@ subroutine model2param_comet(self, x) x(10) = self%R_outer end subroutine model2param_comet + subroutine param2model_WrightCloudRing(self, x) + implicit none + class(ZodiWrightCloudRing), intent(inout) :: self + real(dp), dimension(1:), intent(in) :: x + self%n_0 = x(1) + self%incl = x(2) + self%Omega = x(3) + self%x_0 = x(4) + self%y_0 = x(5) + self%z_0 = x(6) + self%p1 = x(7) + self%p3 = x(8) + self%p4 = x(9) + self%p5 = x(10) + self%p6 = x(11) + self%p7 = x(12) + self%p9 = x(13) + self%p10 = x(14) + self%p13 = x(15) + self%p14 = x(16) + self%p15 = x(17) + self%p16 = x(18) + self%p17 = x(19) + self%p18 = x(20) + self%p19 = x(21) + end subroutine param2model_WrightCloudRing + + subroutine model2param_WrightCloudRing(self, x) + implicit none + class(ZodiWrightCloudRing), intent(in) :: self + real(dp), dimension(1:), intent(out) :: x + x(1) = self%n_0 + x(2) = self%incl + x(3) = self%Omega + x(4) = self%x_0 + x(5) = self%y_0 + x(6) = self%z_0 + x(7) = self%p1 + x(8) = self%p3 + x(9) = self%p4 + x(10) = self%p5 + x(11) = self%p6 + x(12) = self%p7 + x(13) = self%p9 + x(14) = self%p10 + x(15) = self%p13 + x(16) = self%p14 + x(17) = self%p15 + x(18) = self%p16 + x(19) = self%p17 + x(20) = self%p18 + x(21) = self%p19 + end subroutine model2param_WrightCloudRing + + subroutine param2model_WrightBand(self, x) + implicit none + class(ZodiWrightBand), intent(inout) :: self + real(dp), dimension(1:), intent(in) :: x + self%n_0 = x(1) + self%incl = x(2) + self%Omega = x(3) + self%x_0 = x(4) + self%y_0 = x(5) + self%z_0 = x(6) + self%q1 = x(7) + self%q5 = x(8) + self%q6 = x(9) + self%q7 = x(10) + self%q8 = x(11) + self%R_1 = x(12) + end subroutine param2model_WrightBand + + subroutine model2param_WrightBand(self, x) + implicit none + class(ZodiWrightBand), intent(in) :: self + real(dp), dimension(1:), intent(out) :: x + x(1) = self%n_0 + x(2) = self%incl + x(3) = self%Omega + x(4) = self%x_0 + x(5) = self%y_0 + x(6) = self%z_0 + x(7) = self%q1 + x(8) = self%q5 + x(9) = self%q6 + x(10) = self%q7 + x(11) = self%q8 + x(12) = self%R_1 + end subroutine model2param_WrightBand + subroutine get_density_cloud(self, X_vec, theta, n_out) class(ZodiCloud) :: self @@ -836,5 +1050,77 @@ subroutine get_density_comet(self, X_vec, theta, n_out) n_out(i) = 0.37 * self%n_0 * f / R end do end subroutine get_density_comet - + + subroutine get_density_WrightCloudRing(self, X_vec, theta, n_out) + class(ZodiWrightCloudRing) :: self + real(dp), dimension(:, :), intent(in) :: X_vec + real(dp), intent(in) :: theta + real(dp), dimension(:), intent(out) :: n_out + integer(i4b) :: i + real(dp) :: R, z_c(3), o_c(3), R_c + real(dp) :: f, sin_i, Z, S + real(dp) :: x_D, y_D, z_D, L_D, A, D + + ! X_vec = r = position to evaluate model in heliocentric coordinates + do i = 1, size(n_out) + R = sqrt(sum(X_vec(:,i)**2)) + z_c = [self%p6, self%p7, 10.d0] / sqrt(100.d0 + self%p6**2 + self%p7**2) + o_c = [self%p8/10.d0, self%p9/10.d0, 0.d0] + sin_i = sum(z_c*X_vec(:,i)) / R + R_c = R + sum(o_c * X_vec(:,i)) + + ! Cloud + S = exp(self%p5) + if (abs(sin_i) > S) then + Z = abs(sin_i) - 0.5d0*S + else + Z = 0.5d0*sin_i**2/S + end if + f = exp(-self%p3 * Z**self%p4) + self%p15 + self%p16 * sin_i**2 & + & + self%p17 * 4.d0*sin_i**2*exp( -4.d0*sin_i**2) & + & + self%p18 * 16.d0*sin_i**2*exp(-16.d0*sin_i**2) & + & + self%p19 * 36.d0*sin_i**2*exp(-36.d0*sin_i**2) + + ! Ring + x_D = X_vec(1,i)*cos(theta) + X_vec(2,i)*sin(theta) + y_D = X_vec(2,i)*cos(theta) - X_vec(1,i)*sin(theta) + z_D = X_vec(3,i) + L_D = abs(atan2(y_D, x_D) + 0.25d0) + if (L_D < 0.375d0) then + A = cos(8.d0*pi*L_d/3.d0) + else if (L_D < 0.75d0) then + A = 0.5d0*(cos(8.d0*pi*L_D/3)-1.d0) + else + A = 0.d0 + end if + D = exp(-56.5d0*(sqrt(x_D**2 + y_D**2) - 1.133d0 + 0.133d0 * self%p13 * exp(-4.d0*L_D**2))**2 - self%p14 * z_D**2/R**2) + + ! Total density + n_out(i) = self%n_0 * R/R_c * f * R_c**(-self%p1) * (1.d0 + 0.1d0 * self%p10 * D*(1.d0+A)) + end do + end subroutine get_density_WrightCloudRing + + subroutine get_density_WrightBand(self, X_vec, theta, n_out) + class(ZodiWrightBand) :: self + real(dp), dimension(:, :), intent(in) :: X_vec + real(dp), intent(in) :: theta + real(dp), dimension(:), intent(out) :: n_out + integer(i4b) :: i + real(dp) :: R, z_b(3), o_b(3), R_b, sin_i + + do i = 1, size(n_out) + R = sqrt(sum(X_vec(:,i)**2)) + z_b = [self%q5, self%q6, 10.d0] / sqrt(100.d0 + self%q5**2 + self%q6**2) + sin_i = sum(z_b*X_vec(:,i)) / R + o_b = [self%q7/10.d0, self%q8/10.d0, 0.d0] + R_b = R + sum(o_b * X_vec(:,i)) + + if (abs(sin_i) < 0.1d0*self%q1 .and. R_b < self%R_1) then + n_out(i) = self%n_0 * R/R_b**2 * cosh(1.72d0*abs(sin_i)/(0.1d0*self%q1)) + else + n_out(i) = 0.d0 + end if + end do + end subroutine get_density_WrightBand + end module comm_zodi_comp_mod diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 041941d9d..460429770 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -400,6 +400,52 @@ subroutine init_comps(self, params, comp_types, param_labels) &) allocate(self%comps(i)%labels(10)) self%comps(i)%labels = [param_labels%common, param_labels%comet] + case ('wrightcloudring') + allocate (ZodiWrightCloudRing::self%comps(i)%c) + self%comps(i)%c = ZodiWrightCloudRing(& + & n_0=params(i, 1), & + & incl=params(i, 2), & + & Omega=params(i, 3), & + & x_0=params(i, 4), & + & y_0=params(i, 5), & + & z_0=params(i, 6), & + & p1=params(i, 7), & + & p3=params(i, 8), & + & p4=params(i, 9), & + & p5=params(i, 10), & + & p6=params(i, 11), & + & p7=params(i, 12), & + & p8=params(i, 13), & + & p9=params(i, 14), & + & p10=params(i, 15), & + & p13=params(i, 16), & + & p14=params(i, 17), & + & p15=params(i, 18), & + & p16=params(i, 19), & + & p17=params(i, 20), & + & p18=params(i, 21), & + & p19=params(i, 22) & + &) + allocate(self%comps(i)%labels(22)) + self%comps(i)%labels = [param_labels%common, param_labels%wrightcloudring] + case ('wrightband') + allocate (ZodiWrightBand::self%comps(i)%c) + self%comps(i)%c = ZodiWrightBand(& + & n_0=params(i, 1), & + & incl=params(i, 2), & + & Omega=params(i, 3), & + & x_0=params(i, 4), & + & y_0=params(i, 5), & + & z_0=params(i, 6), & + & q1=params(i, 7), & + & q5=params(i, 8), & + & q6=params(i, 9), & + & q7=params(i, 10), & + & q8=params(i, 11), & + & R_1=params(i, 12) & + &) + allocate(self%comps(i)%labels(12)) + self%comps(i)%labels = [param_labels%common, param_labels%wrightband] case default print *, 'Invalid zodi component type in zodi `init_from_params`:', trim(adjustl(comp_types(i))) stop @@ -479,12 +525,38 @@ subroutine model_to_params2(self, x, labels) x(running_idx + 4) = comp%Z_midplane_0 x(running_idx + 5) = comp%R_outer running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiComet) + class is (ZodiComet) x(running_idx + 1) = comp%P x(running_idx + 2) = comp%Z_midplane_0 x(running_idx + 3) = comp%R_inner x(running_idx + 4) = comp%R_outer running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params + class is (ZodiWrightCloudRing) + x(running_idx + 1) = comp%p1 + x(running_idx + 2) = comp%p3 + x(running_idx + 3) = comp%p4 + x(running_idx + 4) = comp%p5 + x(running_idx + 5) = comp%p6 + x(running_idx + 6) = comp%p7 + x(running_idx + 7) = comp%p8 + x(running_idx + 8) = comp%p9 + x(running_idx + 9) = comp%p10 + x(running_idx + 10) = comp%p13 + x(running_idx + 11) = comp%p14 + x(running_idx + 12) = comp%p15 + x(running_idx + 13) = comp%p16 + x(running_idx + 14) = comp%p17 + x(running_idx + 15) = comp%p18 + x(running_idx + 16) = comp%p19 + running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params + class is (ZodiWrightBand) + x(running_idx + 1) = comp%q1 + x(running_idx + 2) = comp%q5 + x(running_idx + 3) = comp%q6 + x(running_idx + 4) = comp%q7 + x(running_idx + 5) = comp%q8 + x(running_idx + 6) = comp%R_1 + running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params end select if (present(labels)) then labels_copy = self%comps(i)%labels @@ -569,6 +641,32 @@ subroutine params_to_model2(self, x) comp%R_inner = x(running_idx + 3) comp%R_outer = x(running_idx + 4) running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params + class is (ZodiWrightCloudRing) + comp%p1 = x(running_idx + 1) + comp%p3 = x(running_idx + 2) + comp%p4 = x(running_idx + 3) + comp%p5 = x(running_idx + 4) + comp%p6 = x(running_idx + 5) + comp%p7 = x(running_idx + 6) + comp%p8 = x(running_idx + 7) + comp%p9 = x(running_idx + 8) + comp%p10 = x(running_idx + 9) + comp%p13 = x(running_idx + 10) + comp%p14 = x(running_idx + 11) + comp%p15 = x(running_idx + 12) + comp%p16 = x(running_idx + 13) + comp%p17 = x(running_idx + 14) + comp%p18 = x(running_idx + 15) + comp%p19 = x(running_idx + 16) + running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params + class is (ZodiWrightBand) + comp%q1 = x(running_idx + 1) + comp%q5 = x(running_idx + 2) + comp%q6 = x(running_idx + 3) + comp%q7 = x(running_idx + 4) + comp%q8 = x(running_idx + 5) + comp%R_1 = x(running_idx + 6) + running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params end select call self%comps(i)%c%init() end do @@ -1286,7 +1384,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod end if end do !!$ call vec2ang(unit_vector, lat, lon) -!!$ write(58,*) i, lon*180.d0/pi, 90.d0-180.d0/pi*lat, 0.958*sum(s_zodi_therm(i,:))!, sum(s_zodi_scat(i,:)), sum(s_zodi_therm(i,:))+sum(s_zodi_scat(i,:)) +!!$ write(58,*) i, lon*180.d0/pi, 90.d0-180.d0/pi*lat, 0.958*sum(s_zodi_therm(i,:)), sum(s_zodi_scat(i,:)), sum(s_zodi_therm(i,:))+sum(s_zodi_scat(i,:)) !!$ !!$ write(*,*) "X", comp_LOS(1)%X(1,:) !!$ write(*,*) "Y", comp_LOS(1)%X(2,:) @@ -1298,8 +1396,9 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !!$ !write(*,*) "F", comp_LOS(1)%F_sol*1.d20 !!$ !write(*,*) "Phi", comp_LOS(1)%Phi !!$ !write(*,*) "s", comp_LOS(1)%F_sol*comp_LOS(1)%Phi*1d20 * 0.255d0 + (1.d0-0.255d0) * 1.d0 * comp_LOS(1)%B_nu* 1.d0 +!!$ write(*,*) "T_0, delta", model%T_0, model%delta +!!$ write(*,*) "T", comp_LOS(1)%T !!$ write(*,*) "s", comp_LOS(1)%B_nu*0.958 - end do !!$ close(58) From 6ad4e45cccbefdd587995f3a9073dd0d13dc9ec4 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 14 Jan 2025 09:11:30 +0100 Subject: [PATCH 063/171] Support for separate preconditioners for each sample group --- commander3/src/comm_cr_mod.f90 | 6 +- commander3/src/comm_cr_precond_mod.f90 | 2 +- commander3/src/comm_diffuse_comp_mod.f90 | 24 ++-- commander3/src/comm_diffuse_comp_smod.f90 | 150 ++++++++++++---------- commander3/src/comm_md_comp_mod.f90 | 1 + commander3/src/comm_ptsrc_comp_mod.f90 | 21 +-- commander3/src/comm_signal_mod.f90 | 13 +- commander3/src/comm_template_comp_mod.f90 | 19 +-- commander3/src/commander.f90 | 2 +- 9 files changed, 128 insertions(+), 110 deletions(-) diff --git a/commander3/src/comm_cr_mod.f90 b/commander3/src/comm_cr_mod.f90 index 3b43b822f..25b85c676 100644 --- a/commander3/src/comm_cr_mod.f90 +++ b/commander3/src/comm_cr_mod.f90 @@ -1026,9 +1026,9 @@ function cr_invM(comm, x, samp_group) !!$ call mpi_finalize(ierr) !!$ stop - call applyDiffPrecond(cr_invM) - call applyPtsrcPrecond(cr_invM) - call applyTemplatePrecond(cr_invM) + call applyDiffPrecond(cr_invM, samp_group) + call applyPtsrcPrecond(cr_invM, samp_group) + call applyTemplatePrecond(cr_invM, samp_group) if (Q_is_active) cr_invM = cr_invM + Qx diff --git a/commander3/src/comm_cr_precond_mod.f90 b/commander3/src/comm_cr_precond_mod.f90 index a234492ab..516d6343b 100644 --- a/commander3/src/comm_cr_precond_mod.f90 +++ b/commander3/src/comm_cr_precond_mod.f90 @@ -34,6 +34,6 @@ module comm_cr_precond_mod type(invM), allocatable, dimension(:,:) :: invM_temp ! (1,1) end type precond - type(precond) :: P_cr + type(precond), allocatable, dimension(:) :: P_cr ! (n_sampgroup) end module comm_cr_precond_mod diff --git a/commander3/src/comm_diffuse_comp_mod.f90 b/commander3/src/comm_diffuse_comp_mod.f90 index 6c321a38b..baa89c807 100644 --- a/commander3/src/comm_diffuse_comp_mod.f90 +++ b/commander3/src/comm_diffuse_comp_mod.f90 @@ -245,24 +245,24 @@ module subroutine initSpecindProp(self,cpar, id, id_abs) end subroutine initSpecindProp - module subroutine initDiffPrecond(comm) + module subroutine initDiffPrecond(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group end subroutine initDiffPrecond - module subroutine initDiffPrecond_diagonal(comm) + module subroutine initDiffPrecond_diagonal(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group end subroutine initDiffPrecond_diagonal - module subroutine initDiffPrecond_pseudoinv(comm) + module subroutine initDiffPrecond_pseudoinv(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group end subroutine initDiffPrecond_pseudoinv @@ -336,25 +336,28 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) end function projectDiffuseBand - module subroutine applyDiffPrecond(x) + module subroutine applyDiffPrecond(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group end subroutine applyDiffPrecond - module subroutine applyDiffPrecond_diagonal(x) + module subroutine applyDiffPrecond_diagonal(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group end subroutine applyDiffPrecond_diagonal - module subroutine applyDiffPrecond_pseudoinv(x) + module subroutine applyDiffPrecond_pseudoinv(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group end subroutine applyDiffPrecond_pseudoinv @@ -434,8 +437,9 @@ end function lnL_diffuse_multi - module subroutine print_precond_mat + module subroutine print_precond_mat(samp_group) implicit none + integer(i4b), intent(in) :: samp_group end subroutine print_precond_mat module subroutine updateDiffuseFInt(self, band) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 0b9593bd5..36f505c60 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -1287,24 +1287,25 @@ module subroutine initSpecindProp(self,cpar, id, id_abs) end subroutine initSpecindProp - module subroutine initDiffPrecond(comm) + module subroutine initDiffPrecond(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group select case (trim(precond_type)) case ("diagonal") - call initDiffPrecond_diagonal(comm) + call initDiffPrecond_diagonal(comm, samp_group) case ("pseudoinv") - call initDiffPrecond_pseudoinv(comm) + call initDiffPrecond_pseudoinv(comm, samp_group) case default call report_error("Preconditioner type not supported: "//trim(precond_type)) end select end subroutine initDiffPrecond - module subroutine initDiffPrecond_diagonal(comm) + module subroutine initDiffPrecond_diagonal(comm, samp_group) implicit none integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: samp_group integer(i4b) :: i, i1, i2, j, k1, k2, q, l, m, n real(dp) :: t1, t2 @@ -1315,7 +1316,7 @@ module subroutine initDiffPrecond_diagonal(comm) call update_status(status, "init_diffpre1") if (npre == 0) return - if (allocated(P_cr%invM_diff)) return + if (allocated(P_cr(samp_group)%invM_diff)) return if (.not. allocated(diffComps)) then ! Set up an array of all the diffuse components @@ -1336,7 +1337,7 @@ module subroutine initDiffPrecond_diagonal(comm) ! Build frequency-dependent part of preconditioner call wall_time(t1) - allocate(P_cr%invM_diff(0:info_pre%nalm-1,info_pre%nmaps)) + allocate(P_cr(samp_group)%invM_diff(0:info_pre%nalm-1,info_pre%nmaps)) !!$OMP PARALLEL PRIVATE(mat, ind, j, i1, l, m, q, i2, k1, p1, k2, n) allocate(mat(npre,npre), ind(npre)) do j = 1, info_pre%nmaps @@ -1345,15 +1346,18 @@ module subroutine initDiffPrecond_diagonal(comm) call info_pre%i2lm(i1, l, m) mat = 0.d0 do q = 1, numband + if (.not. data(q)%cr_active) cycle call data(q)%info%lm2i(l,m,i2) if (i2 == -1) cycle if (j > data(q)%info%nmaps) cycle do k1 = 1, npre p1 => diffComps(k1)%p + if (.not. p1%active_samp_group(samp_group)) cycle if (l > p1%lmax_amp) cycle if (j > p1%nmaps) cycle do k2 = 1, npre p2 => diffComps(k2)%p + if (.not. p2%active_samp_group(samp_group)) cycle if (l > p2%lmax_amp) cycle if (j > p2%nmaps) cycle mat(k1,k2) = mat(k1,k2) + & @@ -1365,20 +1369,20 @@ module subroutine initDiffPrecond_diagonal(comm) end do n = 0 - allocate(P_cr%invM_diff(i1,j)%comp2ind(npre)) - P_cr%invM_diff(i1,j)%comp2ind = -1 + allocate(P_cr(samp_group)%invM_diff(i1,j)%comp2ind(npre)) + P_cr(samp_group)%invM_diff(i1,j)%comp2ind = -1 do k1 = 1, npre if (mat(k1,k1) > 0.d0) then n = n+1 ind(n) = k1 - P_cr%invM_diff(i1,j)%comp2ind(k1) = n + P_cr(samp_group)%invM_diff(i1,j)%comp2ind(k1) = n end if end do - P_cr%invM_diff(i1,j)%n = n - allocate(P_cr%invM_diff(i1,j)%ind(n)) - allocate(P_cr%invM_diff(i1,j)%M0(n,n), P_cr%invM_diff(i1,j)%M(n,n)) - P_cr%invM_diff(i1,j)%ind = ind(1:n) - P_cr%invM_diff(i1,j)%M0 = mat(ind(1:n),ind(1:n)) + P_cr(samp_group)%invM_diff(i1,j)%n = n + allocate(P_cr(samp_group)%invM_diff(i1,j)%ind(n)) + allocate(P_cr(samp_group)%invM_diff(i1,j)%M0(n,n), P_cr(samp_group)%invM_diff(i1,j)%M(n,n)) + P_cr(samp_group)%invM_diff(i1,j)%ind = ind(1:n) + P_cr(samp_group)%invM_diff(i1,j)%M0 = mat(ind(1:n),ind(1:n)) end do !!$OMP END DO end do @@ -1390,9 +1394,9 @@ module subroutine initDiffPrecond_diagonal(comm) end subroutine initDiffPrecond_diagonal - module subroutine initDiffPrecond_pseudoinv(comm) + module subroutine initDiffPrecond_pseudoinv(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group integer(i4b) :: i, i1, i2, j, k1, k2, q, l, m, n real(dp) :: t1, t2 @@ -1402,7 +1406,7 @@ module subroutine initDiffPrecond_pseudoinv(comm) real(dp), allocatable, dimension(:,:) :: mat if (npre == 0) return - if (allocated(P_cr%invM_diff)) return + if (allocated(P_cr(samp_group)%invM_diff)) return if (.not. allocated(diffComps)) then ! Set up an array of all the diffuse components @@ -1422,10 +1426,10 @@ module subroutine initDiffPrecond_pseudoinv(comm) ! Allocate space for pseudo-inverse of U call wall_time(t1) - allocate(P_cr%invM_diff(0:lmax_pre,info_pre%nmaps)) + allocate(P_cr(samp_group)%invM_diff(0:lmax_pre,info_pre%nmaps)) do j = 1, info_pre%nmaps do l = 0, lmax_pre - allocate(P_cr%invM_diff(l,j)%M(npre,numband+npre)) + allocate(P_cr(samp_group)%invM_diff(l,j)%M(npre,numband+npre)) end do end do @@ -1468,7 +1472,7 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) !self%invM = self%invM0 do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n > 0) P_cr%invM_diff(i,j)%M = P_cr%invM_diff(i,j)%M0 + if (P_cr(samp_group)%invM_diff(i,j)%n > 0) P_cr(samp_group)%invM_diff(i,j)%M = P_cr(samp_group)%invM_diff(i,j)%M0 end do end do @@ -1484,11 +1488,11 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) if (.not. diffComps(k2)%p%active_samp_group(samp_group)) cycle do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) - q = P_cr%invM_diff(i,j)%comp2ind(k2) + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) + q = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k2) if (p /= -1 .and. q /= -1) then - alm(i,j) = P_cr%invM_diff(i,j)%M(q,p) + alm(i,j) = P_cr(samp_group)%invM_diff(i,j)%M(q,p) else alm(i,j) = 0.d0 end if @@ -1501,10 +1505,10 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) !stop do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) - q = P_cr%invM_diff(i,j)%comp2ind(k2) - if (p /= -1 .and. q /= -1) P_cr%invM_diff(i,j)%M(q,p) = alm(i,j) + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) + q = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k2) + if (p /= -1 .and. q /= -1) P_cr(samp_group)%invM_diff(i,j)%M(q,p) = alm(i,j) end do end do end do @@ -1524,11 +1528,11 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) if (.not. diffComps(k2)%p%active_samp_group(samp_group)) cycle do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) - q = P_cr%invM_diff(i,j)%comp2ind(k2) + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) + q = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k2) if (p /= -1 .and. q /= -1) then - alm(i,j) = P_cr%invM_diff(i,j)%M(p,q) + alm(i,j) = P_cr(samp_group)%invM_diff(i,j)%M(p,q) else alm(i,j) = 0.d0 end if @@ -1539,10 +1543,10 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) ! if (info_pre%myid == 0) write(*,*) 'd', k1, k2, alm(4,1) do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) - q = P_cr%invM_diff(i,j)%comp2ind(k2) - if (p /= -1 .and. q /= -1) P_cr%invM_diff(i,j)%M(p,q) = alm(i,j) + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) + q = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k2) + if (p /= -1 .and. q /= -1) P_cr(samp_group)%invM_diff(i,j)%M(p,q) = alm(i,j) end do end do end do @@ -1556,8 +1560,8 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) ! Nullify temperature block if only polarization if (only_pol) then do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,1)%n == 0) cycle - P_cr%invM_diff(i,1)%M = 0.d0 + if (P_cr(samp_group)%invM_diff(i,1)%n == 0) cycle + P_cr(samp_group)%invM_diff(i,1)%M = 0.d0 end do end if @@ -1575,9 +1579,9 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) !end if if (l <= diffComps(k1)%p%lmax_amp) then do j = 1, info_pre%nmaps - if (P_cr%invM_diff(i,j)%n == 0) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) - if (p > 0) P_cr%invM_diff(i,j)%M(p,p) = P_cr%invM_diff(i,j)%M(p,p) + 1.d0 + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) + if (p > 0) P_cr(samp_group)%invM_diff(i,j)%M(p,p) = P_cr(samp_group)%invM_diff(i,j)%M(p,p) + 1.d0 end do end if end do @@ -1589,13 +1593,13 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) ! Nullify elements that are not involved in current sample group do j = 1, info_pre%nmaps do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle do k1 = 1, npre if (diffComps(k1)%p%active_samp_group(samp_group)) cycle - p = P_cr%invM_diff(i,j)%comp2ind(k1) + p = P_cr(samp_group)%invM_diff(i,j)%comp2ind(k1) if (p == -1) cycle - P_cr%invM_diff(i,j)%M(p,:) = 0.d0 - P_cr%invM_diff(i,j)%M(:,p) = 0.d0 + P_cr(samp_group)%invM_diff(i,j)%M(p,:) = 0.d0 + P_cr(samp_group)%invM_diff(i,j)%M(:,p) = 0.d0 end do end do end do @@ -1609,10 +1613,10 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) do j = 1, nmaps_pre do i = 0, info_pre%nalm-1 call info_pre%i2lm(i, l, m) - n = P_cr%invM_diff(i,j)%n + n = P_cr(samp_group)%invM_diff(i,j)%n if (n > 0) then allocate(W(n), ind(n)) - call get_eigenvalues(P_cr%invM_diff(i,j)%M, W) + call get_eigenvalues(P_cr(samp_group)%invM_diff(i,j)%M, W) W_ref = minval(abs(W)) cond(l) = max(cond(l), maxval(abs(W/W_ref))) W_min(l) = min(W_min(l), minval(W)) @@ -1644,8 +1648,8 @@ module subroutine updateDiffPrecond_diagonal(samp_group, force_update) call wall_time(t1) do j = 1, nmaps_pre do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n > 0) then - if (any(P_cr%invM_diff(i,j)%M /= 0.d0)) call invert_matrix_with_mask(P_cr%invM_diff(i,j)%M) + if (P_cr(samp_group)%invM_diff(i,j)%n > 0) then + if (any(P_cr(samp_group)%invM_diff(i,j)%M /= 0.d0)) call invert_matrix_with_mask(P_cr(samp_group)%invM_diff(i,j)%M) end if end do end do @@ -1713,8 +1717,8 @@ module subroutine updateDiffPrecond_pseudoinv(samp_group, force_update) end do ! Store pseudo-inverse of U - call compute_pseudo_inverse(mat, P_cr%invM_diff(l,j)%M) - !P_cr%invM_diff(l,j)%M = transpose(mat) + call compute_pseudo_inverse(mat, P_cr(samp_group)%invM_diff(l,j)%M) + !P_cr(samp_group)%invM_diff(l,j)%M = transpose(mat) end do end do deallocate(mat) @@ -2075,6 +2079,7 @@ module function evalDiffuseBand(self, band, amp_in, pix, alm_out, det) result(re m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else + write(*,*) "skal ikke vaere her, eval", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() @@ -2147,6 +2152,7 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else + write(*,*) "skal ikke vaere her, proj", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask if (data(band)%B(d)%p%almFromConv) call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() @@ -2162,15 +2168,16 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) end function projectDiffuseBand - module subroutine applyDiffPrecond(x) + module subroutine applyDiffPrecond(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group select case (trim(precond_type)) case ("diagonal") - call applyDiffPrecond_diagonal(x) + call applyDiffPrecond_diagonal(x, samp_group) case ("pseudoinv") - call applyDiffPrecond_pseudoinv(x) + call applyDiffPrecond_pseudoinv(x, samp_group) case default call report_error("Preconditioner type not supported: "//trim(precond_type)) end select @@ -2178,9 +2185,10 @@ module subroutine applyDiffPrecond(x) end subroutine applyDiffPrecond - module subroutine applyDiffPrecond_diagonal(x) + module subroutine applyDiffPrecond_diagonal(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group integer(i4b) :: i, j, k, l, m, nmaps real(dp), allocatable, dimension(:,:) :: alm @@ -2205,9 +2213,9 @@ module subroutine applyDiffPrecond_diagonal(x) ! Multiply with preconditioner do j = 1, nmaps_pre do i = 0, info_pre%nalm-1 - if (P_cr%invM_diff(i,j)%n == 0) cycle - y(P_cr%invM_diff(i,j)%ind,i,j) = & - & matmul(P_cr%invM_diff(i,j)%M, y(P_cr%invM_diff(i,j)%ind,i,j)) + if (P_cr(samp_group)%invM_diff(i,j)%n == 0) cycle + y(P_cr(samp_group)%invM_diff(i,j)%ind,i,j) = & + & matmul(P_cr(samp_group)%invM_diff(i,j)%M, y(P_cr(samp_group)%invM_diff(i,j)%ind,i,j)) end do end do @@ -2230,9 +2238,10 @@ module subroutine applyDiffPrecond_diagonal(x) end subroutine applyDiffPrecond_diagonal - module subroutine applyDiffPrecond_pseudoinv(x) + module subroutine applyDiffPrecond_pseudoinv(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x + integer(i4b), intent(in) :: samp_group integer(i4b) :: i, ii, j, k, l, m, p, q, qq, nmaps, npre_int real(dp) :: t1, t2 @@ -2280,7 +2289,7 @@ module subroutine applyDiffPrecond_pseudoinv(x) do q = 1, npre_int qq = ind_pre(q) do p = 1, nmaps - invN_x%alm(i,p) = invN_x%alm(i,p) + P_cr%invM_diff(l,p)%M(qq,k) * y(q,j,p) + invN_x%alm(i,p) = invN_x%alm(i,p) + P_cr(samp_group)%invM_diff(l,p)%M(qq,k) * y(q,j,p) end do end do end do @@ -2309,7 +2318,7 @@ module subroutine applyDiffPrecond_pseudoinv(x) do q = 1, npre_int qq = ind_pre(q) do p = 1, nmaps - z(q,j,p) = z(q,j,p) + P_cr%invM_diff(l,p)%M(qq,k) * invN_x%alm(i,p) + z(q,j,p) = z(q,j,p) + P_cr(samp_group)%invM_diff(l,p)%M(qq,k) * invN_x%alm(i,p) end do end do end do @@ -2335,13 +2344,13 @@ module subroutine applyDiffPrecond_pseudoinv(x) w2 = 0.d0 do j = 1, npre_int do k = 1, npre_int - w2(j) = w2(j) + P_cr%invM_diff(l,p)%M(ind_pre(k),numband+ind_pre(j))*w(k) + w2(j) = w2(j) + P_cr(samp_group)%invM_diff(l,p)%M(ind_pre(k),numband+ind_pre(j))*w(k) end do end do w = 0.d0 do j = 1, npre_int do k = 1, npre_int - w(j) = w(j) + P_cr%invM_diff(l,p)%M(ind_pre(j),numband+ind_pre(k))*w2(k) + w(j) = w(j) + P_cr(samp_group)%invM_diff(l,p)%M(ind_pre(j),numband+ind_pre(k))*w2(k) end do end do z(:,i,p) = z(:,i,p) + w @@ -2890,8 +2899,9 @@ module subroutine sampleDiffuseSpecInd(self, cpar, handle, id, iter) end subroutine sampleDiffuseSpecInd - module subroutine print_precond_mat + module subroutine print_precond_mat(samp_group) implicit none + integer(i4b), intent(in) :: samp_group integer(i4b) :: l, m, i, j, p real(dp), allocatable, dimension(:) :: W @@ -2906,18 +2916,18 @@ module subroutine print_precond_mat call info_pre%lm2i(l, 0, i) write(*,*) write(*,*) l - do j = 1, size(P_cr%invM_diff(i,p)%M(j,:),1) - write(*,*) real(P_cr%invM_diff(i,p)%M(j,:),sp) + do j = 1, size(P_cr(samp_group)%invM_diff(i,p)%M(j,:),1) + write(*,*) real(P_cr(samp_group)%invM_diff(i,p)%M(j,:),sp) end do - allocate(W(P_cr%invM_diff(i,p)%n)) - call get_eigenvalues(P_cr%invM_diff(i,p)%M, W) + allocate(W(P_cr(samp_group)%invM_diff(i,p)%n)) + call get_eigenvalues(P_cr(samp_group)%invM_diff(i,p)%M, W) write(58,*) l, real(W,sp) deallocate(W) end do else allocate(mat(npre,npre)) do l = 0, info_pre%lmax - mat = matmul(P_cr%invM_diff(l,p)%M, transpose(P_cr%invM_diff(l,p)%M)) + mat = matmul(P_cr(samp_group)%invM_diff(l,p)%M, transpose(P_cr(samp_group)%invM_diff(l,p)%M)) write(*,*) write(*,*) l do j = 1, npre diff --git a/commander3/src/comm_md_comp_mod.f90 b/commander3/src/comm_md_comp_mod.f90 index 8cfe079a9..85ca40d24 100644 --- a/commander3/src/comm_md_comp_mod.f90 +++ b/commander3/src/comm_md_comp_mod.f90 @@ -80,6 +80,7 @@ function constructor_md(cpar, id, id_abs, band, label, mu, rms, def) result(c) c%nside_def = 0 c%fwhm_def = 0.d0 c%mono_prior_type = 'none' + c%latmask = -1.d0 precond_type = cpar%cg_precond call get_tokens(cpar%output_comps, ",", comp_label, n) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 2caf35775..487c083a5 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -1497,9 +1497,9 @@ subroutine compute_symmetric_beam(band, glon, glat, T, bl, beamfile) end subroutine compute_symmetric_beam - subroutine initPtsrcPrecond(comm) + subroutine initPtsrcPrecond(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt real(dp) :: t1, t2, t3, t4 @@ -1511,13 +1511,13 @@ subroutine initPtsrcPrecond(comm) if (ncomp_pre == 0) return if (.not. recompute_ptsrc_precond) return if (.not. apply_ptsrc_precond) return - if (allocated(P_cr%invM_src)) deallocate(P_cr%invM_src) + if (allocated(P_cr(samp_group)%invM_src)) deallocate(P_cr(samp_group)%invM_src) call mpi_comm_rank(comm, myid, ierr) ! Build frequency-dependent part of preconditioner call wall_time(t1) - allocate(P_cr%invM_src(1,nmaps_pre)) + allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) allocate(mat(npre,npre), mat2(npre,npre)) do j = 1, nmaps_pre @@ -1662,8 +1662,8 @@ subroutine initPtsrcPrecond(comm) call invert_matrix_with_mask(mat2) call wall_time(t4) if (myid_pre == 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) - allocate(P_cr%invM_src(1,j)%M(npre,npre)) - P_cr%invM_src(1,j)%M = mat2 + allocate(P_cr(samp_group)%invM_src(1,j)%M(npre,npre)) + P_cr(samp_group)%invM_src(1,j)%M = mat2 end if end do call wall_time(t2) @@ -1680,15 +1680,16 @@ subroutine updatePtsrcPrecond(samp_group) implicit none integer(i4b), intent(in) :: samp_group - call initPtsrcPrecond(comm_pre) + call initPtsrcPrecond(comm_pre, samp_group) end subroutine updatePtsrcPrecond - subroutine applyPtsrcPrecond(x) + subroutine applyPtsrcPrecond(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x - + integer(i4b), intent(in) :: samp_group + integer(i4b) :: i, j, k, l, m, nmaps logical(lgt) :: skip real(dp), allocatable, dimension(:,:) :: amp @@ -1725,7 +1726,7 @@ subroutine applyPtsrcPrecond(x) ! Multiply with preconditioner do j = 1, nmaps_pre - y(:,j) = matmul(P_cr%invM_src(1,j)%M, y(:,j)) + y(:,j) = matmul(P_cr(samp_group)%invM_src(1,j)%M, y(:,j)) end do ! Reformat y(npre,nmaps) structure back into linear array diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index b9f16b7b7..810509821 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -291,7 +291,8 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) call cr_computeRHS(cpar%operation, cpar%resamp_CMB, cpar%only_pol,& & handle, handle_noise, mask, samp_group, rhs) call update_status(status, "init_precond1") - call initPrecond(cpar%comm_chain) + if (.not. allocated(P_cr)) allocate(P_cr(cpar%cg_num_user_samp_groups)) + call initPrecond(cpar%comm_chain, samp_group) call update_status(status, "init_precond2") call solve_cr_eqn_by_CG(cpar, samp_group, x, rhs, stat) call cr_x2amp(samp_group, x) @@ -388,12 +389,12 @@ subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups) end subroutine sample_all_amps_by_CG - subroutine initPrecond(comm) + subroutine initPrecond(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm - call initDiffPrecond(comm) - call initPtsrcPrecond(comm) - call initTemplatePrecond(comm) + integer(i4b), intent(in) :: comm, samp_group + call initDiffPrecond(comm, samp_group) + call initPtsrcPrecond(comm, samp_group) + call initTemplatePrecond(comm, samp_group) end subroutine initPrecond subroutine add_to_complist(c) diff --git a/commander3/src/comm_template_comp_mod.f90 b/commander3/src/comm_template_comp_mod.f90 index ec3729462..79b5f4213 100644 --- a/commander3/src/comm_template_comp_mod.f90 +++ b/commander3/src/comm_template_comp_mod.f90 @@ -335,9 +335,9 @@ subroutine initTemplateHDF(self, cpar, hdffile, hdfpath) end subroutine initTemplateHDF - subroutine initTemplatePrecond(comm) + subroutine initTemplatePrecond(comm, samp_group) implicit none - integer(i4b), intent(in) :: comm + integer(i4b), intent(in) :: comm, samp_group integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, m, n, p, p1, p2, n1, n2, myid, ierr, cnt real(dp) :: t1, t2 @@ -348,7 +348,7 @@ subroutine initTemplatePrecond(comm) real(dp), allocatable, dimension(:,:) :: mat, mat2 if (npre == 0) return - if (allocated(P_cr%invM_temp)) return + if (allocated(P_cr(samp_group)%invM_temp)) return call mpi_comm_rank(comm, myid, ierr) @@ -401,7 +401,7 @@ subroutine initTemplatePrecond(comm) call mpi_reduce(mat, mat2, size(mat2), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) ! Invert matrix to finalize preconditioner - allocate(P_cr%invM_temp(1,1)) + allocate(P_cr(samp_group)%invM_temp(1,1)) if (myid == 0) then ! Multiply with sqrtS from left side i1 = 0 @@ -445,8 +445,8 @@ subroutine initTemplatePrecond(comm) end do ! Invert matrix to finalize preconditioner call invert_matrix_with_mask(mat2) - allocate(P_cr%invM_temp(1,1)%M(npre,npre)) - P_cr%invM_temp(1,1)%M = mat2 + allocate(P_cr(samp_group)%invM_temp(1,1)%M(npre,npre)) + P_cr(samp_group)%invM_temp(1,1)%M = mat2 end if deallocate(mat,mat2) @@ -463,10 +463,11 @@ subroutine updateTemplatePrecond(samp_group) end subroutine updateTemplatePrecond - subroutine applyTemplatePrecond(x) + subroutine applyTemplatePrecond(x, samp_group) implicit none real(dp), dimension(:), intent(inout) :: x - + integer(i4b), intent(in) :: samp_group + integer(i4b) :: i, j, k, l, m, nmaps logical(lgt) :: skip real(dp), allocatable, dimension(:,:) :: amp @@ -501,7 +502,7 @@ subroutine applyTemplatePrecond(x) end do ! Multiply with preconditioner - y = matmul(P_cr%invM_temp(1,1)%M, y) + y = matmul(P_cr(samp_group)%invM_temp(1,1)%M, y) ! Reformat y(npre) structure back into linear array l = 1 diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index f2696ef5e..a9d63791e 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -416,7 +416,7 @@ program commander ! Sample linear parameters with CG search; loop over CG sample groups !call output_FITS_sample(cpar, 1000+iter, .true.) - if (cpar%sample_signal_amplitudes .and. iter > 1) then + if (cpar%sample_signal_amplitudes .and. iter > 0) then ! Do CG group sampling call sample_all_amps_by_CG(cpar, handle, handle_noise) From 379d9ff74aa0049d1afe1f7ca0fd512f8bc4bef4 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 15 Jan 2025 12:08:57 +0100 Subject: [PATCH 064/171] Updated defaults --- .../bands/HFI/HFI_217-1_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-2_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-3_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-4_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-5_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-6_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-7_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_217-8_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-1_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-2_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-3_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-4_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-5_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-6_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-7_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_353-8_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_545_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../bands/HFI/HFI_857_DIRBE_n4096.defaults | 41 +++++++++++++++++++ .../dust/dust_DIRBE_localsampler.defaults | 4 +- .../dust/dust_coldtab_DIRBE.defaults | 4 +- .../components/dust/dust_hotPAH.defaults | 4 +- .../dust/dust_hotPAH_localsampler.defaults | 4 +- .../freefree/freefree_DIRBE2.defaults | 10 ++--- 23 files changed, 751 insertions(+), 13 deletions(-) create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-1_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-2_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-3_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-4_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_545_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_857_DIRBE_n4096.defaults diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_DIRBE_n4096.defaults new file mode 100644 index 000000000..13aa6a156 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-1 single-horn map parameters +BAND_LABEL&&& = 217-1 +BAND_INSTRUMENT_LABEL&&& = 217-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-1_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-1_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-1_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_DIRBE_n4096.defaults new file mode 100644 index 000000000..867b332d9 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-2 single-horn map parameters +BAND_LABEL&&& = 217-2 +BAND_INSTRUMENT_LABEL&&& = 217-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-2_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-2_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-2_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_DIRBE_n4096.defaults new file mode 100644 index 000000000..9d26b6f9a --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-3 single-horn map parameters +BAND_LABEL&&& = 217-3 +BAND_INSTRUMENT_LABEL&&& = 217-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-3_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-3_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-3.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-3_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_DIRBE_n4096.defaults new file mode 100644 index 000000000..3be8a4d2c --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-4 single-horn map parameters +BAND_LABEL&&& = 217-4 +BAND_INSTRUMENT_LABEL&&& = 217-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-4_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-4_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-4.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-4_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE_n4096.defaults new file mode 100644 index 000000000..09cd72dc0 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-5 single-horn map parameters +BAND_LABEL&&& = 217-5 +BAND_INSTRUMENT_LABEL&&& = 217-5 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-5_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-5_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-5_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-5_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE_n4096.defaults new file mode 100644 index 000000000..40ddabad1 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-6 single-horn map parameters +BAND_LABEL&&& = 217-6 +BAND_INSTRUMENT_LABEL&&& = 217-6 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-6_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-6_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-6_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-6_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE_n4096.defaults new file mode 100644 index 000000000..78f1dd46a --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-7 single-horn map parameters +BAND_LABEL&&& = 217-7 +BAND_INSTRUMENT_LABEL&&& = 217-7 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-7_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-7_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-7_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-7_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE_n4096.defaults new file mode 100644 index 000000000..84288ebf4 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 217-8 single-horn map parameters +BAND_LABEL&&& = 217-8 +BAND_INSTRUMENT_LABEL&&& = 217-8 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_217-8_bmap_n4096_uK_noDipole_zodicorr.fits +BAND_NOISEFILE&&& = npipe6v20_217-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_217-8_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_217x217_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-8_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_217-8_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE_n4096.defaults new file mode 100644 index 000000000..3ff924a91 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-1 single-horn map parameters +BAND_LABEL&&& = 353-1 +BAND_INSTRUMENT_LABEL&&& = 353-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-1_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-1_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-1_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-1_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE_n4096.defaults new file mode 100644 index 000000000..34d491a92 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-2 single-horn map parameters +BAND_LABEL&&& = 353-2 +BAND_INSTRUMENT_LABEL&&& = 353-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-2_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-2_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-2_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-2_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE_n4096.defaults new file mode 100644 index 000000000..6eb14cdda --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-3 single-horn map parameters +BAND_LABEL&&& = 353-3 +BAND_INSTRUMENT_LABEL&&& = 353-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-3_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-3_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-3_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-3_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-3_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE_n4096.defaults new file mode 100644 index 000000000..7a9d5c6a7 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-4 single-horn map parameters +BAND_LABEL&&& = 353-4 +BAND_INSTRUMENT_LABEL&&& = 353-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-4_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-4_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-4_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-4_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-4_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE_n4096.defaults new file mode 100644 index 000000000..be4d66426 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-5 single-horn map parameters +BAND_LABEL&&& = 353-5 +BAND_INSTRUMENT_LABEL&&& = 353-5 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-5_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-5_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-5_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-5_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-5_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE_n4096.defaults new file mode 100644 index 000000000..ca9699304 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-6 single-horn map parameters +BAND_LABEL&&& = 353-6 +BAND_INSTRUMENT_LABEL&&& = 353-6 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-6_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-6_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-6_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-6_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-6_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE_n4096.defaults new file mode 100644 index 000000000..268a7b2b9 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-7 single-horn map parameters +BAND_LABEL&&& = 353-7 +BAND_INSTRUMENT_LABEL&&& = 353-7 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-7_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-7_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-7_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-7.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-7_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE_n4096.defaults new file mode 100644 index 000000000..dea11efc5 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 353-8 single-horn map parameters +BAND_LABEL&&& = 353-8 +BAND_INSTRUMENT_LABEL&&& = 353-8 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = npipe6v20_353-8_bmap_n4096_uK_noDipole_zodicorr_CIBcorr.fits +BAND_NOISEFILE&&& = npipe6v20_353-8_bmap_n4096_uK_rms_hack.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = npipe6v20_353-8_misspix.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_353x353_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = powlaw_tilt # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-8.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_353-8_bmap_n2048_uK_rms_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_DIRBE_n4096.defaults new file mode 100644 index 000000000..57a8bd016 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 545 GHz (full frequency) parameters +BAND_LABEL&&& = 545 +BAND_INSTRUMENT_LABEL&&& = 545 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10009 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = none #Must be set +BAND_NOISEFILE&&& = none #Must be set +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = none #Must be set +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_545x545_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 545 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = firas all cmb +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = HFI_SkyMap_545-BPassCorrected_2048_R4.00_full_rms_uK_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857_DIRBE_n4096.defaults new file mode 100644 index 000000000..58793e838 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857_DIRBE_n4096.defaults @@ -0,0 +1,41 @@ +# 857 GHz (full frequency) parameters +BAND_LABEL&&& = 857 +BAND_INSTRUMENT_LABEL&&& = 857 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = none #Must be set +BAND_NOISEFILE&&& = none #Must be set +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = none #Must be set +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_dx12v2_857x857_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 857 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0. +BAND_GAIN_CALIB_COMP&&& = firas all cmb +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = HFI_SkyMap_857-BPassCorrected_2048_R4.00_full_rms_uK_1deg_n256_v2.fits +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults index d6c8c33e5..e565381cf 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults @@ -18,7 +18,7 @@ COMP_BETA_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites n COMP_BETA_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region COMP_BETA_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region COMP_BETA_ALMSAMP_INIT&& = init_alm_dust_beta_hke.dat -COMP_BETA_MASK&& = mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_BETA_MASK&& = fullsky mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. COMP_BETA_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) COMP_BETA_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) COMP_BETA_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler @@ -53,7 +53,7 @@ COMP_T_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites npro COMP_T_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region COMP_T_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region COMP_T_ALMSAMP_INIT&& = init_alm_dust_T_hke.dat -COMP_T_MASK&& = mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_MASK&& = fullsky mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. COMP_T_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) COMP_T_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) COMP_T_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults index 3018554df..0f441b384 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults @@ -29,7 +29,7 @@ COMP_CL_L_PIVOT&& = 50 # Pivot multipole COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta COMP_CL_DEFAULT_AMP_E&& = 500 COMP_CL_DEFAULT_AMP_B&& = 500 -COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_T&& = 10.d0 COMP_CL_DEFAULT_BETA_E&& = 10.d0 COMP_CL_DEFAULT_BETA_B&& = 10.d0 @@ -52,7 +52,7 @@ COMP_BETA_SMOOTHING_SCALE&& = 1 COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} COMP_T_DEFAULT&& = 16. -COMP_T_PRIOR_UNI_LOW&& = 8. +COMP_T_PRIOR_UNI_LOW&& = 7.5 COMP_T_PRIOR_UNI_HIGH&& = 20. COMP_T_PRIOR_GAUSS_MEAN&& = 18 COMP_T_PRIOR_GAUSS_RMS&& = 1. diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults index 15a3fd375..1a36c3963 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults @@ -20,7 +20,7 @@ COMP_NU_REF_P&& = 857 COMP_MASK&& = fullsky COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky -COMP_CL_TYPE&& = power_law gauss # {none, single_l, binned,power_law, exp} +COMP_CL_TYPE&& = gauss power_law gauss # {none, single_l, binned,power_law, exp} COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} COMP_CL_BETA_PRIOR_MEAN&& = -0.0 COMP_CL_BETA_PRIOR_RMS&& = 0.0 @@ -28,7 +28,7 @@ COMP_CL_L_PIVOT&& = 50 # Pivot multipole COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta COMP_CL_DEFAULT_AMP_E&& = 500 COMP_CL_DEFAULT_AMP_B&& = 500 -COMP_CL_DEFAULT_BETA_T&& = 0.d0 +COMP_CL_DEFAULT_BETA_T&& = 10.d0 COMP_CL_DEFAULT_BETA_E&& = 10.d0 COMP_CL_DEFAULT_BETA_B&& = 10.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_localsampler.defaults index 7431687cd..7c05d587b 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_hotPAH_localsampler.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_localsampler.defaults @@ -18,7 +18,7 @@ COMP_BETA_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites n COMP_BETA_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region COMP_BETA_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region COMP_BETA_ALMSAMP_INIT&& = init_alm_hotPAH_beta_hke.dat -COMP_BETA_MASK&& = mask_DIRBE_hotdust_chisq_n2048_v2.fits fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_BETA_MASK&& = fullsky mask_DIRBE_hotdust_chisq_n2048_v2.fits fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. COMP_BETA_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) COMP_BETA_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) COMP_BETA_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler @@ -53,7 +53,7 @@ COMP_T_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites npro COMP_T_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region COMP_T_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region COMP_T_ALMSAMP_INIT&& = init_alm_hotPAH_T_hke.dat -COMP_T_MASK&& = mask_DIRBE_hotdust_chisq_n2048_v2.fits fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_MASK&& = fullsky mask_DIRBE_hotdust_chisq_n2048_v2.fits fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. COMP_T_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) COMP_T_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) COMP_T_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults index af13dd478..2c38e1a31 100644 --- a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults +++ b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults @@ -12,7 +12,7 @@ COMP_MONOPOLE_PRIOR&& = monopole-dipole:mask_ff_monoprior_bp10_n1024_TQU COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1500 COMP_LMAX_IND&& = 0 -1 # Use input map as is -COMP_OUTPUT_FWHM&& = 30 # arcmin +COMP_OUTPUT_FWHM&& = 15 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 COMP_NU_MAX&& = 1d30 @@ -25,20 +25,20 @@ COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} COMP_CL_BETA_PRIOR_MEAN&& = -0.0 COMP_CL_BETA_PRIOR_RMS&& = 0.0 COMP_CL_L_PIVOT&& = 50 1 # Pivot multipole -COMP_CL_DEFAULT_AMP_T&& = 1e3 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_T&& = 1e8 # D_l = amp * (l/lpivot)**beta COMP_CL_DEFAULT_AMP_E&& = 50 COMP_CL_DEFAULT_AMP_B&& = 50 -COMP_CL_DEFAULT_BETA_T&& = 2.0d0 -0.5d0 +COMP_CL_DEFAULT_BETA_T&& = 0. 2.0d0 -0.5d0 COMP_CL_DEFAULT_BETA_E&& = -0.5d0 COMP_CL_DEFAULT_BETA_B&& = -0.5d0 -COMP_CL_DEFAULT_THETA_T&& = 30.d0 # equivalent to BETA for CL_TYPE = gauss (see synch), BP8.0 used 90.d0 +COMP_CL_DEFAULT_THETA_T&& = 19.d0 # equivalent to BETA for CL_TYPE = gauss (see synch), BP8.0 used 90.d0 COMP_CL_DEFAULT_THETA_E&& = 90.d0 COMP_CL_DEFAULT_THETA_B&& = 90.d0 COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 1500 COMP_AMP_INPUT_MAP&& = init_ff_amp_BP8.1_v1.fits -COMP_AMP_PRIOR_MAP&& = ff_prior_mean_2015_median_90arc.fits none +COMP_AMP_PRIOR_MAP&& = none ff_prior_mean_2015_median_90arc.fits none COMP_AMP_PRIOR_LMAX&& = -1 COMP_EM_POLTYPE&& = 1 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} From cece5051707bd20c93c70039e46f5f2491d04a35 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 15 Jan 2025 12:12:42 +0100 Subject: [PATCH 065/171] Added missing CMB defaults file --- .../components/cmb/cmb_DIRBE.defaults | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults new file mode 100644 index 000000000..67ea4d94b --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults @@ -0,0 +1,40 @@ +# CMB for LFI TOD study +COMP_LABEL&& = cmb +COMP_TYPE&& = cmb +COMP_CLASS&& = diffuse # {diffuse, ptsrc, template} +COMP_POLARIZATION&& = .true. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_NSIDE&& = 2048 +COMP_MONOPOLE_PRIOR&& = monopole-dipole:mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n2048_TQU.fits +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 4000 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 4000 +COMP_AMP_INPUT_MAP&& = init_cmb_amp_BP8.1_v1_n2048.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_LMAX_IND&& = 0 +COMP_OUTPUT_FWHM&& = 5 # arcmin +COMP_UNIT&& = uK_cmb +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 700 +COMP_NU_REF_T&& = 1 100. +COMP_NU_REF_P&& = 1 100. +COMP_CL_TYPE&& = none power_law # {none, single_l, binned, power_law} +COMP_CL_POLTYPE&& = 1 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = 0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.1 +COMP_CL_L_PIVOT&& = 20 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1000000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 1000 +COMP_CL_DEFAULT_AMP_B&& = 1000 +COMP_CL_DEFAULT_BETA_T&& = 0.d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_MASK&& = fullsky +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + From b8704a3ea5ad16940c76c0513261a103a682e2d7 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 15 Jan 2025 12:14:39 +0100 Subject: [PATCH 066/171] Added missing defaults --- .../dust/dust_coldcores_DIRBE_n4096.defaults | 69 +++++++++++++++++++ .../dust/dust_coldtab_DIRBE_n4096.defaults | 69 +++++++++++++++++++ .../dust/dust_hotPAH_n4096.defaults | 68 ++++++++++++++++++ .../dust/dust_ir_DIRBE_n4096.defaults | 68 ++++++++++++++++++ 4 files changed, 274 insertions(+) create mode 100644 commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults new file mode 100644 index 000000000..c8f0fbfb6 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults @@ -0,0 +1,69 @@ +# Cold thermal dust component +COMP_LABEL&& = dust_cores +COMP_TYPE&& = MBBtab +COMP_MBBTAB_TYPE = binned +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 4096 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 6000 +COMP_OUTPUT_FWHM&& = 5 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = power_law gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 500 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e6 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 0.5 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_AMP_INPUT_MAP&& = none init_colddust_n2048_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 6. +COMP_T_PRIOR_UNI_LOW&& = 5 +COMP_T_PRIOR_UNI_HIGH&& = 9. +COMP_T_PRIOR_GAUSS_MEAN&& = 6 +COMP_T_PRIOR_GAUSS_RMS&& = 0.1 +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults new file mode 100644 index 000000000..f3e2efcba --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults @@ -0,0 +1,69 @@ +# Cold thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBBtab +COMP_MBBTAB_TYPE = binned +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 4096 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 6000 +COMP_OUTPUT_FWHM&& = 5 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 857 +COMP_NU_REF_P&& = 857 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = power_law gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 500 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e6 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = -0.5 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_AMP_INPUT_MAP&& = none init_colddust_n2048_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 16. +COMP_T_PRIOR_UNI_LOW&& = 7.5 +COMP_T_PRIOR_UNI_HIGH&& = 20. +COMP_T_PRIOR_GAUSS_MEAN&& = 18 +COMP_T_PRIOR_GAUSS_RMS&& = 1. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults new file mode 100644 index 000000000..4be3e806f --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults @@ -0,0 +1,68 @@ +# Thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 4096 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 6000 +COMP_OUTPUT_FWHM&& = 5 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 857 +COMP_NU_REF_P&& = 857 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = power_law gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 500 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e6 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = -0.5 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_AMP_INPUT_MAP&& = none init_hotPAH_n2048_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.8 1.68 1.55 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 5.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 2.2 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 32. +COMP_T_PRIOR_UNI_LOW&& = 10. +COMP_T_PRIOR_UNI_HIGH&& = 100. +COMP_T_PRIOR_GAUSS_MEAN&& = 25. +COMP_T_PRIOR_GAUSS_RMS&& = 1. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults new file mode 100644 index 000000000..ef5196daa --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults @@ -0,0 +1,68 @@ +# Cold thermal dust component +COMP_LABEL&& = dust_ir +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 200 +COMP_NSIDE&& = 4096 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 800 +COMP_OUTPUT_FWHM&& = 45 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 5000 +COMP_NU_REF_P&& = 5000 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 10000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 400 +COMP_CL_DEFAULT_AMP_B&& = 400 +COMP_CL_DEFAULT_BETA_T&& = 45 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 800 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 1 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 80. +COMP_T_PRIOR_UNI_LOW&& = 20. +COMP_T_PRIOR_UNI_HIGH&& = 50. +COMP_T_PRIOR_GAUSS_MEAN&& = 20 +COMP_T_PRIOR_GAUSS_RMS&& = 10. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 \ No newline at end of file From 6bece0bc7efecadfaf51d5599cd2d97e81498e77 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 17 Jan 2025 13:11:13 +0100 Subject: [PATCH 067/171] Fixed alpha vs albedo bug --- .../components/dust/dust_hotPAH2.defaults | 68 ++++++++++++++++++ .../components/dust/dust_ir_DIRBE.defaults | 69 +++++++++++++++++++ .../dust/dust_ir_DIRBE_n0512.defaults | 68 ++++++++++++++++++ .../dust/dust_ir_DIRBE_n2048.defaults | 68 ++++++++++++++++++ .../dust/dust_nearby_DIRBE_alm.defaults | 67 ++++++++++++++++++ ...ust_nearby_DIRBE_alm_localsampler.defaults | 68 ++++++++++++++++++ commander3/src/comm_zodi_mod.f90 | 4 +- 7 files changed, 410 insertions(+), 2 deletions(-) create mode 100644 commander3/parameter_files/defaults/components/dust/dust_hotPAH2.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n0512.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n2048.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm_localsampler.defaults diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH2.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH2.defaults new file mode 100644 index 000000000..15a3fd375 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH2.defaults @@ -0,0 +1,68 @@ +# Thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 2048 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 6000 +COMP_OUTPUT_FWHM&& = 10 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 857 +COMP_NU_REF_P&& = 857 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = power_law gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 0.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_AMP_INPUT_MAP&& = init_hotPAH_n2048_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.8 1.68 1.55 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 5.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 2.2 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 32. +COMP_T_PRIOR_UNI_LOW&& = 10. +COMP_T_PRIOR_UNI_HIGH&& = 100. +COMP_T_PRIOR_GAUSS_MEAN&& = 25. +COMP_T_PRIOR_GAUSS_RMS&& = 1. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults new file mode 100644 index 000000000..3564fef36 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults @@ -0,0 +1,69 @@ +# Infrared thermal dust component +COMP_LABEL&& = dust_ir +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 200 +COMP_NSIDE&& = 512 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 200 +COMP_OUTPUT_FWHM&& = 42 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 5000 +COMP_NU_REF_P&& = 5000 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n0512_v2.fits fullsky + +COMP_CL_TYPE&& = gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 30000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 40.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 557 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none +COMP_AMP_PRIOR_LMAX&& = 1500 + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 1 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 80. +COMP_T_PRIOR_UNI_LOW&& = 20. +COMP_T_PRIOR_UNI_HIGH&& = 50. +COMP_T_PRIOR_GAUSS_MEAN&& = 20 +COMP_T_PRIOR_GAUSS_RMS&& = 10. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 \ No newline at end of file diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n0512.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n0512.defaults new file mode 100644 index 000000000..1cf5acc2b --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n0512.defaults @@ -0,0 +1,68 @@ +# Cold thermal dust component +COMP_LABEL&& = dust_ir +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 200 +COMP_NSIDE&& = 512 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 1500 +COMP_OUTPUT_FWHM&& = 45 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 5000 +COMP_NU_REF_P&& = 5000 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 100 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 400 +COMP_CL_DEFAULT_AMP_B&& = 400 +COMP_CL_DEFAULT_BETA_T&& = 45 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 1500 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 1 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 80. +COMP_T_PRIOR_UNI_LOW&& = 20. +COMP_T_PRIOR_UNI_HIGH&& = 50. +COMP_T_PRIOR_GAUSS_MEAN&& = 20 +COMP_T_PRIOR_GAUSS_RMS&& = 10. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 \ No newline at end of file diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n2048.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n2048.defaults new file mode 100644 index 000000000..a4089a77b --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n2048.defaults @@ -0,0 +1,68 @@ +# Cold thermal dust component +COMP_LABEL&& = dust_ir +COMP_TYPE&& = MBBtab +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 200 +COMP_NSIDE&& = 2048 +COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 1000 +COMP_OUTPUT_FWHM&& = 42 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 5000 +COMP_NU_REF_P&& = 5000 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 400 +COMP_CL_DEFAULT_AMP_B&& = 400 +COMP_CL_DEFAULT_BETA_T&& = 42.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 1000 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = -1 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 1 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 80. +COMP_T_PRIOR_UNI_LOW&& = 20. +COMP_T_PRIOR_UNI_HIGH&& = 50. +COMP_T_PRIOR_GAUSS_MEAN&& = 20 +COMP_T_PRIOR_GAUSS_RMS&& = 10. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + +COMP_SED_PRIOR&& = 0 \ No newline at end of file diff --git a/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm.defaults b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm.defaults new file mode 100644 index 000000000..4c2695fcb --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm.defaults @@ -0,0 +1,67 @@ +# Nearby dust component +COMP_LABEL&& = dust_near +COMP_TYPE&& = MBB +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 2048 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 1000 +COMP_OUTPUT_FWHM&& = 14 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 857 +COMP_NU_REF_P&& = 857 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_DIRBE_chisq_n2048_v2.fits fullsky + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 1000 +COMP_AMP_INPUT_MAP&& = dust_nearby_edenhofer_total_scaled.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 10 + +COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = none init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.4 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 1 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 16. +COMP_T_PRIOR_UNI_LOW&& = 10. +COMP_T_PRIOR_UNI_HIGH&& = 35. +COMP_T_PRIOR_GAUSS_MEAN&& = 18 +COMP_T_PRIOR_GAUSS_RMS&& = 1. +COMP_T_SMOOTHING_SCALE&& = 1 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = none init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + diff --git a/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm_localsampler.defaults new file mode 100644 index 000000000..2281ba39a --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE_alm_localsampler.defaults @@ -0,0 +1,68 @@ +# New Local sampling parameters, 'dust' +COMP_BETA_INT_LMAX&& = 10 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_BETA_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_BETA_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_BETA_INT_PRIOR_MEAN&& = 1.56 # prior sampler mean; Planck 2015 +COMP_BETA_INT_PRIOR_RMS&& = 0.03 # prior sampler RMS; Planck 2015 +COMP_BETA_INT_PIXREG_PRIORS&& = none +COMP_BETA_POL_PIXREG_PRIORS&& = none +COMP_BETA_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_BETA_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_BETA_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_BETA_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_BETA_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_BETA_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_BETA_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_BETA_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_BETA_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_BETA_ALMSAMP_INIT&& = init_alm_dust_beta_hke.dat +COMP_BETA_MASK&& = fullsky mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_BETA_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_BETA_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_BETA_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_BETA_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_BETA_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_BETA_INT_FIX_PIXREG&& = none +COMP_BETA_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_BETA_POL_FIX_PIXREG&& = none +COMP_BETA_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_BETA_PIXREG_INITVALUE_MAP&& = none +COMP_BETA_COMBINED_MONOPOLE_SAMPLING&& = .false. +COMP_BETA_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_BETA_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_BETA_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_BETA_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_BETA_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + +COMP_T_INT_LMAX&& = 10 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_T_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_T_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_INT_PIXREG_PRIORS&& = none +COMP_T_POL_PIXREG_PRIORS&& = none +COMP_T_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_T_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_T_ALMSAMP_INIT&& = init_alm_dust_T_hke.dat +COMP_T_MASK&& = fullsky mask_DIRBE_colddust_chisq_n2048_v2.fits fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_T_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_T_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_INT_FIX_PIXREG&& = none +COMP_T_POL_FIX_PIXREG&& = none +COMP_T_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_T_PIXREG_INITVALUE_MAP&& = none +COMP_T_COMBINED_MONOPOLE_SAMPLING&& = .false. +COMP_T_CORRELATION_CONVERGENCE_SAMPLING&& = .false. diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 460429770..c95b4e23b 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -127,7 +127,7 @@ subroutine initialize_zodi_mod(cpar) call get_tokens(cpar%zs_samp_group_bands(i), ',', tokens, ntok) do j = 1, ntok k = get_string_index(band_labels, tokens(j)) - zodi_model%sampgroup_active_band(k,i) = .true. + zodi_model%sampgroup_active_band(k,i) = .true. end do call samp_group2stat(cpar, i, zodi_model%sampgroup_active_band(:,i), zodi_model%theta_stat(:,i)) end do @@ -1024,7 +1024,7 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) ind = zodi_model%get_par_ind(comp=zodi_model%comps(c), em_string=comp_param(2)) stat(ind) = 0 end if - else if (trim(label(1:2)) == 'al') then + else if (trim(label(1:2)) == 'al' .and. trim(label) /= 'alpha') then ! Albedo call get_tokens(label, '@', comp_param, num=n) if (n == 1) then From c4215861fbc8a49fea7e4416e8509144f0656d2f Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 17 Jan 2025 15:44:28 +0100 Subject: [PATCH 068/171] Fixed MCMC Gibbs bug when running with zodi --- commander3/src/commander.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index a9d63791e..083fb31fe 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -259,7 +259,7 @@ program commander iter = first_sample first = .true. first_zodi = .true. - modfact = 1; if (cpar%enable_TOD_analysis .and. cpar%sample_zodi .and. (cpar%sample_signal_amplitudes .or. cpar%sample_specind)) modfact = 2 + modfact = 1; if (cpar%enable_TOD_analysis .and. cpar%sample_zodi .and. (cpar%sample_signal_amplitudes .or. cpar%sample_specind .or. cpar%mcmc_num_samp_groups > 0)) modfact = 2 !---------------------------------------------------------------------------------- ! Part of Simulation routine !---------------------------------------------------------------------------------- From e20d515b7a4a930b077ed391f6321793614f672d Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 18 Jan 2025 20:34:12 +0100 Subject: [PATCH 069/171] Bug fixes for static component --- commander3/src/comm_zodi_mod.f90 | 7 ++++++- commander3/src/comm_zodi_samp_mod.f90 | 10 ++++++---- commander3/src/commander.f90 | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index c95b4e23b..cab608ded 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -1264,7 +1264,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod else scattering = .false. do i = 1, zodi_model%n_comps - if (zodi_model%comps(i)%c%emissivity(tod%id) > EPS) then + if (zodi_model%comps(i)%c%albedo(tod%id) > EPS) then scattering = .true. exit end if @@ -1365,6 +1365,11 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod end if call get_dust_grain_temperature(comp_LOS(k)%R, comp_LOS(k)%T, model%T_0, model%delta) +!!$ write(*,*) tod%info%myid, k, size(comp_LOS(k)%T), size(tod%zodi_B_nu_spl_obj(det)%x), size(tod%zodi_B_nu_spl_obj(det)%y) +!!$ write(*,*) tod%info%myid, k, comp_LOS(k)%T +!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%x +!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%y +!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%y2 call splint_simple_multi(tod%zodi_b_nu_spl_obj(det), comp_LOS(k)%T, comp_LOS(k)%B_nu) call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 2403b949d..6156936c9 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -791,12 +791,14 @@ subroutine downsamp_invariant_structs(cpar) ! Allocate other downsampled quantities with same shape ndownsamp = size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ndownsamp)) - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_scat(ndownsamp, zodi_model%n_comps)) - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_therm(ndownsamp, zodi_model%n_comps)) + if (.not. allocated(data(i)%tod%scans(scan)%d(j)%downsamp_scat)) then + allocate (data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ndownsamp)) + allocate (data(i)%tod%scans(scan)%d(j)%downsamp_scat(ndownsamp, zodi_model%n_comps)) + allocate (data(i)%tod%scans(scan)%d(j)%downsamp_therm(ndownsamp, zodi_model%n_comps)) ! Compute downsampled pointing in various coordinates - allocate(data(i)%tod%scans(scan)%d(j)%downsamp_point(ndownsamp,5)) + allocate(data(i)%tod%scans(scan)%d(j)%downsamp_point(ndownsamp,5)) + end if do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) !!$ call pix2ang_ring(data(i)%tod%nside, data(i)%tod%scans(scan)%d(j)%downsamp_pix(k), lat, lon) !!$ phi = phi * 180.d0/pi diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 083fb31fe..de9b7dadb 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -344,10 +344,12 @@ program commander ! if (.true. .and. cpar%include_tod_zodi) then call timer%start(TOT_ZODI_SAMP) call project_and_downsamp_sky(cpar) + call downsamp_invariant_structs(cpar) if (first_zodi) then ! in the first tod gibbs iter we precompute timeinvariant downsampled quantities - call downsamp_invariant_structs(cpar) call precompute_lowres_zodi_lookups(cpar) + else + call apply_zodi_glitch_mask(cpar) end if !!$ do i = 1, zodi_model%n_comps @@ -357,9 +359,10 @@ program commander !!$ write(*,*) 'emissivity', data(i)%tod%zodi_emissivity, data(i)%tod%zodi_albedo !!$ end do + call compute_downsamp_zodi(cpar, zodi_model) if (first_zodi) then - call sample_linear_zodi(cpar, handle, iter, zodi_model, verbose=.true.) + !call sample_linear_zodi(cpar, handle, iter, zodi_model, verbose=.true.) call compute_downsamp_zodi(cpar, zodi_model) call create_zodi_glitch_mask(cpar, handle) first_zodi = .false. @@ -378,7 +381,7 @@ program commander end select ! Sample stationary zodi components with 2D model - !call sample_static_zodi_map(cpar, handle) + call sample_static_zodi_map(cpar, handle) !call sample_static_zodi_amps(cpar, handle) !!$ if (mod(iter-2,10) == 0) then From 19a6660c464d3cca1c70e0f88387b37010ff2f8f Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 20 Jan 2025 19:56:38 +0100 Subject: [PATCH 070/171] Fixed zodi monopole bug, disabled positivity prior --- commander3/src/comm_mh_specind_mod.f90 | 3 ++- commander3/src/comm_zodi_samp_mod.f90 | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index b0c7bba92..e89641292 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -462,7 +462,8 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) end if ! Check MH statistic - reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 .or. negative + !reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 .or. negative + reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 call mpi_bcast(reject, 1, MPI_LOGICAL, 0, data(1)%info%comm, ierr) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 6156936c9..16004fb0e 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -1160,7 +1160,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) ! Initialize active monopoles do i = 1, numband ind = zodi_model%get_par_ind(mono_band=i) - if (zodi_model%theta_stat(ind,samp_group) == 0) band_monopole(i) = get_monopole_amp(data(i)%label) + band_monopole(i) = get_monopole_amp(data(i)%label) end do if (cpar%myid_chain == 0) then @@ -1390,7 +1390,12 @@ function lnL_zodi(p) &) call wall_time(t3) !if (data(1)%tod%myid == 10) write(*,*) ' CPU2 = ', t3-t4 - + + !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'tod ', minval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)), maxval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)) + !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'sky ', minval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)), maxval((data(i)%tod%scans(scan)%d(j)%downsamp_sky)) + !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'zodi ', minval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)), maxval((data(i)%tod%scans(scan)%d(j)%downsamp_zodi)) + !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'mono ', mono + !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'noise', data(i)%tod%scans(scan)%d(j)%N_psd%sigma0 chisq = sum( & & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & From 4348a4e8bc44b090af56b16f2255316e6d6ae54c Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 23 Jan 2025 17:13:37 +0100 Subject: [PATCH 071/171] Found bug, requires changing flag arrays to 32-bit integers --- .../todscripts/dirbe/metin/dirbe_utils.py | 15 ++++-- .../dirbe/metin/write_tods_final.py | 54 +++++++++++++------ 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index ef237ef24..5fcf92e17 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -184,11 +184,16 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d lons = np.array(lons) lats = np.array(lats) dists = np.array(dists) - locs = np.array([lons, lats]) + #locs = np.array([astropy_times.mjd, lons, lats]) + x, y, z = hp.dir2vec(lons, lats, lonlat=True) + locs = np.array([astropy_times.mjd, x, y, z]) np.save(f'comet_{ci}', locs) interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) + interpolaters_comet[c]['x'] = interp1d(astropy_times.mjd, x) + interpolaters_comet[c]['y'] = interp1d(astropy_times.mjd, y) + interpolaters_comet[c]['z'] = interp1d(astropy_times.mjd, z) for a in ASTEROID_RADII: interpolaters_asteroids[a] = {} @@ -198,13 +203,17 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d astropy_times_i = astropy_times[i*1441:(i+1)*1441] eph = MPC.get_ephemeris(a, start=astropy_times_i[0], number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'], eph['Dec'], lonlat=True) + lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) lons += lon.tolist() lats += lat.tolist() lons = np.array(lons) - latss = np.array(lats) + lats = np.array(lats) + x, y, z = hp.dir2vec(lons, lats, lonlat=True) interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) + interpolaters_asteroids[a]['x'] = interp1d(astropy_times.mjd, x) + interpolaters_asteroids[a]['y'] = interp1d(astropy_times.mjd, y) + interpolaters_asteroids[a]['z'] = interp1d(astropy_times.mjd, z) return interpolaters_comet, interpolaters_asteroids @cache diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index 47a371fda..3f77a9aab 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -44,7 +44,7 @@ CIO_PATH = Path("/mn/stornext/d16/cmbco/ola/dirbe/cio") # system constants -N_PROC = multiprocessing.cpu_count() +N_PROC = multiprocessing.cpu_count() // 2 ROTATOR = hp.Rotator(coord=["E", "G"]) YDAYS = np.concatenate([np.arange(89345, 89366), np.arange(90001, 90265)]) @@ -80,7 +80,8 @@ '73P/Schwassmann–Wachmann 3':13, 'C/1989 Q1':14, 'C/1989 T1':15, - 'C/1990 K1':16, + #'C/1990 K1':16, + 'C/1989 X1':16, '1 Ceres':17, '2 Pallas':18, '4 Vesta':19, @@ -290,6 +291,8 @@ def get_yday_cio_data( # Convert unit vectors to requested nside resolution healpix pixels pix = hp.vec2pix(nside_out, *unit_vectors_gal) lon, lat = hp.pix2ang(nside_out, pix, lonlat=True) + #v_x, v_y, v_z = hp.pix2vec(nside_out, pix) + v_x, v_y, v_z = unit_vectors_gal tod = data[f"Phot{cio_band_label}"].astype(np.float64)[time_sorted_inds] @@ -309,6 +312,7 @@ def get_yday_cio_data( # Remove the iras convention color correction iras_color_corr_factor = dirbe_utils.get_iras_factor(band) flag = common_flags.copy() + print(np.unique(flag), 'Pre-planet indicies') # Get planet flags for body, radius in dirbe_utils.PLANET_RADII.items(): planet_lon = planet_interps[body]["lon"](time) @@ -328,44 +332,54 @@ def get_yday_cio_data( flag[planet_indices] += 2 ** FLAG_BITS[body] + print(np.unique(flag), 'Pre-comet indicies') # Get comet flags + np.save(f'horn_pos_{yday}', + np.array([v_x, v_y, v_z])) for body, radius in dirbe_utils.COMET_RADII.items(): if body not in FLAG_BITS.keys(): continue - comet_lon = comet_interps[body]["lon"](time) - comet_lat = comet_interps[body]["lat"](time) + comet_x = comet_interps[body]["x"](time) + comet_y = comet_interps[body]["y"](time) + comet_z = comet_interps[body]["z"](time) comet_dist = comet_interps[body]["dist"](time) if comet_dist.min() < 2: r = radius else: r = 1 - ang_dist = hp.rotator.angdist( - np.array([lon, lat]), - np.array([comet_lon, comet_lat]), - lonlat=True, + np.array([v_x, v_y, v_z]), + np.array([comet_x, comet_y, comet_z]) ) + + np.save(f'comet_pos_{yday}_{body[-6:]}', + np.array([comet_x, comet_y, comet_z])) comet_indices = ang_dist <= np.deg2rad(r) + print(np.unique(flag), f'Pre-adding {body}') flag[comet_indices] += 2 ** FLAG_BITS[body] + #print(body, (np.bitwise_and(flag, 2**FLAG_BITS[body]) > 0).sum() / len(flag)) + print(np.unique(flag), 'Pre-asteroid indicies') for body, radius in dirbe_utils.ASTEROID_RADII.items(): if body not in FLAG_BITS.keys(): continue - aster_lon = asteroid_interps[body]["lon"](time) - aster_lat = asteroid_interps[body]["lat"](time) - + aster_x = asteroid_interps[body]["x"](time) + aster_y = asteroid_interps[body]["y"](time) + aster_z = asteroid_interps[body]["z"](time) ang_dist = hp.rotator.angdist( - np.array([lon, lat]), - np.array([aster_lon, aster_lat]), - lonlat=True, + np.array([v_x, v_y, v_z]), + np.array([aster_x, aster_y, aster_z]) ) - aster_indices = ang_dist <= np.deg2rad(r) + aster_indices = ang_dist <= np.deg2rad(radius) + np.save(f'aster_pos_{yday}_{body[-6:]}', + np.array([aster_x, aster_y, aster_z])) flag[aster_indices] += 2 ** FLAG_BITS[body] - + print(np.unique(flag), "final situation") + asdf # Find which flags correspond to the detector and get the inds of those flags xs_noise_inds = (xs_noise_flags & band_bit) > 0 @@ -404,6 +418,14 @@ def get_yday_cio_data( np.split(flag, split_inds), padding=flag_padding ) + # print('Total flags:') + # test_arr = np.zeros(18) + # for i in range(18): + # test = np.bitwise_and(flags[band_label], 2**i) + # test_arr[i] = (test != 0).sum() / len(flags[band_label]) + # print(np.arange(18)) + # print(test_arr) + return YdayData( tods, pixels, From 7f9fcfd5f71233c9c06c883340e9033fc95c0d03 Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 24 Jan 2025 17:35:05 +0100 Subject: [PATCH 072/171] Fixed issues with flags, consolidated asteroids and comets. --- .../todscripts/dirbe/metin/dirbe_utils.py | 6 +- .../dirbe/metin/write_tods_final.py | 132 +++++++----------- 2 files changed, 50 insertions(+), 88 deletions(-) diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py index 5fcf92e17..3e230ae6c 100644 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ b/commander3/todscripts/dirbe/metin/dirbe_utils.py @@ -103,7 +103,7 @@ 'C/1989 Q1':2, 'C/1989 T1':2, 'C/1989 X1':15, - 'C/1990 K1':2 + 'C/1990 K1':5 } ASTEROID_RADII = { '1 Ceres':1, @@ -184,10 +184,8 @@ def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d lons = np.array(lons) lats = np.array(lats) dists = np.array(dists) - #locs = np.array([astropy_times.mjd, lons, lats]) x, y, z = hp.dir2vec(lons, lats, lonlat=True) - locs = np.array([astropy_times.mjd, x, y, z]) - np.save(f'comet_{ci}', locs) + interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index 3f77a9aab..d4204db6c 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -35,16 +35,14 @@ from scipy.interpolate import interp1d from astropy.time import Time, TimeDelta from cosmoglobe.tod_tools import TODLoader -import zodipy -# zodi_model = zodipy.Zodipy(extrapolate=True) # Path objects DIRBE_DATA_PATH = Path("/mn/stornext/d5//data/duncanwa/DIRBE/hdf_files/") BANDPASS_PATH = Path("/mn/stornext/d5/data/metins/dirbe/data/") CIO_PATH = Path("/mn/stornext/d16/cmbco/ola/dirbe/cio") # system constants -N_PROC = multiprocessing.cpu_count() // 2 +N_PROC = multiprocessing.cpu_count() // 4 ROTATOR = hp.Rotator(coord=["E", "G"]) YDAYS = np.concatenate([np.arange(89345, 89366), np.arange(90001, 90265)]) @@ -77,31 +75,26 @@ "saturn": 10, "uranus": 11, "neptune": 12, - '73P/Schwassmann–Wachmann 3':13, - 'C/1989 Q1':14, - 'C/1989 T1':15, - #'C/1990 K1':16, - 'C/1989 X1':16, - '1 Ceres':17, - '2 Pallas':18, - '4 Vesta':19, + "comets": 13, + "asteroids": 14, # Orbit and attitude flag (each observation has either of each pair turned on) - "non_definitive_attitude": 20, - # "definite_attitude": 19, - "coarse_attitude": 21, - # "fine_attitude": 21, - # "merged_attitude": 22, - # "external_uax_attitude": 23, - # "space_craft_slewing": 24, - # "space_craft_not_slewing": 25, - # "special_pointing": 26, - # "normal_pointing": 27, - #"space_craft_ascending": 28, - #"space_craft_descending": 29, - #"leading_los": 25, - #"trailing_los": 26, + "non_definitive_attitude": 15, + "coarse_attitude": 16, } +''' +The default DIRBE flags used for Commander analysis are in the defaults directory. For example, +for band 1 the default value is BAND_TOD_FLAG&&& = 2047, which includes all the radiation zone flags, +the excess noise flag, the bad data flag, and the planet flags. Currently it seems that the attitude flags +are not necessary, but they are included now for completeness. + +Only a few bands are sensitive to the infrared radiation from comets and asteroids, specifically bands 4 and 5. For these, +the flags should include the comet and asteroid flags. When summed together, these flags should be 32767 = 2**15 - 1. + +Comet flags and asteroid flags currently are set by hand, since their FWHM are not documented anywhere specifically, although +Arendt 2014 does specify that the comet tails are up to 15 degrees long when they are within 2 AU of the sun. +''' + @dataclass class YdayData: @@ -215,15 +208,15 @@ def get_yday_cio_data( bad_data_padding = padd_vals(base_padding, BAD_DATA_SENTINEL) pix_padding = padd_vals(base_padding, 0, dtype=np.int64) - flag_padding = padd_vals(base_padding, 2 ** FLAG_BITS["bad_data"], dtype=np.int16) + flag_padding = padd_vals(base_padding, 2 ** FLAG_BITS["bad_data"], dtype=np.int32) psi_padding = padd_vals(base_padding, 0, dtype=np.int64) # Get cio flags - rad_zone_flags = data["RadZone"].astype(np.int8)[time_sorted_inds] - xs_noise_flags = data["XSNoise"].astype(np.int16)[time_sorted_inds] - oa_flags = data["OA_Flags"].astype(np.int16)[time_sorted_inds] + rad_zone_flags = data["RadZone"].astype(np.int32)[time_sorted_inds] + xs_noise_flags = data["XSNoise"].astype(np.int32)[time_sorted_inds] + oa_flags = data["OA_Flags"].astype(np.int32)[time_sorted_inds] - common_flags = np.zeros_like(rad_zone_flags, dtype=np.int16) + common_flags = np.zeros_like(rad_zone_flags, dtype=np.int32) non_zero_rad_zone_inds = rad_zone_flags > 0 common_flags[non_zero_rad_zone_inds > 0] += ( 2 ** rad_zone_flags[non_zero_rad_zone_inds] @@ -291,7 +284,6 @@ def get_yday_cio_data( # Convert unit vectors to requested nside resolution healpix pixels pix = hp.vec2pix(nside_out, *unit_vectors_gal) lon, lat = hp.pix2ang(nside_out, pix, lonlat=True) - #v_x, v_y, v_z = hp.pix2vec(nside_out, pix) v_x, v_y, v_z = unit_vectors_gal tod = data[f"Phot{cio_band_label}"].astype(np.float64)[time_sorted_inds] @@ -312,7 +304,6 @@ def get_yday_cio_data( # Remove the iras convention color correction iras_color_corr_factor = dirbe_utils.get_iras_factor(band) flag = common_flags.copy() - print(np.unique(flag), 'Pre-planet indicies') # Get planet flags for body, radius in dirbe_utils.PLANET_RADII.items(): planet_lon = planet_interps[body]["lon"](time) @@ -332,13 +323,8 @@ def get_yday_cio_data( flag[planet_indices] += 2 ** FLAG_BITS[body] - print(np.unique(flag), 'Pre-comet indicies') # Get comet flags - np.save(f'horn_pos_{yday}', - np.array([v_x, v_y, v_z])) for body, radius in dirbe_utils.COMET_RADII.items(): - if body not in FLAG_BITS.keys(): - continue comet_x = comet_interps[body]["x"](time) comet_y = comet_interps[body]["y"](time) comet_z = comet_interps[body]["z"](time) @@ -353,18 +339,11 @@ def get_yday_cio_data( np.array([comet_x, comet_y, comet_z]) ) - np.save(f'comet_pos_{yday}_{body[-6:]}', - np.array([comet_x, comet_y, comet_z])) comet_indices = ang_dist <= np.deg2rad(r) - print(np.unique(flag), f'Pre-adding {body}') - flag[comet_indices] += 2 ** FLAG_BITS[body] - #print(body, (np.bitwise_and(flag, 2**FLAG_BITS[body]) > 0).sum() / len(flag)) + flag[comet_indices] += 2 ** FLAG_BITS["comets"] - print(np.unique(flag), 'Pre-asteroid indicies') for body, radius in dirbe_utils.ASTEROID_RADII.items(): - if body not in FLAG_BITS.keys(): - continue aster_x = asteroid_interps[body]["x"](time) aster_y = asteroid_interps[body]["y"](time) aster_z = asteroid_interps[body]["z"](time) @@ -375,11 +354,7 @@ def get_yday_cio_data( ) aster_indices = ang_dist <= np.deg2rad(radius) - np.save(f'aster_pos_{yday}_{body[-6:]}', - np.array([aster_x, aster_y, aster_z])) - flag[aster_indices] += 2 ** FLAG_BITS[body] - print(np.unique(flag), "final situation") - asdf + flag[aster_indices] += 2 ** FLAG_BITS["asteroids"] # Find which flags correspond to the detector and get the inds of those flags xs_noise_inds = (xs_noise_flags & band_bit) > 0 @@ -393,18 +368,7 @@ def get_yday_cio_data( pixels[band_label] = padd_array_gaps( np.split(pix, split_inds), padding=pix_padding ) - # nus, weights = dirbe_utils.get_bandpass(band) - # zodi_tods = zodi_model.get_emission_pix( - # freq=nus, - # weights=weights, - # pixels=pixels[band_label], - # obs_time=Time(time[0], format="mjd"), - # obs_pos=sat_pos * u.au, - # nside=nside_out, - # coord_in="G", - # ) - - # tods[band_label] = zodi_tods.value + tods[band_label] = padd_array_gaps( np.split(tod * iras_color_corr_factor if color_corr else tod, split_inds), padding=bad_data_padding, @@ -418,14 +382,6 @@ def get_yday_cio_data( np.split(flag, split_inds), padding=flag_padding ) - # print('Total flags:') - # test_arr = np.zeros(18) - # for i in range(18): - # test = np.bitwise_and(flags[band_label], 2**i) - # test_arr[i] = (test != 0).sum() / len(flags[band_label]) - # print(np.arange(18)) - # print(test_arr) - return YdayData( tods, pixels, @@ -451,6 +407,27 @@ def padd_vals( def get_oa_flags(oa_flags: np.ndarray, yday: int) -> np.ndarray: + """ + Function which converts the OA flags to the new flag system. The new flag system is as follows: + - The OA flags are split into 7 bits, each bit corresponding to a different flag. + From the DIRBE Explanatory supplement, these are + - Bit 0: 1 if non-definitive attitude, 0 if definitive attitude + - Bit 1: 1 if coarse attitude, 0 if fine attitude + - Bit 2: 1 if merged attitude, 0 if external UAX attitude + - Bit 3: 1 if spacecraft slewing, 0 if spacecraft not slewing + - Bit 4: 1 if special pointing, 0 if normal pointing + - Bit 5: 1 when spacecraft in ascending portion of COBE orbit, + i.e., moving up toward North Ecliptic Pole, + 0 when spacecraft in descending portion of COBE orbit, + i.e., moving down toward South Ecliptic Pole + - Bit 6: 1 if leading LOS, 0 if trailing LOS + - Bit 7: Not used + + Currently, only the non-definitive attitude is considered a gamechanger, so flags with value of 15 (2**15 = 32768) + need to be removed. All others are set to 2**16 = 65536 + + Default assumptions si taht the attitude solutions are the highest values. + """ new_bits = iter( [ bit @@ -460,15 +437,13 @@ def get_oa_flags(oa_flags: np.ndarray, yday: int) -> np.ndarray: ) flags = np.zeros_like(oa_flags) for cio_bit, bit1 in zip(range(7), new_bits): - bit2 = next(new_bits) inds = (oa_flags & 2**cio_bit) > 0 flags[inds] += 2**bit1 - flags[~inds] += 2**bit2 - return flags def get_flag_sum(flags: list[str]) -> int: + if flags: return sum(2 ** FLAG_BITS[flag] for flag in flags) return 0 @@ -670,19 +645,8 @@ def main() -> None: "uranus", "neptune", "non_definitive_attitude", - # "definite_attitude", "coarse_attitude", - # "fine_attitude", - # "merged_attitude", - # "external_uax_attitude", - # "space_craft_slewing", - # "space_craft_not_slewing", "special_pointing", - # "normal_pointing", - # "space_craft_ascending", - # "space_craft_descending", - # "leading_los", - # "trailing_los", ] ) print(f"flag bit sum: {flag_bit_sum}") From 056b0f5516ff48f812ec57283bbe0a3ba604dc27 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 27 Jan 2025 14:04:30 +0100 Subject: [PATCH 073/171] fixed cmake compilation of merge --- cmake/projects/commander3.cmake | 1 - commander3/src/comm_tod_quiet_smod.f90 | 6 ++-- commander3/src/get_deps | 42 -------------------------- 3 files changed, 3 insertions(+), 46 deletions(-) delete mode 100755 commander3/src/get_deps diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 9d5b18b1f..86e4af7d1 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -64,7 +64,6 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_tod_lfi_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_lfi_smod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_hfi_mod.f90 - ${COMMANDER3_SOURCE_DIR}/comm_tod_cr_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_gain_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_gain_smod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_noise_mod.f90 diff --git a/commander3/src/comm_tod_quiet_smod.f90 b/commander3/src/comm_tod_quiet_smod.f90 index 767ae18b4..0fc71c2e7 100644 --- a/commander3/src/comm_tod_quiet_smod.f90 +++ b/commander3/src/comm_tod_quiet_smod.f90 @@ -274,15 +274,15 @@ end function constructor_quiet if (sample_rel_bandpass) then !call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true., init_s_bp_prop=.true.) - call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call sd%init_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then ! call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true., init_s_sky_prop=.true.) - call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call sd%init_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else ! call sd%init_differential(self, i, map_sky, procmask, procmask2, & ! & init_s_bp=.true.) - call init_scan_data_singlehorn(sd, self, i, map_sky, procmask, procmask2, init_s_bp=.true.) + call sd%init_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) diff --git a/commander3/src/get_deps b/commander3/src/get_deps deleted file mode 100755 index cfde50276..000000000 --- a/commander3/src/get_deps +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -declare -A blacklist - -declare -A srcs_lower -for srcfile in "$@"; do - srcs_lower[${srcfile,,}]=$srcfile -done - -for srcfile in "$@"; do - objfile="${srcfile%%.*}.o" - declare -A seen - used=($(grep '^\s*use ' "$srcfile" | while read line; do - toks=($line) - dep=${toks[1]} - echo ${dep,,} - done)) - used+=($(grep '^\s*submodule' "$srcfile" | while read line; do - if [[ $line =~ submodule\ *\(([^ ]*)\) ]]; then - dep=${BASH_REMATCH[1]} - echo ${dep,,} - fi - done)) - deps=($(for dep in "${used[@]}"; do - if [[ ${seen[$dep]} ]]; then continue; fi - if [[ ! ${srcs_lower[$dep.f90]} && ! ${srcs_lower[$dep.f90.in]} ]]; then continue; fi - #if [[ ! -f "$dep.f90" && ! -f "$dep.f90.in" ]]; then continue; fi - seen[$dep]=1 - # Would ideally just output $dep.o, but need to make sure we get the case on disk right - k=${srcs_lower[$dep.f90]} - if [[ $k ]]; then - odep=${k/.f90/} - else - k=${srcs_lower[$dep.f90.in} - odep=${k/.f90.in/} - fi - echo $odep.o - done)) - #echo "$objfile : ${deps[@]}" - if (( ${#deps[@]} > 0 )); then - echo "$(printf "%-27s" $objfile) : ${deps[@]}" - fi -done From e32b2b89775c5e66818e2c179917563efbef520b Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 28 Jan 2025 16:27:49 +0100 Subject: [PATCH 074/171] Updated DIRBE flags --- .../bands/DIRBE/DIRBE_01_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_02_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_03_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_04_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_05_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_06_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_07_CIO_512.defaults | 4 +- .../bands/DIRBE/DIRBE_08_CIO_512.defaults | 2 +- commander3/src/comm_tod_mod.f90 | 6 ++- .../dirbe/metin/write_tods_final.py | 45 ++++++++++++++++++- 10 files changed, 63 insertions(+), 18 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults index 2ffcc5fc3..8970bce6d 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 10239 # All planets except Neptune/Uranus. Also comets BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 01_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults index b5dffed7d..d252bcebd 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 10239 # All planets except Neptune/Uranus. Also comets BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 02_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_02_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults index 09d6a5568..ce82d2424 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults @@ -42,7 +42,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 10239 # All planets except Neptune/Uranus. Also comets BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 03_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -67,4 +67,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_03_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0 BAND_TOD_ZODI_ALBEDO&&& = 0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults index f6c04a3bb..8738adddf 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 26623 # All planets except Neptune/Uranus. Also comets and asteroids BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 04_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_04_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.99740908486652979d0,0.35926451958350442d0,0.35926451958350442d0,0.35926451958350442d0,1.0675116768340536d0,1.0675116768340536d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults index ca9627649..8d06a24a6 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 26623 # All planets except Neptune/Uranus. Also comets and asteroids BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 05_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06_n512_v2.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.95766914805948866d0,1.0127926948497732d0,1.0127926948497732d0,0.35926451958350442d0,1.0608768682182081d0,1.0608768682182081d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults index a5211f20a..abe6d2df6 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 26623 # All planets except Neptune/Uranus. Also comets and asteroids BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 06_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06_n512_v2.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .true. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .true. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults index cce1e4deb..6644a2aa9 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 157695 # All planets except Neptune/Uranus. Also comets and asteroids. Glitch-related flags included BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 07_A BAND_TOD_INIT_FROM_HDF&&& = default @@ -66,4 +66,4 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_07_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.73338832616768868d0,1.2539242027824944d0,1.2539242027824944d0,1.2539242027824944d0,0.87266361378785184d0,0.87266361378785184d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 -BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. \ No newline at end of file +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults index 1f4257b9f..84ede897b 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults @@ -41,7 +41,7 @@ BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 1 BAND_TOD_END_SCANID&&& = 285 BAND_TOD_TOT_NUMSCAN&&& = 285 -BAND_TOD_FLAG&&& = 2047 # Don't mask Uranus and Neptune, 8191 +BAND_TOD_FLAG&&& = 157695 # All planets except Neptune/Uranus. Also comets and asteroids. Glitch-related flags included BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_DETECTOR_LIST&&& = 08_A BAND_TOD_INIT_FROM_HDF&&& = default diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index f3bb8a399..0fc040dec 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -2964,7 +2964,11 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) rms = rms + res(i)**2 n = n + 1 end do - rms = sqrt(rms/(n-1)) + if (n <= 1) then + rms = 0 + else + rms = sqrt(rms/(n-1)) + end if ! write(*,*) 'a' ! Get full-sky mask diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/metin/write_tods_final.py index d4204db6c..ce2039bad 100644 --- a/commander3/todscripts/dirbe/metin/write_tods_final.py +++ b/commander3/todscripts/dirbe/metin/write_tods_final.py @@ -21,7 +21,7 @@ from dataclasses import dataclass import itertools from pathlib import Path -from datetime import timedelta +from datetime import timedelta, datetime import multiprocessing import time @@ -42,7 +42,8 @@ CIO_PATH = Path("/mn/stornext/d16/cmbco/ola/dirbe/cio") # system constants -N_PROC = multiprocessing.cpu_count() // 4 +N_PROC = multiprocessing.cpu_count() // 2 +N_PROC = 2 ROTATOR = hp.Rotator(coord=["E", "G"]) YDAYS = np.concatenate([np.arange(89345, 89366), np.arange(90001, 90265)]) @@ -80,6 +81,7 @@ # Orbit and attitude flag (each observation has either of each pair turned on) "non_definitive_attitude": 15, "coarse_attitude": 16, + "glitch": 17, } ''' @@ -93,6 +95,10 @@ Comet flags and asteroid flags currently are set by hand, since their FWHM are not documented anywhere specifically, although Arendt 2014 does specify that the comet tails are up to 15 degrees long when they are within 2 AU of the sun. + +Flag glitch, bit 17 or 131072, should only apply to bands 7 and 8, since these +bands are especially sensitivie to cosmic ray hits, and it affects the gain +and/or baseline over very short timescales. ''' @@ -325,6 +331,8 @@ def get_yday_cio_data( # Get comet flags for body, radius in dirbe_utils.COMET_RADII.items(): + #if (band < 4) | (band < 7): + # continue comet_x = comet_interps[body]["x"](time) comet_y = comet_interps[body]["y"](time) comet_z = comet_interps[body]["z"](time) @@ -344,6 +352,8 @@ def get_yday_cio_data( flag[comet_indices] += 2 ** FLAG_BITS["comets"] for body, radius in dirbe_utils.ASTEROID_RADII.items(): + #if (band < 4) | (band < 7): + # continue aster_x = asteroid_interps[body]["x"](time) aster_y = asteroid_interps[body]["y"](time) aster_z = asteroid_interps[body]["z"](time) @@ -364,6 +374,34 @@ def get_yday_cio_data( bad_data_inds = tod <= BAD_DATA_SENTINEL flag[bad_data_inds] += 2 ** FLAG_BITS["bad_data"] + # Large glitch-rate related excitations + # Applied for both 7 and 8, since they have the same detector material, + # Ge:Ga. These were determined by hand by looking at residual maps per + # day, and should be automated in the future. + if (band == 7) | (band == 8): + t = np.arange(len(flag)) + scan_no = file_number + 1 + if (scan_no == 90): + glitch_inds = ((t > 270_000) & (t < 275_000)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + if (scan_no == 91): + glitch_inds = ((t > 273_500) & (t < 273_750)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + if (scan_no == 93): + glitch_inds = ((t > 272_000) & (t < 273_000)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + if (scan_no == 118): + glitch_inds = ((t > 211_900) & (t < 212_100)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + if (scan_no == 131): + glitch_inds = ((t > 553_500) & (t < 554_125)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + if (scan_no == 181): + glitch_inds = ((t > 270_000) & (t < 275_000)) + flag[glitch_inds] += 2**FLAG_BITS["glitch"] + + + # padd tods, pix and flags to remove gaps in data pixels[band_label] = padd_array_gaps( np.split(pix, split_inds), padding=pix_padding @@ -382,6 +420,8 @@ def get_yday_cio_data( np.split(flag, split_inds), padding=flag_padding ) + print(yday, datetime.now()) + return YdayData( tods, pixels, @@ -580,6 +620,7 @@ def write_to_commander_tods( def main() -> None: + print(datetime.now()) time_delta = timedelta(hours=1) files = range(N_CIO_FILES) nside_out = 512 From 693a9368ab49aa94a1c53fdd79de11d6d1599675 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 28 Jan 2025 18:21:15 +0100 Subject: [PATCH 075/171] Added parameter files for 1 degree, low resolution run --- .../defaults/bands/planck2015_1deg.defaults | 42 +++++++ .../ame/ame_planck2015_1deg.defaults | 96 +++++++++++++++ .../cmb/cmb_planck2015_1deg.defaults | 30 +++++ .../cmb/cmb_relquad_planck2015_1deg.defaults | 14 +++ .../components/co/co_planck2015_1deg.defaults | 29 +++++ .../dust/dust_planck2015_1deg.defaults | 67 ++++++++++ .../freefree_planck2015_1deg.defaults | 72 +++++++++++ ...free_planck2015_1deg_localsampler.defaults | 57 +++++++++ .../synch/synch_planck2015_1deg.defaults | 96 +++++++++++++++ .../defaults/planck2015_1deg.defaults | 114 ++++++++++++++++++ 10 files changed, 617 insertions(+) create mode 100644 commander3/parameter_files/defaults/bands/planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults create mode 100644 commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults create mode 100644 commander3/parameter_files/defaults/planck2015_1deg.defaults diff --git a/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults b/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults new file mode 100644 index 000000000..d444ba7e3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/planck2015_1deg.defaults @@ -0,0 +1,42 @@ +#Generic Planck 2015 1deg default parameters + +BAND_LABEL&&& = 030 +BAND_INSTRUMENT_LABEL&&& = 030 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 256 +BAND_LMAX&&& = 750 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 +BAND_MASKFILE&&& = fullsky +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = beam_60arcmin.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n0256.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = LFI +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 28.4 +BAND_SAMP_BANDPASS&&& = .false. +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0.1 +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband + +BAND_TOD_TYPE&&& = none + +BAND_MAPFILE&&& = init_tod_map_030_n512_BP8.1_v1.fits +BAND_NOISEFILE&&& = init_tod_rms_030_n512_BP8.1_v1.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_BANDPASSFILE&&& = LFI_instrument_v4.h5 diff --git a/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults new file mode 100644 index 000000000..b4739b12b --- /dev/null +++ b/commander3/parameter_files/defaults/components/ame/ame_planck2015_1deg.defaults @@ -0,0 +1,96 @@ +# AME component +COMP_LABEL&& = ame1 +COMP_TYPE&& = spindust +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 22.8 +COMP_NU_REF_P&& = 22.8 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_ame1_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_NU_P_NU_MIN&& = 20 # Lowest frequency for index estimation in GHz +COMP_NU_P_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_NU_P_INPUT_MAP&& = init_ame1_nup_rc2_n256_v03.fits +COMP_NU_P_DEFAULT&& = 19 +COMP_NU_P_PRIOR_UNI_LOW&& = 10 +COMP_NU_P_PRIOR_UNI_HIGH&& = 70 +COMP_NU_P_PRIOR_GAUSS_MEAN&& = 19 +COMP_NU_P_PRIOR_GAUSS_RMS&& = 0. # 0.1 +COMP_NU_P_SMOOTHING_SCALE&& = 0 +COMP_NU_P_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + + +# New Local sampling parameters, 'ame' +COMP_NU_P_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_INT_LNLTYPE&& = prior # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_NU_P_INT_PRIOR_MEAN&& = 19 # prior sampler mean; Planck 2015 +COMP_NU_P_INT_PRIOR_RMS&& = 0.0 # prior sampler RMS; Planck 2015 +COMP_NU_P_INT_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_NU_P_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_NU_P_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_NU_P_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_ALMSAMP_INIT&& = init_alm_dust_beta.dat +COMP_NU_P_MASK&& = fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_NU_P_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_NU_P_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_NU_P_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_INT_FIX_PIXREG&& = none +COMP_NU_P_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_POL_FIX_PIXREG&& = none +COMP_NU_P_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_NU_P_PIXREG_INITVALUE_MAP&& = none +COMP_NU_P_COMBINED_MONOPOLE_SAMPLING&& = .true. +COMP_NU_P_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_NU_P_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_NU_P_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_NU_P_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_NU_P_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults new file mode 100644 index 000000000..569ae1fd6 --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_planck2015_1deg.defaults @@ -0,0 +1,30 @@ +# CMB for Planck 2015 1deg +COMP_LABEL&& = cmb +COMP_TYPE&& = cmb +COMP_CLASS&& = diffuse # {diffuse, ptsrc, template} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none + +COMP_LMAX_IND&& = 0 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_cmb +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 1 100. +COMP_NU_REF_P&& = 1 100. +COMP_CL_TYPE&& = none power_law # {none, single_l, binned, power_law} +COMP_MASK&& = fullsky +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = none default + diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults new file mode 100644 index 000000000..f339a4f2c --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_planck2015_1deg.defaults @@ -0,0 +1,14 @@ +# CMB relativistic quadrupole correction +COMP_LABEL&& = relquad +COMP_TYPE&& = cmb_relquad +COMP_CLASS&& = template +COMP_POLARIZATION&& = .false. +#COMP_CG_SCALE&& = 1.d0 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_PRIOR_GAUSS_MEAN&& = 1.d0 +COMP_PRIOR_GAUSS_RMS&& = 0.d0 +COMP_DEFAULT_AMPLITUDE&& = 1.d0 +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def.txt +COMP_INIT_FROM_HDF&& = none diff --git a/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults new file mode 100644 index 000000000..6febcff97 --- /dev/null +++ b/commander3/parameter_files/defaults/components/co/co_planck2015_1deg.defaults @@ -0,0 +1,29 @@ +# Line emission component +COMP_LABEL&& = co100 +COMP_TYPE&& = line +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_L_APOD&& = 750 +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = Kkm/s +COMP_NU_REF_T&& = 115.27 +COMP_NU_REF_P&& = 115.27 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_BAND_REF&& = 100-1 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky +COMP_MONOPOLE_PRIOR&& = none +COMP_CL_TYPE&& = none +COMP_LINE_TEMPLATE&& = /mn/stornext/d5/data/metins/dirbe/data/co100_line_template_DIRBE_v1.dat +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits +COMP_AMP_PRIOR_MAP&& = none +COMP_INIT_FROM_HDF&& = none diff --git a/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults new file mode 100644 index 000000000..67058c461 --- /dev/null +++ b/commander3/parameter_files/defaults/components/dust/dust_planck2015_1deg.defaults @@ -0,0 +1,67 @@ +# Thermal dust component +COMP_LABEL&& = dust +COMP_TYPE&& = MBB +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_MASK&& = fullsky +COMP_INDMASK&& = none + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_dust_amp_BP8.1_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_BETA_NU_MIN&& = 20 # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = init_dust_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = 1.56 1.68 1.55 +COMP_BETA_PRIOR_UNI_LOW&& = 0.4 +COMP_BETA_PRIOR_UNI_HIGH&& = 3.0 +COMP_BETA_PRIOR_GAUSS_MEAN&& = 1.56 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 # 0.1 +COMP_BETA_SMOOTHING_SCALE&& = 0 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + +COMP_T_DEFAULT&& = 18. +COMP_T_PRIOR_UNI_LOW&& = 10. +COMP_T_PRIOR_UNI_HIGH&& = 35. +COMP_T_PRIOR_GAUSS_MEAN&& = 18.5 +COMP_T_PRIOR_GAUSS_RMS&& = 0. +COMP_T_SMOOTHING_SCALE&& = 0 +COMP_T_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_INPUT_MAP&& = init_dust_T_BP8.1_v1.fits +COMP_T_NU_MIN&& = 150 # Lowest frequency for index estimation in GHz +COMP_T_NU_MAX&& = 1000 # Highest frequency for index estimation in GHz + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults new file mode 100644 index 000000000..d3de02d44 --- /dev/null +++ b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg.defaults @@ -0,0 +1,72 @@ +# freefree component --------------------------------------------------------------------- +COMP_LABEL&& = ff +COMP_TYPE&& = freefreeEM +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 150 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_LMAX_IND&& = -1 # Use input map as is +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 22.8 +COMP_NU_REF_P&& = 22.8 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky +COMP_CL_TYPE&& = none +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 1 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e3 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 50 +COMP_CL_DEFAULT_AMP_B&& = 50 +COMP_CL_DEFAULT_BETA_T&& = 2.0d0 -0.5d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_CL_DEFAULT_THETA_T&& = 30.d0 # equivalent to BETA for CL_TYPE = gauss (see synch), BP8.0 used 90.d0 +COMP_CL_DEFAULT_THETA_E&& = 90.d0 +COMP_CL_DEFAULT_THETA_B&& = 90.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 1500 +COMP_AMP_INPUT_MAP&& = init_ff_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = init_ff_rc2_n256_v03.fits +COMP_AMP_PRIOR_LMAX&& = -1 + +COMP_EM_POLTYPE&& = 1 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_EM_INPUT_MAP&& = init_ff_EM_rc2_n256_v03.fits +COMP_EM_SMOOTHING_SCALE&& = 0 +COMP_EM_DEFAULT&& = 1. +COMP_EM_PRIOR_UNI_LOW&& = 1.d-6 +COMP_EM_PRIOR_UNI_HIGH&& = 1.d6 +COMP_EM_PRIOR_GAUSS_MEAN&& = 1. +COMP_EM_PRIOR_GAUSS_RMS&& = 0. +COMP_EM_NU_MIN&& = 0. # Lowest frequency for index estimation in GHz +COMP_EM_NU_MAX&& = 80. # Highest frequency for index estimation in GHz + +COMP_T_E_POLTYPE&& = 1 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_T_E_INPUT_MAP&& = init_ff_T_e_rc2_n256_v03.fits +COMP_T_E_SMOOTHING_SCALE&& = 0 +COMP_T_E_DEFAULT&& = 7000. +COMP_T_E_PRIOR_UNI_LOW&& = 1200. +COMP_T_E_PRIOR_UNI_HIGH&& = 12000. +COMP_T_E_PRIOR_GAUSS_MEAN&& = 7000. +COMP_T_E_PRIOR_GAUSS_RMS&& = 0. +COMP_T_E_NU_MIN&& = 0. # Lowest frequency for index estimation in GHz +COMP_T_E_NU_MAX&& = 217. # Highest frequency for index estimation in GHz +COMP_T_E_INT_PIXREG_PRIORS&& = none +COMP_T_E_POL_PIXREG_PRIORS&& = none + +COMP_T_E_ALMSAMP_INIT&& = none + +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults new file mode 100644 index 000000000..6db104749 --- /dev/null +++ b/commander3/parameter_files/defaults/components/freefree/freefree_planck2015_1deg_localsampler.defaults @@ -0,0 +1,57 @@ +# New Local sampling parameters. 'freefree, ff' +COMP_EM_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_EM_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_EM_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_EM_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_EM_INT_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_EM_POL_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_EM_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_EM_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_EM_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_EM_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_EM_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_EM_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_EM_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_EM_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_EM_MASK&& = fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_EM_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_EM_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_EM_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_EM_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_EM_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_EM_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_EM_INT_FIX_PIXREG&& = none +COMP_EM_POL_FIX_PIXREG&& = none +COMP_EM_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_EM_PIXREG_INITVALUE_MAP&& = none +COMP_EM_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_EM_COMBINED_MONOPOLE_SAMPLING&& = .false. + +COMP_T_E_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_E_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_E_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_E_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_T_E_INT_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_E_POL_PIXREG&& = single_pix # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_T_E_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_T_E_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_T_E_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_E_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_T_E_INT_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_E_POL_NPROP_INIT&& = 1000 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_T_E_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_T_E_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_T_E_MASK&& = fullsky # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_T_E_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_T_E_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_T_E_INT_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_E_POL_PROPLEN_INIT&& = 5.d-2 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_T_E_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_E_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_T_E_INT_FIX_PIXREG&& = none +COMP_T_E_POL_FIX_PIXREG&& = none +COMP_T_E_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_T_E_PIXREG_INITVALUE_MAP&& = none +COMP_T_E_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_T_E_COMBINED_MONOPOLE_SAMPLING&& = .false. + diff --git a/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults b/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults new file mode 100644 index 000000000..9ff961019 --- /dev/null +++ b/commander3/parameter_files/defaults/components/synch/synch_planck2015_1deg.defaults @@ -0,0 +1,96 @@ +# Synch component +COMP_LABEL&& = synch +COMP_TYPE&& = spindust +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 256 +COMP_MONOPOLE_PRIOR&& = none +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 750 +COMP_OUTPUT_FWHM&& = 60 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 0.408 +COMP_NU_REF_P&& = 0.408 +COMP_MASK&& = fullsky +COMP_INDMASK&& = fullsky + +COMP_CL_TYPE&& = none gauss # {none, single_l, binned,power_law, exp} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.0 +COMP_CL_BETA_PRIOR_RMS&& = 0.0 +COMP_CL_L_PIVOT&& = 50 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e7 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 500 +COMP_CL_DEFAULT_AMP_B&& = 500 +COMP_CL_DEFAULT_BETA_T&& = 5.d0 +COMP_CL_DEFAULT_BETA_E&& = 10.d0 +COMP_CL_DEFAULT_BETA_B&& = 10.d0 + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 750 +COMP_AMP_INPUT_MAP&& = init_synch_rc2_n256_v03.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 750 + +COMP_NU_P_NU_MIN&& = 0 # Lowest frequency for index estimation in GHz +COMP_NU_P_NU_MAX&& = 100 # Highest frequency for index estimation in GHz +COMP_NU_P_INPUT_MAP&& = init_synch_nup_rc2_n256_v03.fits +COMP_NU_P_DEFAULT&& = 0.015407022 +COMP_NU_P_PRIOR_UNI_LOW&& = 0.001 +COMP_NU_P_PRIOR_UNI_HIGH&& = 0.10 +COMP_NU_P_PRIOR_GAUSS_MEAN&& = 0.015407022 +COMP_NU_P_PRIOR_GAUSS_RMS&& = 0. # 0.1 +COMP_NU_P_SMOOTHING_SCALE&& = 0 +COMP_NU_P_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} + + +COMP_APPLY_JEFFREYS_PRIOR&& = .true. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + + +# New Local sampling parameters, 'synch' +COMP_NU_P_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_NU_P_INT_LNLTYPE&& = prior # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling +COMP_NU_P_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. +COMP_NU_P_INT_PRIOR_MEAN&& = 19 # prior sampler mean; Planck 2015 +COMP_NU_P_INT_PRIOR_RMS&& = 0.0 # prior sampler RMS; Planck 2015 +COMP_NU_P_INT_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG_PRIORS&& = none +COMP_NU_P_POL_PIXREG&& = pixreg # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment +COMP_NU_P_INT_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=1 of poltype). Sample correlation length of proposals +COMP_NU_P_POL_SAMPLE_NPROP&& = .false. # sample nprop, local sampling (p=2 of poltype). Sample correlation length of proposals +COMP_NU_P_INT_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=1 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_POL_SAMPLE_PROPLEN&& = .true. # sample proposal length, local sampling (p=2 of poltype). Sample proposal length (std. dev.) of proposals +COMP_NU_P_INT_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_POL_NPROP_INIT&& = 500 # {> 0, < 0 to disable}. overwrites nprop init values from nprop map. local sampler +COMP_NU_P_UNI_NPROP_LOW&& = 10 # {>= 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_UNI_NPROP_HIGH&& = 2000 # {> 0} local sampling. minimum number of proposals per pixel region +COMP_NU_P_ALMSAMP_INIT&& = init_alm_dust_beta.dat +COMP_NU_P_MASK&& = fullsky mask_monopoles_BP10_chisq_dx12_n1024_specpar_sampling.fits mask_dust_beta_BP8_10deg.fits # index sampling mask for smoothed log-likelihood eval. local sampler. +COMP_NU_P_NPROP&& = fullsky # nprop map, local sampling (fullsky = 1) +COMP_NU_P_PROPLEN&& = fullsky # proposal length map, local sampling (fullsky = 1.d0) +COMP_NU_P_INT_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_POL_PROPLEN_INIT&& = 0.0003 # {> 0.d0, -1.d0 to disable}. overwrites proplen init values from nprop map. local sampler +COMP_NU_P_INT_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_INT_FIX_PIXREG&& = none +COMP_NU_P_POL_NUM_PIXREG&& = 1 # number of pixel regions to sample (from 1 to N), all regions above N set to 0 (and prior value for spec ind) +COMP_NU_P_POL_FIX_PIXREG&& = none +COMP_NU_P_PIXREG_MAP&& = fullsky # Pixel region map (from 1 -> N). 'fullsky' -> all pixels = 1 +COMP_NU_P_PIXREG_INITVALUE_MAP&& = none +COMP_NU_P_COMBINED_MONOPOLE_SAMPLING&& = .true. +COMP_NU_P_COMBINED_MONOPOLE_TYPE&& = monopole-dipole +COMP_NU_P_COMBINED_MONOPOLE_FREEZE&& = none #write band labels of band to not sample monopoles from during combined sampling. separate with comma ',' +COMP_NU_P_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n1024_TQU.fits +COMP_NU_P_CORRELATION_CONVERGENCE_SAMPLING&& = .false. +COMP_NU_P_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 + diff --git a/commander3/parameter_files/defaults/planck2015_1deg.defaults b/commander3/parameter_files/defaults/planck2015_1deg.defaults new file mode 100644 index 000000000..843e1f398 --- /dev/null +++ b/commander3/parameter_files/defaults/planck2015_1deg.defaults @@ -0,0 +1,114 @@ +# Monte Carlo options +BASE_SEED = 163425 # Seed for random number generator + +NUM_GIBBS_STEPS_PER_TOD_SAMPLE = 0 + +SAMPLE_ONLY_TEMPERATURE = .true. +SAMPLE_ONLY_POLARIZATION = .false. +SAMPLE_SIGNAL_AMPLITUDES = .true. +SAMPLE_SPECTRAL_INDICES = .false. +SAMPLE_POWSPEC = .false. + +ENABLE_TOD_ANALYSIS = .false. +TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER = 10 +TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER = 10 +TOD_INCLUDE_ZODI = .false. +FFTW3_MAGIC_NUMBERS = fft3_magic_numbers_230810.txt + +ENABLE_TOD_SIMULATIONS = .false. +SIMS_OUTPUT_DIRECTORY = none + +# Options for CMB resampling (for constrained realization production) +RESAMPLE_CMB = .false. +FIRST_SAMPLE_FOR_CMB_RESAMP = 1 +LAST_SAMPLE_FOR_CMB_RESAMP = 15 +NUM_SUBSAMP_PER_MAIN_SAMPLE = 10 + +# Numerical accuracy settings +CG_CONVERGENCE_CRITERION = fixed_iter chisq # {residual, chisquare} +CG_LMAX_PRECOND = -1 # lmax for low-l preconditioner +CG_MAXITER = 300 # Conjugate gradients time out limit +CG_MINITER = 5 +CG_TOLERANCE = 1.d-8 # Fractional CG convergence criterion +CG_CONV_CHECK_FREQUENCY = 1 # Check convergence every n'th iteration +CG_PRECOND_TYPE = diagonal pseudoinv +CG_INIT_AMPS_ON_ZERO = .false. +SET_ALL_NOISE_MAPS_TO_MEAN = .false. +NUM_INDEX_CYCLES_PER_ITERATION = 1 +IGNORE_GAIN_AND_BANDPASS_CORR = .false. + +############################################################## +## Output options # +############################################################### + +THINNING_FACTOR = 1 +NSIDE_CHISQ = 16 +POLARIZATION_CHISQ = .true. +OUTPUT_MIXING_MATRIX = .false. +OUTPUT_RESIDUAL_MAPS = .true. +OUTPUT_CHISQ_MAP = .true. +OUTPUT_EVERY_NTH_CG_ITERATION = 0 +OUTPUT_CG_PRECOND_EIGENVALS = .false. +OUTPUT_INPUT_MODEL = .false. +OUTPUT_DEBUG_SEDS = .false. +OUTPUT_SIGNALS_PER_BAND = .false. + + +SOURCE_MASKFILE = none #bright_sources.txt +PROCESSING_MASKFILE = none #mask_cmb_v1_n0256_apod_v2_clean.fits +PROC_SMOOTH_SCALE = 30. #arcmin; smoothing inside processing mask + +# Spectral index sampling options + NUM_SMOOTHING_SCALES = 0 + + SMOOTHING_SCALE_FWHM01 = 300. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX01 = 96 + SMOOTHING_SCALE_NSIDE01 = 32 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN01 = pixel_window_n0032.fits + SMOOTHING_SCALE_FWHM_POSTPROC01 = 600. # Smoothing FWHM after pixel-by-pixel fit + + SMOOTHING_SCALE_FWHM02 = 600. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX02 = 64 + SMOOTHING_SCALE_NSIDE02 = 16 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN02 = pixel_window_n0016.fits + SMOOTHING_SCALE_FWHM_POSTPROC02 = 600. # Smoothing FWHM after pixel-by-pixel fit + + #fullsky spec. ind. parameters sampling (per say no smoothing in skymaps, but smoothing in postproc) + SMOOTHING_SCALE_FWHM03 = 60. # Arcmin; 0 = native resolution + SMOOTHING_SCALE_LMAX03 = 64 + SMOOTHING_SCALE_NSIDE03 = 16 # Must match NSIDE of component it is used for + SMOOTHING_SCALE_PIXWIN03 = pixel_window_n0016.fits + SMOOTHING_SCALE_FWHM_POSTPROC03 = 600. # Smoothing FWHM after pixel-by-pixel fit + + # TOD sampling options + TOD_NUM_BP_PROPOSALS_PER_ITER = 1 # 1 for sampling; >= 1 for optimize + + NUMITER_RESAMPLE_HARD_GAIN_PRIORS = 3 + + +CMB_DIPOLE_PRIOR = none + +OUTPUT_COMPS_TO_CHAINDIR = all + +# Alm sampler settings +ALMSAMP_NSAMP_ALM = 100 # of mcmc samples per gibbs +ALMSAMP_BURN_IN = 2 # of gibbs iterations with steplength adjustment +ALMSAMP_NSIDE_CHISQ_LOWRES = 16 +ALMSAMP_PRIOR_FWHM = 0 +ALMSAMP_OPTIMIZE_ALM = .false. # save chisq from prev gibbs iter +ALMSAMP_APPLY_PRIOR = .true. # apply prior to alms +ALMSAMP_PIXREG = .true. +ALMSAMP_PRIORSAMP_FROZEN_REGIONS = .true. + +#local sampler settings +LOCALSAMP_BURN_IN = 2 # of gibbs iterations with steplength adjustment +LOCALSAMP_OUTPUT_MAPS = .false. # {.true., .false.} output extra maps from local sampler + +############################################################## +## Conventions and global parameters # +############################################################### + + +MJYSR_CONVENTION = IRAS +T_CMB = 2.7255d0 + From 19c17711a14eec56b4519da8428de300719e87c9 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 28 Jan 2025 19:06:26 +0100 Subject: [PATCH 076/171] Removed warning, results seem reasonable. --- commander3/src/comm_diffuse_comp_smod.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 48e3f912e..1f442d0b7 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -2098,7 +2098,7 @@ module function evalDiffuseBand(self, band, amp_in, pix, alm_out, det) result(re m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else - write(*,*) "skal ikke vaere her, eval", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask + ! write(*,*) "skal ikke vaere her, eval", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() @@ -2171,7 +2171,7 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else - write(*,*) "skal ikke vaere her, proj", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask + ! write(*,*) "skal ikke vaere her, proj", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask if (data(band)%B(d)%p%almFromConv) call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() From be766eecb4847aaa42f3cb54ed78d27365247eb6 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 28 Jan 2025 19:14:24 +0100 Subject: [PATCH 077/171] Removed for real --- commander3/src/comm_diffuse_comp_smod.f90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 1f442d0b7..e1cbd70d6 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -2098,7 +2098,6 @@ module function evalDiffuseBand(self, band, amp_in, pix, alm_out, det) result(re m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else - ! write(*,*) "skal ikke vaere her, eval", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() @@ -2171,7 +2170,6 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do else - ! write(*,*) "skal ikke vaere her, proj", trim(self%label), self%lmax_ind_mix(1:nmaps,:), self%latmask if (data(band)%B(d)%p%almFromConv) call m%Y() m%map(:,1:nmaps) = m%map(:,1:nmaps) * self%F(band,d)%p%map(:,1:nmaps) call m%YtW() From b4c3251253bec6b89b62c297dbd1fe98e121bd89 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 29 Jan 2025 11:04:36 +0100 Subject: [PATCH 078/171] Removed debug file output --- commander3/src/comm_tod_dirbe_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index aa142cfbb..bcdf9f2a2 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -423,7 +423,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call compute_calibrated_data(self, i, sd, d_calib) ! For debugging: write TOD to hdf - if (.true.) then + if (.false.) then ! scan id appears to be the worst chi2 if (self%scanid(i) < 10000) then !print *, self%scanid(i) From 274a9306087dbd66464f688dd4060ac83b078cd9 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 29 Jan 2025 11:44:29 +0100 Subject: [PATCH 079/171] Fixed validation bug --- commander3/src/comm_param_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 023989402..0a239fe2c 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -3583,7 +3583,7 @@ subroutine validate_params(cpar) if (trim(cpar%cs_mono_prior(i)) /= 'none') then filename = get_token(cpar%cs_mono_prior(i), ":", 2) filename1 = get_token(filename, ",", 1) - call validate_file(trim(filename1),"COMP_MONOPOLE_PRIOR"//itext) + call validate_file(trim(cpar%datadir)//'/'//trim(filename1),"COMP_MONOPOLE_PRIOR"//itext) end if if (trim(cpar%cs_prior_amp(i)) /= 'none') then From e0f44ce5d95e85110daec0a1ff15204bd25ca0f0 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 29 Jan 2025 12:05:47 +0100 Subject: [PATCH 080/171] Debugging t0/t1 issue --- commander3/src/comm_tod_mod.f90 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index fbc8bd6aa..fa9643b29 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -2881,7 +2881,10 @@ subroutine precompute_zodi_lookups(self, cpar) ! filter out non zero values t0_packed = pack(t0, t0 /= 0.) t1_packed = pack(t1, t1 /= 0.) - if (size(t0_packed) /= size(t1_packed)) stop "t0 and t1 are not the same size" + if (size(t0_packed) /= size(t1_packed)) then + write(*,*) "t0 and t1 are not the same size", size(t0_packed), size(t1_packed) + stop + end if allocate(x0_obs_packed(3, size(t0_packed)), x1_obs_packed(3, size(t0_packed))) From 3ea7eba07d37064b7d937ee60f506b53137266dd Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 29 Jan 2025 14:24:14 +0100 Subject: [PATCH 081/171] Added optional support for reading in end time of TOD. --- commander3/src/comm_tod_mod.f90 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index fa9643b29..dee99339b 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -81,11 +81,11 @@ module comm_tod_mod real(dp) :: n_proctime = 0 ! Number of completed loops real(dp) :: v_sun(3) ! Observatory velocity relative to Sun in km/s real(dp) :: t0(3) ! MJD, OBT, SCET for start of chunk - real(dp) :: t1(3) ! MJD, OBT, SCET for end f chunk + real(dp) :: t1(3) ! MJD, OBT, SCET for end of chunk real(dp) :: x0_obs(3) ! Observatory position (x,y,z) for start of chunk - real(dp) :: x1_obs(3) ! Observatory position (x,y,z) for end f chunk + real(dp) :: x1_obs(3) ! Observatory position (x,y,z) for end of chunk real(dp) :: x0_earth(3) ! Observatory position (x,y,z) for start of chunk - real(dp) :: x1_earth(3) ! Observatory position (x,y,z) for end f chunk + real(dp) :: x1_earth(3) ! Observatory position (x,y,z) for end of chunk type(huffcode) :: hkey ! Huffman decompression key type(huffcode) :: todkey ! Huffman decompression key @@ -972,6 +972,19 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio self%t0(2) = time end if + + if (hdf_group_exists(file, slabel // "/common/time_end")) then + call get_size_hdf(file, slabel // "/common/time_end", setsize) + if (setsize(1) == 3) then + call read_hdf(file, slabel // "/common/time_end", self%t1) + else + self%t1 = 0 + end if + else + self%t1 = 0 + end if + + ! HKE: LFI files should be regenerated with (x,y,z) info ! Read in satellite and earth position at the start and end of each scan (if available) call read_hdf(file, slabel // "/common/satpos", self%x0_obs, opt=.true.) @@ -2882,7 +2895,7 @@ subroutine precompute_zodi_lookups(self, cpar) t0_packed = pack(t0, t0 /= 0.) t1_packed = pack(t1, t1 /= 0.) if (size(t0_packed) /= size(t1_packed)) then - write(*,*) "t0 and t1 are not the same size", size(t0_packed), size(t1_packed) + write(*,*) "Irregularity in number of unique start/end-times of tods, ", size(t0_packed), ' versus ', size(t1_packed), ' needed for zodi/tod interpolation' stop end if From b5f646d84e91d88500e8e58dd5a0851254692cb5 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 29 Jan 2025 18:22:41 +0100 Subject: [PATCH 082/171] Complete Gibbs sample with Planck 2015 + 10 DIRBE scans --- commander3/src/comm_tod_dirbe_mod.f90 | 15 +---- commander3/src/comm_tod_driver_mod.f90 | 76 +++++++++++++++++--------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index bcdf9f2a2..d32e6d012 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -281,12 +281,9 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, select_data = .false. !self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration sample_gain = .false. ! Gain sampling, LB TOD sims have perfect gain -!!$ if (trim(self%freq) == '01' .or. trim(self%freq) == '02' .or. & -!!$ & trim(self%freq) == '03' .or. & -!!$ & trim(self%freq) == '09' .or. trim(self%freq) == '10') then - !if (trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then if (trim(self%freq(1:2)) == '10') then sample_ncorr = .true. + sample_ncorr = .false. else sample_ncorr = .false. end if @@ -336,16 +333,6 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, stop end if - ! Prepare data - if (sample_rel_bandpass) then -! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) - else if (sample_abs_bandpass) then - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) - else - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) - end if - !------------------------------------ ! Perform main sampling steps diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 1c2c42006..c60943ee2 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -116,6 +116,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, allocate(sd%s_bp(sd%ntod, sd%ndet)) allocate(sd%s_orb(sd%ntod, sd%ndet)) allocate(sd%s_tot(sd%ntod, sd%ndet)) + allocate(sd%s_gain(sd%ntod, sd%ndet)) allocate(sd%mask(sd%ntod, sd%ndet)) allocate(sd%pix(sd%ntod, sd%ndet, sd%nhorn)) allocate(sd%psi(sd%ntod, sd%ndet, sd%nhorn)) @@ -124,8 +125,14 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, if (init_s_bp_prop_) allocate(sd%s_bp_prop(sd%ntod, sd%ndet, 2:sd%ndelta)) if (init_s_sky_prop_) allocate(sd%mask2(sd%ntod, sd%ndet)) if (tod%sample_mono) allocate(sd%s_mono(sd%ntod, sd%ndet)) - if (tod%subtract_zodi) allocate(sd%s_zodi(sd%ntod, sd%ndet)) if (tod%apply_inst_corr) allocate(sd%s_inst(sd%ntod, sd%ndet)) + if (tod%subtract_zodi) then + call tod%clear_zodi_cache() + allocate(sd%s_zodi(sd%ntod, sd%ndet)) + allocate(sd%s_zodi_scat(sd%ntod, tod%zodi_n_comps, sd%ndet)) + allocate(sd%s_zodi_therm(sd%ntod, tod%zodi_n_comps, sd%ndet)) + if (tod%sample_zodi) allocate(sd%mask_zodi(sd%ntod, sd%ndet)) + end if !call update_status(status, "todinit_alloc") call timer%stop(TOD_ALLOC, tod%band) @@ -169,9 +176,13 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, if (init_s_bp_) then call project_sky(tod, map_sky(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & & procmask, scan, sd%s_sky, sd%mask, s_bp=sd%s_bp) + call project_sky(tod, map_gain(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask, scan, sd%s_gain, sd%mask, s_bp=sd%s_bp) else call project_sky(tod, map_sky(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & & procmask, scan, sd%s_sky, sd%mask) + call project_sky(tod, map_gain(:,:,:,1), sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, & + & procmask, scan, sd%s_gain, sd%mask) end if !call update_status(status, "todinit_sky") !if (tod%myid == 78) write(*,*) 'c6', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires @@ -314,7 +325,11 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, ! Construct total sky signal do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle - sd%s_tot(:,j) = sd%s_sky(:,j) + sd%s_sl(:,j) + sd%s_orb(:,j) + if (tod%subtract_zodi) then + sd%s_tot(:,j) = sd%s_sky(:,j) + sd%s_sl(:,j) + sd%s_orb(:,j) + sd%s_zodi(:,j) + else + sd%s_tot(:,j) = sd%s_sky(:,j) + sd%s_sl(:,j) + sd%s_orb(:,j) + end if if (tod%sample_mono) sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_mono(:,j) if (tod%apply_inst_corr) sd%s_tot(:,j) = sd%s_tot(:,j) + sd%s_inst(:,j) end do @@ -377,11 +392,14 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas allocate(sd%s_sky(sd%ntod, sd%ndet)) allocate(sd%s_bp(sd%ntod, sd%ndet)) allocate(sd%s_orb(sd%ntod, sd%ndet)) + allocate(sd%s_orbA(sd%ntod, sd%ndet)) + allocate(sd%s_orbB(sd%ntod, sd%ndet)) allocate(sd%s_tot(sd%ntod, sd%ndet)) allocate(sd%s_totA(sd%ntod, sd%ndet)) allocate(sd%s_totB(sd%ntod, sd%ndet)) - allocate(sd%s_orbA(sd%ntod, sd%ndet)) - allocate(sd%s_orbB(sd%ntod, sd%ndet)) + allocate(sd%s_gain(sd%ntod, sd%ndet)) + allocate(sd%s_gainA(sd%ntod, sd%ndet)) + allocate(sd%s_gainB(sd%ntod, sd%ndet)) allocate(sd%mask(sd%ntod, sd%ndet)) allocate(sd%pix(sd%ntod, 1, sd%nhorn)) allocate(sd%psi(sd%ntod, 1, sd%nhorn)) @@ -391,12 +409,15 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas if (init_s_sky_prop_) allocate(sd%mask2(sd%ntod, sd%ndet)) if (tod%sample_mono) allocate(sd%s_mono(sd%ntod, sd%ndet)) if (tod%subtract_zodi) allocate(sd%s_zodi(sd%ntod, sd%ndet)) - sd%s_tot = 0. - sd%s_totA = 0. - sd%s_totB = 0. - sd%s_orb = 0. - sd%s_orbA = 0. - sd%s_orbB = 0. + sd%s_tot = 0. + sd%s_totA = 0. + sd%s_totB = 0. + sd%s_orb = 0. + sd%s_orbA = 0. + sd%s_orbB = 0. + sd%s_gain = 0. + sd%s_gainA = 0. + sd%s_gainB = 0. allocate(s_bufA(sd%ntod, sd%ndet)) allocate(s_bufB(sd%ntod, sd%ndet)) @@ -446,7 +467,7 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas if (init_s_bp_prop_) then do k = 2, sd%ndelta call project_sky_differential(tod, map_sky(:,:,:,k), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, sd%mask, s_bpA=s_buf2A, s_bpB=s_buf2B) + & procmask2, scan, s_bufA, s_bufB, sd%mask2, s_bpA=s_buf2A, s_bpB=s_buf2B) do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle sd%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) @@ -456,7 +477,7 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas else if (init_s_sky_prop_) then do k = 2, sd%ndelta call project_sky_differential(tod, map_sky(:,:,:,k), sd%pix(:,1,:), sd%psi(:,1,:), sd%flag(:,1), & - & procmask, scan, s_bufA, s_bufB, sd%mask) + & procmask2, scan, s_bufA, s_bufB, sd%mask2) do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle sd%s_sky_prop(:,j,k) = (1.+tod%x_im(j))*s_bufA(:,j) - (1.-tod%x_im(j))*s_bufB(:,j) @@ -493,8 +514,6 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas sd%s_totA(:,j) = sd%s_totA(:,j) + s_bufA(:,j) sd%s_totB(:,j) = sd%s_totB(:,j) + s_bufB(:,j) end do - else - sd%s_zodi = 0. end if ! Construct sidelobe template @@ -553,8 +572,6 @@ subroutine init_scan_data_differential(sd, tod, scan, map_sky, map_gain, procmas sd%s_totB(:,j) = sd%s_totB(:,j) + s_bufB(:,j) end do call timer%stop(TOD_ZODI, tod%band) - ! else - ! self%s_zodi = 0. end if ! Clean-up @@ -575,17 +592,22 @@ subroutine dealloc_scan_data(sd) deallocate(sd%tod, sd%n_corr, sd%s_sl, sd%s_sky) deallocate(sd%s_orb, sd%s_tot, sd%mask) deallocate(sd%pix, sd%psi, sd%flag) - if (allocated(sd%s_sky_prop)) deallocate(sd%s_sky_prop) - if (allocated(sd%s_bp_prop)) deallocate(sd%s_bp_prop) - if (allocated(sd%s_bp)) deallocate(sd%s_bp) - if (allocated(sd%s_mono)) deallocate(sd%s_mono) - if (allocated(sd%mask2)) deallocate(sd%mask2) - if (allocated(sd%s_zodi)) deallocate(sd%s_zodi) - if (allocated(sd%s_totA)) deallocate(sd%s_totA) - if (allocated(sd%s_totB)) deallocate(sd%s_totB) - if (allocated(sd%s_inst)) deallocate(sd%s_inst) - if (allocated(sd%s_orbA)) deallocate(sd%s_orbA) - if (allocated(sd%s_orbB)) deallocate(sd%s_orbB) + if (allocated(sd%s_sky_prop)) deallocate(sd%s_sky_prop) + if (allocated(sd%s_bp_prop)) deallocate(sd%s_bp_prop) + if (allocated(sd%s_bp)) deallocate(sd%s_bp) + if (allocated(sd%s_mono)) deallocate(sd%s_mono) + if (allocated(sd%mask2)) deallocate(sd%mask2) + if (allocated(sd%s_zodi)) deallocate(sd%s_zodi) + if (allocated(sd%s_zodi_scat)) deallocate(sd%s_zodi_scat) + if (allocated(sd%s_zodi_therm)) deallocate(sd%s_zodi_therm) + if (allocated(sd%s_totA)) deallocate(sd%s_totA) + if (allocated(sd%s_totB)) deallocate(sd%s_totB) + if (allocated(sd%s_inst)) deallocate(sd%s_inst) + if (allocated(sd%s_orbA)) deallocate(sd%s_orbA) + if (allocated(sd%s_orbB)) deallocate(sd%s_orbB) + if (allocated(sd%s_gain)) deallocate(sd%s_gain) + if (allocated(sd%s_gainA)) deallocate(sd%s_gainA) + if (allocated(sd%s_gainB)) deallocate(sd%s_gainB) end subroutine dealloc_scan_data From 8f20c47ce91fa95b765b6257a1cafcd222301bf4 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 30 Jan 2025 11:04:51 +0100 Subject: [PATCH 083/171] further progress on merging hfi and devel, now doesn't crash immediately --- .../defaults/bands/HFI/HFI_545_TOD.defaults | 4 +++ .../python/commander_tools/tod_tools/hfi.py | 9 +++++- .../python/commander_tools/tod_tools/lfi.py | 4 +-- commander3/src/comm_bp_mod.f90 | 2 -- commander3/src/comm_data_mod.f90 | 2 +- commander3/src/comm_param_mod.f90 | 4 +-- commander3/src/comm_tod_hfi_mod.f90 | 9 +++++- commander3/src/comm_tod_mod.f90 | 28 +++++++++++-------- commander3/todscripts/hfi/hfiinstrument.py | 6 ++-- 9 files changed, 46 insertions(+), 22 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index a4e5c647a..b4e771179 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -1,6 +1,7 @@ #HFI 545 GHz TOD default parameters BAND_LABEL&&& = 545 +BAND_INSTRUMENT_LABEL&&& = HFI BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -45,6 +46,9 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_INIT_FROM_HDF&&& = default +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none #TODO: make these paths into real defaults in the Oslo legacy archive BAND_MAPFILE&&& = npipe6v20_545_map_K.fits diff --git a/commander3/python/commander_tools/tod_tools/hfi.py b/commander3/python/commander_tools/tod_tools/hfi.py index f992356f0..e5438aa82 100644 --- a/commander3/python/commander_tools/tod_tools/hfi.py +++ b/commander3/python/commander_tools/tod_tools/hfi.py @@ -186,5 +186,12 @@ def verify_instrument_file(outDir, version): if version == 1: print("Should check the version here") - if version > 1: + if version == 2: + print("I don't know how this is supposed to be different than 1") + + if version == 3: + if f['545-1/sllmax'] != 0: + print("HFI instrument file doesn't contain sidelobes for 545") + + if version > 3: raise ValueError("Version " + str(version) + " of HFI instrument file has not yet been defined.") diff --git a/commander3/python/commander_tools/tod_tools/lfi.py b/commander3/python/commander_tools/tod_tools/lfi.py index 12e3de783..ac821768a 100644 --- a/commander3/python/commander_tools/tod_tools/lfi.py +++ b/commander3/python/commander_tools/tod_tools/lfi.py @@ -20,8 +20,8 @@ #================================================================================ import h5py -#import commander_tools.tod_tools.commander_instrument as inst -import tod_tools.commander_instrument as inst +import commander_tools.tod_tools.commander_instrument as inst +#import tod_tools.commander_instrument as inst import os import numpy as np import healpy as hp diff --git a/commander3/src/comm_bp_mod.f90 b/commander3/src/comm_bp_mod.f90 index d214c8bed..6aa40285f 100644 --- a/commander3/src/comm_bp_mod.f90 +++ b/commander3/src/comm_bp_mod.f90 @@ -180,8 +180,6 @@ function constructor_bp(cpar, id, id_abs, detlabel, subdets) result(c) end do c%tau0 = c%tau0 / ndet else - print *, "got to nonzero threshold, aborting" - stop call read_bandpass_nonzero_threshold(cpar%ds_bpfile(id_abs), dets, ndet, & & c%threshold, & & c%n, c%nu0, c%tau0) diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 94292ac15..0210a2334 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -288,7 +288,7 @@ subroutine initialize_data_mod(cpar, handle) data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=trim(data(n)%tod%label(j))) else ! Check if bandpass already exists in detector list - call read_bandpass(trim(cpar%datadir) // '/' // cpar%ds_bpfile(i), & + call read_bandpass(cpar%ds_bpfile(i), & & trim(data(n)%tod%label(j)), & & data(n)%bp(1)%p%threshold, & & n_dummy, & diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index e9425ef1e..863a85484 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -1078,7 +1078,7 @@ subroutine read_diffuse_gen_params_hash(htbl, cpar, itext, i, len_itext, bool_fl end if cpar%cs_cl_amp_def(i,:) = cpar%cs_cl_amp_def(i,:) / cpar%cs_cg_scale(:,i)**2 end if - call get_parameter_hashtable(htbl, 'COMP_MONOPOLE_PRIOR'//itext, len_itext=len_itext, par_string=cpar%cs_mono_prior(i)) + call get_parameter_hashtable(htbl, 'COMP_MONOPOLE_PRIOR'//itext, len_itext=len_itext, par_string=cpar%cs_mono_prior(i), path=.true.) call get_parameter_hashtable(htbl, 'COMP_MASK'//itext, len_itext=len_itext, par_string=cpar%cs_mask(i), path=.true.) if(cpar%cs_mask(i) /= 'fullsky') then maskfile = adjustl(trim(cpar%cs_mask(i))) @@ -3569,7 +3569,7 @@ subroutine validate_params(cpar) if (trim(cpar%cs_mono_prior(i)) /= 'none') then filename = get_token(cpar%cs_mono_prior(i), ":", 2) filename1 = get_token(filename, ",", 1) - call validate_file(trim(filename1),"COMP_MONOPOLE_PRIOR"//itext) + call validate_file(trim(cpar%datadir) //"/"// trim(filename1),"COMP_MONOPOLE_PRIOR"//itext) end if if (trim(cpar%cs_prior_amp(i)) /= 'none') then diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 69710bacf..b71c3df71 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -98,16 +98,23 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%noise_psd_model = 'oof' allocate(c%xi_n_P_uni(c%n_xi,2)) allocate(c%xi_n_P_rms(c%n_xi)) + allocate(c%xi_n_nu_fit(c%n_xi, 2)) ! just so that it actually runs c%xi_n_P_uni(2,:) = [0.010d0, 0.45d0] ! fknee c%xi_n_P_uni(3,:) = [-2.5d0, -0.4d0] ! alpha - !c%xi_n_nu_fit = [0.d0, 1.225d0] ! I took it from freq=30 for LFI, so not true + + !TODO: These numbers are made up, we should refine them + c%xi_n_nu_fit(1,:) = [3.d0, 10.d0] + c%xi_n_nu_fit(2,:) = [0.d0, 1.25d0] + c%xi_n_nu_fit(3,:) = [0.d0, 1.25d0] c%xi_n_P_rms = [-1.d0, 0.1d0, 0.2d0] ! [sigma0, fknee, alpha]; sigma0 is not used c%n_cray_temps = 3 + c%ndiode = 1 + ! Initialize common parameters call c%tod_constructor(cpar, id, id_abs, info, tod_type) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 4fde5fc59..d2be2e2b7 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -155,7 +155,7 @@ module comm_tod_mod real(dp), allocatable, dimension(:) :: prop_bp_mean ! proposal matrix, sigma(ndelta), for mean real(sp), allocatable, dimension(:,:) :: xi_n_P_uni ! Uniform prior for noise PSD parameters real(sp), allocatable, dimension(:) :: xi_n_P_rms ! RMS for active noise PSD prior - real(sp), allocatable, dimension(:,:) :: xi_n_nu_fit ! Frequency range used to fit noise PSD parameters + real(sp), allocatable, dimension(:,:) :: xi_n_nu_fit ! Frequency range used to fit noise PSD parameters, (xi_n, 2) integer(i4b) :: nside, nside_param ! Nside for pixelized pointing integer(i4b) :: nobs, nobs_lowres ! Number of observed pixels for this core integer(i4b) :: n_bp_prop ! Number of consecutive bandpass proposals in each main iteration; should be 2 for MH @@ -650,17 +650,27 @@ subroutine load_instrument_file(self, nside_beam, nmaps_beam, pol_beam, comm_cha call read_hdf(h5_file, trim(adjustl(self%label(1)))//'/'//'sllmax', lmax_sl) call read_hdf(h5_file, trim(adjustl(self%label(1)))//'/'//'beamlmax', lmax_beam) - self%slinfo => comm_mapinfo(comm_chain, nside_beam, lmax_sl, nmaps_beam, pol_beam) - self%mbinfo => comm_mapinfo(comm_chain, nside_beam, lmax_beam, nmaps_beam, pol_beam) + if(lmax_sl > 0) then + self%slinfo => comm_mapinfo(comm_chain, nside_beam, lmax_sl, nmaps_beam, pol_beam) + end if + + if(lmax_beam > 0) then + self%mbinfo => comm_mapinfo(comm_chain, nside_beam, lmax_beam, nmaps_beam, pol_beam) + end if do i = 1, self%ndet call read_hdf(h5_file, trim(adjustl(self%label(i)))//'/'//'fwhm', self%fwhm(i)) call read_hdf(h5_file, trim(adjustl(self%label(i)))//'/'//'elip', self%elip(i)) call read_hdf(h5_file, trim(adjustl(self%label(i)))//'/'//'psi_ell', self%psi_ell(i)) call read_hdf(h5_file, trim(adjustl(self%label(i)))//'/'//'centFreq', self%nu_c(i)) - !self%slbeam(i)%p => comm_map(self%slinfo, h5_file, .true., "sl", trim(self%label(i))) - !self%mbeam(i)%p => comm_map(self%mbinfo, h5_file, .true., "beam", trim(self%label(i))) - !call self%mbeam(i)%p%Y() + if(lmax_sl > 0) then + self%slbeam(i)%p => comm_map(self%slinfo, h5_file, .true., "sl", trim(self%label(i))) + end if + + if(lmax_beam > 0) then + self%mbeam(i)%p => comm_map(self%mbinfo, h5_file, .true., "beam", trim(self%label(i))) + call self%mbeam(i)%p%Y() + end if end do call close_hdf_file(h5_file) @@ -1208,7 +1218,7 @@ subroutine read_hdf_scan_data(self, tod, filename, scan, ndet, detlabels, nhorn, field = detlabels(i) if(ndiode == 1) then if (tod%compressed_tod) then - call read_hdf_opaque(file, slabel // "/" // trim(field) // "/ztod", self%d(i)%ztod) + call read_hdf_opaque(file, slabel // "/" // trim(field) // "/tod", self%d(i)%ztod) else allocate(self%d(i)%tod(m)) call read_hdf(file, slabel // "/" // trim(field) // "/tod", buffer_sp) @@ -1219,10 +1229,6 @@ subroutine read_hdf_scan_data(self, tod, filename, scan, ndet, detlabels, nhorn, end if end if else ! ndiode > 1 per tod - if(tod%compressed_tod .eqv. .false.) then - - else - end if if (tod%compressed_tod) then allocate(self%d(i)%zdiode(ndiode)) call read_hdf_vlen(file, slabel // '/' // trim(field) // '/diodes', self%d(i)%zdiode) diff --git a/commander3/todscripts/hfi/hfiinstrument.py b/commander3/todscripts/hfi/hfiinstrument.py index f4933b38d..890160e63 100644 --- a/commander3/todscripts/hfi/hfiinstrument.py +++ b/commander3/todscripts/hfi/hfiinstrument.py @@ -46,7 +46,7 @@ def main(): args = parser.parse_args() outDir = args.out_dir - version = 1 + version = 3 rimo = fits.open(args.rimo) @@ -76,7 +76,9 @@ def main(): slData_B, mmax_s = hp.read_alm(os.path.join(args.beam_dir, 'fsl_alms_' + str(freq) + '-' + det + '.fits'), return_mmax=True, hdu=2) inst_file.add_alms(prefix, 'sl', lfi.getLmax(len(slData), mmax_s), mmax_s, lfi.complex2realAlms(slData, mmax_s), lfi.complex2realAlms(slData_E, mmax_s), lfi.complex2realAlms(slData_B, mmax_s)) - + else: + #we need sidelobe models for 545 and 857 + inst_file.add_alms(prefix, 'sl', 0, 0, [0], [0], [0]) inst_file.add_alms(prefix, 'beam', lfi.getLmax(len(beamData), mmax_b), mmax_b, lfi.complex2realAlms(beamData, mmax_b), None, None) From 564017e7e95c90eb3d3171532e797970d1373ba5 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 30 Jan 2025 13:28:57 +0100 Subject: [PATCH 084/171] fixed bug with monopole prior read in --- commander3/src/comm_diffuse_comp_smod.f90 | 2 +- commander3/src/comm_param_mod.f90 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index e1cbd70d6..f120f7add 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -334,7 +334,7 @@ module subroutine initDiffuse(self, cpar, id, id_abs) filename = get_token(temp_filename, ",", 1) info_tempfit => comm_mapinfo(cpar%comm_chain, self%nside, 0, 2, .false.) self%mono_prior_map => comm_map(info_tempfit, trim(filename)) - else + else filename = get_token(temp_filename, ",", 1) self%mono_prior_map => comm_map(self%x%info, trim(filename)) end if diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index eac05dfad..00398b30b 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -1090,7 +1090,8 @@ subroutine read_diffuse_gen_params_hash(htbl, cpar, itext, i, len_itext, bool_fl end if cpar%cs_cl_amp_def(i,:) = cpar%cs_cl_amp_def(i,:) / cpar%cs_cg_scale(:,i)**2 end if - call get_parameter_hashtable(htbl, 'COMP_MONOPOLE_PRIOR'//itext, len_itext=len_itext, par_string=cpar%cs_mono_prior(i), path=.true.) + ! Note to future Mathew: don't try to add path=true, it's not always a path + call get_parameter_hashtable(htbl, 'COMP_MONOPOLE_PRIOR'//itext, len_itext=len_itext, par_string=cpar%cs_mono_prior(i)) call get_parameter_hashtable(htbl, 'COMP_MASK'//itext, len_itext=len_itext, par_string=cpar%cs_mask(i), path=.true.) if(cpar%cs_mask(i) /= 'fullsky') then maskfile = adjustl(trim(cpar%cs_mask(i))) From c4fbe6eb2e5f89c1e8ba06bf5a4cd44f4813a025 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 30 Jan 2025 13:51:43 +0100 Subject: [PATCH 085/171] fixed issue with 4 digit gain printing --- commander3/src/comm_tod_gain_smod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index ee5ba80d2..c0704e75c 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -469,7 +469,7 @@ module subroutine sample_abscal_from_orbital(tod, handle, A_abs, b_abs) tod%gain0(0) = tod%gain0(0) + 1.d0/sqrt(sum(A)) * rand_gauss(handle) end if if (tod%verbosity > 1) then - write(*,fmt='(a,f12.8)') ' | abscal = ', tod%gain0(0) + write(*,*) ' | abscal = ', tod%gain0(0) !write(*,*) 'sum(b), sum(A) = ', sum(b), sum(A) end if end if From c186ccdf289f4c212b84c9f933ddd29ab23fb4a3 Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 31 Jan 2025 14:42:36 +0100 Subject: [PATCH 086/171] Added CI paramter file --- .../param_continuous_integration.txt | 948 ++++++++++++++++++ 1 file changed, 948 insertions(+) create mode 100644 commander3/parameter_files/param_continuous_integration.txt diff --git a/commander3/parameter_files/param_continuous_integration.txt b/commander3/parameter_files/param_continuous_integration.txt new file mode 100644 index 000000000..20f3652c9 --- /dev/null +++ b/commander3/parameter_files/param_continuous_integration.txt @@ -0,0 +1,948 @@ +************************************************************** +* Commander parameter file * +************************************************************** +@DEFAULT planck2015_1deg.defaults + +OPERATION = sample # {sample,optimize} +#OPERATION = optimize # {sample,optimize} +VERBOSITY = 3 # [0,...,3] + +############################################################## +# Algorithm specification # +############################################################## + +# Monte Carlo options +NUMCHAIN = 1 # Number of independent chains +NUM_GIBBS_ITER = 1 # Length of each Markov chain +CHAIN_STATUS = new +NUM_INIT_CHAINS = 1 + +INIT_CHAIN01 = none + +OUTPUT_MIXING_MATRIX = .false. +OUTPUT_INPUT_MODEL = .false. +OUTPUT_SIGNALS_PER_BAND = .false. +NSIDE_CHISQ = 256 + +ENABLE_TOD_ANALYSIS = .true. +TOD_INCLUDE_ZODI = .true. +SAMPLE_ZODI = .false. + +############################################################## +# Output options # +############################################################## + +OUTPUT_DIRECTORY = chains + +############################################################## +# Data sets # +############################################################## + +DATA_DIRECTORY = /mn/stornext/d23/cmbco/cg/dirbe/data +NUMBAND = 33 + +# HFI +INCLUDE_BAND001 = .true. # 857-2 +INCLUDE_BAND002 = .true. # 545-2 +INCLUDE_BAND003 = .true. # 545-4 +INCLUDE_BAND004 = .true. # 353-ds2 +INCLUDE_BAND005 = .true. # 353-1 +INCLUDE_BAND006 = .true. # 217-1 +INCLUDE_BAND007 = .true. # 217-2 +INCLUDE_BAND008 = .true. # 217-3 +INCLUDE_BAND009 = .true. # 217-4 +INCLUDE_BAND010 = .true. # 143-ds1 +INCLUDE_BAND011 = .true. # 143-ds2 +INCLUDE_BAND012 = .true. # 143-5 +INCLUDE_BAND013 = .true. # 143-6 +INCLUDE_BAND014 = .true. # 143-7 +INCLUDE_BAND015 = .true. # 100-ds1 +INCLUDE_BAND016 = .true. # 100-ds2 + +# LFI +INCLUDE_BAND017 = .true. # 30 GHz +INCLUDE_BAND018 = .true. # 44 GHz +INCLUDE_BAND019 = .true. # 70-ds1 +INCLUDE_BAND020 = .true. # 70-ds2 +INCLUDE_BAND021 = .true. # 70-ds3 + +# WMAP +INCLUDE_BAND022 = .true. # K +INCLUDE_BAND023 = .true. # Ka +INCLUDE_BAND024 = .true. # Q1 +INCLUDE_BAND025 = .true. # Q2 +INCLUDE_BAND026 = .true. # V1 +INCLUDE_BAND027 = .true. # V2 +INCLUDE_BAND028 = .true. # W1 +INCLUDE_BAND029 = .true. # W2 +INCLUDE_BAND030 = .true. # W3 +INCLUDE_BAND031 = .true. # W4 + +# Haslam +INCLUDE_BAND032 = .true. # Haslam + +# DIRBE +INCLUDE_BAND033 = .true. # 240 micron T 10 first half + +# 857-2 +@START 001 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 857-2 +BAND_INSTRUMENT_LABEL&&& = 857-2 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 857. +BAND_MAPFILE&&& = map_dx11d_r2_zc_857-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_857-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_857-2.dat +@END 001 + +# 545-2 +@START 002 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 545-2 +BAND_INSTRUMENT_LABEL&&& = 545-2 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 545. +BAND_MAPFILE&&& = map_dx11d_r2_zc_545-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_545-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_545-2.dat +@END 002 + +# 545-4 +@START 003 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 545-4 +BAND_INSTRUMENT_LABEL&&& = 545-4 +BAND_UNIT&&& = MJy/sr +BAND_BANDPASS_TYPE&&& = HFI_submm +BAND_NOMINAL_FREQ&&& = 545. +BAND_MAPFILE&&& = map_dx11d_r2_zc_545-4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_545-4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_545-4.dat +@END 003 + +# 353-ds2 +@START 004 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 353-ds2 +BAND_INSTRUMENT_LABEL&&& = 353-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 353. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_353-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_353-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_353-ds2.dat +@END 004 + +# 353-1 +@START 005 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 353-1 +BAND_INSTRUMENT_LABEL&&& = 353-1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 353. +BAND_MAPFILE&&& = map_dx11d_r2_zc_353-1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_353-1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_353-1.dat +@END 005 + +# 217-1 +@START 006 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-1 +BAND_INSTRUMENT_LABEL&&& = 217-1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-1.dat +@END 006 + +# 217-2 +@START 007 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-2 +BAND_INSTRUMENT_LABEL&&& = 217-2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-2.dat +@END 007 + +# 217-3 +@START 008 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-3 +BAND_INSTRUMENT_LABEL&&& = 217-3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-3_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-3_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-3.dat +@END 008 + +# 217-1 +@START 009 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 217-4 +BAND_INSTRUMENT_LABEL&&& = 217-4 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 217. +BAND_MAPFILE&&& = map_dx11d_r2_zc_217-4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_217-4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_217-4.dat +@END 009 + +# 143-ds1 +@START 010 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-ds1 +BAND_INSTRUMENT_LABEL&&& = 143-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_143-ds1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-ds1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-ds1.dat +@END 010 + +# 143-ds2 +@START 011 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-ds2 +BAND_INSTRUMENT_LABEL&&& = 143-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_143-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-ds2.dat +@END 011 + +# 143-5 +@START 012 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-5 +BAND_INSTRUMENT_LABEL&&& = 143-5 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-5_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-5_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-5.dat +@END 012 + +# 143-6 +@START 013 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-6 +BAND_INSTRUMENT_LABEL&&& = 143-6 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-6_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-6_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-6.dat +@END 013 + +# 143-7 +@START 014 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 143-7 +BAND_INSTRUMENT_LABEL&&& = 143-7 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 143. +BAND_MAPFILE&&& = map_dx11d_r2_zc_143-7_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_143-7_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_143-7.dat +@END 014 + +# 100-ds1 +@START 015 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 100-ds1 +BAND_INSTRUMENT_LABEL&&& = 100-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 100. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_100-ds1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_100-ds1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_100-ds1.dat +@END 015 + +# 100-ds2 +@START 016 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 100-ds2 +BAND_INSTRUMENT_LABEL&&& = 100-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_NOMINAL_FREQ&&& = 100. +BAND_MAPFILE&&& = map_dx11d_r2_zbpcg_100-ds2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_100-ds2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v307_100-ds2.dat +@END 016 + +# 30 GHz +@START 017 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 030 +BAND_INSTRUMENT_LABEL&&& = 030 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 28.4 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_030_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_030_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_030.dat +@END 017 + +# 44 GHz +@START 018 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 044 +BAND_INSTRUMENT_LABEL&&& = 044 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 44.1 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_044_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_044_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_044.dat +@END 018 + +# 70-ds1 +@START 019 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds1 +BAND_INSTRUMENT_LABEL&&& = 070-ds1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-18_23_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-18_23_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-18_23.dat +@END 019 + +# 70-ds2 +@START 020 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds2 +BAND_INSTRUMENT_LABEL&&& = 070-ds2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-19_22_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-19_22_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-19_22.dat +@END 020 + +# 70-ds3 +@START 021 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = 070-ds3 +BAND_INSTRUMENT_LABEL&&& = 070-ds3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = LFI +BAND_NOMINAL_FREQ&&& = 70.3 +BAND_MAPFILE&&& = map_dx11d_r2_nobpc_070-20_21_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_dx11d_r2_resc_070-20_21_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_dx11d_v2_070-20_21.dat +@END 021 + +# WMAP K +@START 022 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_K +BAND_INSTRUMENT_LABEL&&& = WMAP_K +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 22.8 +BAND_MAPFILE&&& = map_wmap9_K_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_K_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_K_v3.dat +@END 022 + +# WMAP Ka +@START 023 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Ka +BAND_INSTRUMENT_LABEL&&& = WMAP_Ka +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 33.0 +BAND_MAPFILE&&& = map_wmap9_Ka_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Ka_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Ka_v3.dat +@END 023 + +# WMAP Q1 +@START 024 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Q1 +BAND_INSTRUMENT_LABEL&&& = WMAP_Q1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 40.6 +BAND_MAPFILE&&& = map_wmap9_Q1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Q1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Q1_v3.dat +@END 024 + +# WMAP Q2 +@START 025 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_Q2 +BAND_INSTRUMENT_LABEL&&& = WMAP_Q2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 40.6 +BAND_MAPFILE&&& = map_wmap9_Q2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_Q2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_Q2_v3.dat +@END 025 + +# WMAP V1 +@START 026 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_V1 +BAND_INSTRUMENT_LABEL&&& = WMAP_V1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 60.8 +BAND_MAPFILE&&& = map_wmap9_V1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_V1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_V1_v3.dat +@END 026 + +# WMAP V2 +@START 027 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_V2 +BAND_INSTRUMENT_LABEL&&& = WMAP_V2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 60.8 +BAND_MAPFILE&&& = map_wmap9_V2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_V2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_V2_v3.dat +@END 027 + +# WMAP W1 +@START 028 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W1 +BAND_INSTRUMENT_LABEL&&& = WMAP_W1 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W1_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W1_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W1_v3.dat +@END 028 + +# WMAP W2 +@START 029 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W2 +BAND_INSTRUMENT_LABEL&&& = WMAP_W2 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W2_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W2_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W2_v3.dat +@END 029 + +# WMAP W3 +@START 030 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W3 +BAND_INSTRUMENT_LABEL&&& = WMAP_W3 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W3_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W3_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W3_v3.dat +@END 030 + +# WMAP W4 +@START 031 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = WMAP_W4 +BAND_INSTRUMENT_LABEL&&& = WMAP_W4 +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = WMAP +BAND_NOMINAL_FREQ&&& = 93.5 +BAND_MAPFILE&&& = map_wmap9_W4_0256_60arcmin_full.fits +BAND_NOISEFILE&&& = rms_wmap9_W4_0256_60arcmin_full.fits +BAND_BANDPASSFILE&&& = bp_wmap9_W4_v3.dat +@END 031 + +# Haslam +@START 032 +@DEFAULT bands/planck2015_1deg.defaults +BAND_LABEL&&& = Haslam +BAND_INSTRUMENT_LABEL&&& = Haslam +BAND_UNIT&&& = uK_cmb +BAND_BANDPASS_TYPE&&& = delta +BAND_NOMINAL_FREQ&&& = 0.408 +BAND_MAPFILE&&& = map_haslam408_ds_Remazeilles2014_1deg_n256_uK_TQU.fits +BAND_NOISEFILE&&& = rms_haslam408_ds_Remazeilles2014_1deg_n256_uK_0.8K_1pct_TQU.fits +BAND_BANDPASSFILE&&& = haslam_bp.dat +@END 032 + +# DIRBE +@START 033 +@DEFAULT bands/DIRBE/DIRBE_10_CIO_512.defaults +BAND_LABEL&&& = 10a +BAND_MAPFILE&&& = DIRBE_10a_512_prod_v1.fits +BAND_NOISEFILE&&& = DIRBE_10a_SIGMA_512_prod_v1.fits +BAND_TOD_FILELIST&&& = filelist_DIRBE_10_nside512_V21.txt +BAND_SAMP_GAIN&&& = .false. +BAND_TOD_TYPE&&& = DIRBE +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +#BAND_TOD_START_SCANID&&& = 8 31 +#BAND_TOD_END_SCANID&&& = 285 +BAND_TOD_START_SCANID&&& = 1 +BAND_TOD_END_SCANID&&& = 285 +BAND_TOD_MAIN_PROCMASK&&& = mask_dust_galecl15_v3.fits +BAND_TOD_ZODI_MASK&&& = mask_dust_gal15_v3.fits +BAND_TOD_INIT_FROM_HDF&&& = default none +@END 033 + +############################################################## +# Model parameters # +############################################################## + +INSTRUMENT_PARAM_FILE = init_instpar_planck2015_v1.dat +INIT_INSTRUMENT_FROM_HDF = none + +NUM_SIGNAL_COMPONENTS = 13 +INCLUDE_COMP01 = .true. # CMB +INCLUDE_COMP02 = .true. # Relativistic CMB correction +INCLUDE_COMP03 = .true. # Dust +INCLUDE_COMP04 = .true. # Synch +INCLUDE_COMP05 = .true. # Free-free +INCLUDE_COMP06 = .true. # AME1 +INCLUDE_COMP07 = .true. # AME2 +INCLUDE_COMP08 = .true. # CO10 +INCLUDE_COMP09 = .true. # CO21 +INCLUDE_COMP10 = .true. # CO32 +INCLUDE_COMP11 = .false. # HCN +INCLUDE_COMP12 = .false. # SZ +INCLUDE_COMP13 = .true. # Monopole + +# CMB +@START 01 +@DEFAULT components/cmb/cmb_planck2015_1deg.defaults +COMP_AMP_INPUT_MAP&& = init_cmb_rc2_n256_v03.fits +COMP_MONOPOLE_PRIOR&& = none +@END 01 + +# CMB relativistic quadrupole correction +@START 02 +@DEFAULT components/cmb/cmb_relquad_planck2015_1deg.defaults +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_ci.txt +@END 02 + +# Thermal dust component +@START 03 +@DEFAULT components/dust/dust_planck2015_1deg.defaults +COMP_NU_REF_T&& = 545 +COMP_NU_REF_P&& = 545 +COMP_INDMASK&& = fullsky +COMP_AMP_INPUT_MAP&& = init_dust_rc2_n256_v03.fits +COMP_BETA_INPUT_MAP&& = init_dust_beta_rc2_n256_v03.fits +COMP_T_INPUT_MAP&& = init_dust_Td_rc2_n256_v03.fits +COMP_BETA_SMOOTHING_SCALE&& = 0 +COMP_AMP_LMAX&& = 750 +@DEFAULT components/dust/dust_LFI_localsampler.defaults +# New Local sampling parameters, 'dust' +COMP_IND_LMAX&& = 750 +COMP_BETA_DEFAULT&& = 1.50 +COMP_T_DEFAULT&& = 19.5 +COMP_BETA_COMBINED_MONOPOLE_SAMPLING&& = .false. +COMP_BETA_ALMSAMP_INIT&& = none +COMP_BETA_MASK&& = fullsky +COMP_INIT_FROM_HDF&& = default +COMP_BETA_INT_LNLTYPE&& = prior chisq +COMP_BETA_INT_LMAX&& = -1 +COMP_BETA_INT_PIXREG&& = pixreg +COMP_BETA_POL_LNLTYPE&& = prior +COMP_BETA_INT_PRIOR_MEAN&& = 1.50 +COMP_BETA_POL_PRIOR_MEAN&& = 1.50 +COMP_BETA_POL_PRIOR_RMS&& = 0.03 0.03 +COMP_BETA_INT_PRIOR_RMS&& = 0.03 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.05 +COMP_BETA_POL_LMAX&& = -1 +COMP_CL_DEFAULT_AMP_T&& = 1e4 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 100 +COMP_CL_DEFAULT_AMP_B&& = 100 +COMP_CL_DEFAULT_BETA_T&& = 14.d0 +COMP_CL_DEFAULT_BETA_E&& = 14.d0 +COMP_CL_DEFAULT_BETA_B&& = 14.d0 +@END 03 + +# Synchrotron component +@START 04 +@DEFAULT components/synch/synch_planck2015_1deg.defaults +COMP_LABEL&& = synch +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 0.408 +COMP_NU_P_INPUT_MAP&& = init_synch_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = Synchrotron_template_GHz_extended.txt +COMP_AMP_INPUT_MAP&& = init_synch_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 04 + +# freefree component --------------------------------------------------------------------- +@START 05 +@DEFAULT components/freefree/freefree_planck2015_1deg.defaults +@DEFAULT components/freefree/freefree_planck2015_1deg_localsampler.defaults +COMP_EM_INPUT_MAP&& = init_ff_EM_rc2_n256_v03.fits +COMP_T_E_INPUT_MAP&& = init_ff_T_e_rc2_n256_v03.fits +@END 05 + +# AME1 component ------------------------------------------------------------------ +@START 06 +@DEFAULT components/ame/ame_planck2015_1deg.defaults +COMP_LABEL&& = ame1 +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 22.8 +COMP_NU_P_INPUT_MAP&& = init_ame1_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = spdust2_cnm.dat +COMP_AMP_INPUT_MAP&& = init_ame1_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 06 + +# AME1 component ------------------------------------------------------------------ +@START 07 +@DEFAULT components/ame/ame_planck2015_1deg.defaults +COMP_LABEL&& = ame2 +COMP_TYPE&& = spindust +COMP_NU_REF_T&& = 41 +COMP_NU_P_INPUT_MAP&& = init_ame2_nup_rc2_n256_v03.fits +COMP_SED_TEMPLATE&& = spdust2_cnm.dat +COMP_AMP_INPUT_MAP&& = init_ame2_rc2_n256_v03.fits +COMP_INIT_FROM_HDF&& = none +@END 07 + + +# CO10 line emission +@START 08 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co100 +COMP_NU_REF_T&& = 115.27 +COMP_BAND_REF&& = 100-ds1 +COMP_LINE_TEMPLATE&& = co100_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co10_rc2_n256_v03.fits +@END 08 + +# CO21 line emission +@START 09 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co217 +COMP_NU_REF_T&& = 230.54 +COMP_BAND_REF&& = 217-1 +COMP_LINE_TEMPLATE&& = co217_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co21_rc2_n256_v03.fits +@END 09 + +# CO32 line emission +@START 10 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = co353 +COMP_NU_REF_T&& = 345.81 +COMP_BAND_REF&& = 353-ds2 +COMP_LINE_TEMPLATE&& = co353_line_template_planck2015_1deg_v1.dat +COMP_AMP_INPUT_MAP&& = init_co32_rc2_n256_v03.fits +@END 10 + +# HCN line emission +@START 11 +@DEFAULT components/co/co_planck2015_1deg.defaults +COMP_LABEL&& = hcn +COMP_NU_REF_T&& = 88.6 +COMP_BAND_REF&& = 100-ds1 +COMP_LINE_TEMPLATE&& = /mn/stornext/d5/data/metins/dirbe/data/hcn_line_template_DIRBE_v1.dat +COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits +@END 11 + +# SZ placeholder -- not implemented yet +@START 12 +@DEFAULT components/cmb/cmb_planck2015_1deg.defaults +COMP_LABEL&& = sz +COMP_AMP_INPUT_MAP&& = init_cmb_rc2_n256_v03.fits +COMP_MONOPOLE_PRIOR&& = none +@END 12 + +# Mono- and dipole component +@START 13 +@DEFAULT components/monodipole/md_LFI.defaults +COMP_MD_MONO_FROM_PRIORS&& = none +COMP_MD_DEFINITION_FILE&& = init_md_ci.dat +COMP_INIT_FROM_HDF&& = none +@END 13 + + + + + + + + + +NUM_CG_SAMPLING_GROUPS = 2 +NUM_MCMC_SAMPLING_GROUPS = 0 + + +@START 01 +CG_SAMPLING_GROUP&& = co100,co217,co353 +CG_SAMPLING_GROUP_MASK&& = fullsky +CG_SAMPLING_GROUP_MAXITER&& = 60 +CG_SAMPLING_GROUP_BANDS&& = all +@END 01 + +@START 02 +CG_SAMPLING_GROUP&& = cmb,ff,ame,synch,dust +CG_SAMPLING_GROUP_MASK&& = fullsky +CG_SAMPLING_GROUP_MAXITER&& = 60 +CG_SAMPLING_GROUP_BANDS&& = all +@END 02 + +#@START 02 +#CG_SAMPLING_GROUP&& = md +#CG_SAMPLING_GROUP_MASK&& = mask_chisq_15band_n256_v2_ptsrc.fits +#CG_SAMPLING_GROUP_MAXITER&& = 7 +#CG_SAMPLING_GROUP_BANDS&& = all +#@END 02 + + + +NUM_SMOOTHING_SCALES = 1 +SMOOTHING_SCALE_FWHM01 = 60. # Arcmin; 0 = native resolution +SMOOTHING_SCALE_LMAX01 = 750 +SMOOTHING_SCALE_NSIDE01 = 256 # Must match NSIDE of component it is used for +SMOOTHING_SCALE_PIXWIN01 = pixel_window_n0256.fits +SMOOTHING_SCALE_FWHM_POSTPROC01 = 60. # Smoothing FWHM after pixel-by-pixel fit + + + +# ------------------------------------------------------------------ +# ZODI +# ------------------------------------------------------------------ +@DEFAULT components/zodi/sampling.defaults +@DEFAULT components/zodi/components.defaults + +# HYPER PARAMETERS +# ------------------------------------------------------------------ +ZODI_DELTA_T_RESET = 1 +ZODI_INIT_CHAIN = none /mn/stornext/d5/data/metins/dirbe/data/zodi_init_chain_test.h5:0 +ZODI_N_LOS_STEP = 15 +ZODI_OUTPUT_COMP_MAPS = .false. + + +# ------------------------------------------------------------------ +# ZODI +# ------------------------------------------------------------------ +@DEFAULT components/zodi/sampling.defaults +@DEFAULT components/zodi/components.defaults + +# HYPER PARAMETERS +# ------------------------------------------------------------------ +ZODI_DELTA_T_RESET = 0.1 +ZODI_TOD_THINNING_FACTOR = 0.005 # Fraction of TOD samples to include in fitting +ZODI_TOD_THINNING_THRESHOLD = 8 # Only neglect samples with lower deviation than this (in sigma) +ZODI_OUTPUT_COMP_MAPS = .false. +ZODI_OUTPUT_ASCII = .true. +ZODI_OPERATION = powell # {sample,powell} +ZODI_INIT_FROM_ASCII = /mn/stornext/d23/cmbco/cg/dirbe/data/init_zodi_dirbe_prod_v16.dat +ZODI_RMS_RANDOMIZE_BETWEEN_STEPS = 0.3 +ZODI_SAMP_METHOD = powell +ZODI_REFERENCE_BAND = 05a +ZODI_GLOBAL_EMISSIVITY_COMPONENT = none cloud +ZODI_GLOBAL_ALBEDO_COMPONENT = cloud +ZODI_JOINT_MONOPOLE_SAMPLING = .false. +ZODI_MIN_SOLAR_ELONGATION = 90 68 +ZODI_MAX_SOLAR_ELONGATION = 120 +ZODI_OUTPUT_TOD_RESIDUALS = .false. +ZODI_USE_SOLAR_CENTRIC_COMP = .true. +ZODI_STATIC_COMP_NSIDE = 512 +ZODI_STATIC_COMP_INITMAP = init_zodi_static_v18.fits +ZODI_STATIC_MAP_BANDS = 05a,05b + +# Only emissivity wires support right now +#ZODI_PARAMETER_WIRING = band1:em@03a>cloud:em@03a,band1:em@03b>cloud:em@03b,band2:em>band1:em,band3:em>band1:em,ring:em@03a>cloud:em@03a,ring:em@03b>cloud:em@03b,feature:em>ring:em +#ZODI_PARAMETER_WIRING = band2:em>band1:em,band3:em>band1:em,feature:em>ring:em +ZODI_PARAMETER_WIRING = band2:em>band1:em,band3:em>band1:em + +# COMPONENTS +# ------------------------------------------------------------------ +NUM_ZODI_COMPS = 7 + +! PARAMETER VALUE FORMAT: comma separated list of values and priors +! valid examples: ZODI_T_0 = 286.0 (no prior) +! ZODI_T_0 = 286.0,none,1,uniform (interprets the prior as a uniform prior smaller than 1) +! ZODI_T_0 = 286.0,0,none,uniform (interprets the prior as a uniform prior greater than 0) +! ZODI_T_0 = 286.0,0,1,uniform (interprets the prior as a uniform prior between 0 and 1) +! ZODI_T_0 = 286.0,3,0.4,gauss (interprets the prior as a gaussian with mean 3 and sigma 0.4) +ZODI_T_0 = 286.0 +ZODI_T_DELTA = 0.4668626 + +@START 01 +ZODI_COMP_TYPE&& = cloud +ZODI_COMP_LABEL&& = cloud +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 5.2 + +ZODI_COMP_N_0&& = 1.1344373881427960d-07 +ZODI_COMP_X_0&& = 0.011887800744346281 +ZODI_COMP_Y_0&& = 0.0054765064662263777 +ZODI_COMP_Z_0&& = -0.0021530908020710744 +ZODI_COMP_I&& = 2.0335188072390769 +ZODI_COMP_OMEGA&& = 77.657955554097114 +ZODI_COMP_ALPHA&& = 1.3370696705930281 +ZODI_COMP_BETA&& = 4.1415004157586637 +ZODI_COMP_GAMMA&& = 0.94206179393358036 +ZODI_COMP_MU&& = 0.18873176489090190 +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v91.h5:8 +@END 01 + +@START 02 +ZODI_COMP_TYPE&& = band +ZODI_COMP_LABEL&& = band1 +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 5.2 + +ZODI_COMP_N_0&& = 5.5890290403228370d-10 +ZODI_COMP_X_0&& = 0.0 +ZODI_COMP_Y_0&& = 0.0 +ZODI_COMP_Z_0&& = 0.0 +ZODI_COMP_I&& = 0.56438265154389733 +ZODI_COMP_OMEGA&& = 80.0 +ZODI_COMP_DELTA_ZETA&& = 8.7850534408713035 +ZODI_COMP_V&& = 0.10000000149011612 +ZODI_COMP_P&& = 4.0 +ZODI_COMP_DELTA_R&& = 1.5 +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v91.h5:8 +@END 02 + +@START 03 +ZODI_COMP_TYPE&& = band +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_LABEL&& = band2 +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 5.2 + +ZODI_COMP_N_0&& = 1.9877609422590801d-09 +ZODI_COMP_X_0&& = 0.0 +ZODI_COMP_Y_0&& = 0.0 +ZODI_COMP_Z_0&& = 0.0 +ZODI_COMP_I&& = 1.2000000476837158 +ZODI_COMP_OMEGA&& = 30.347475578624532 +ZODI_COMP_DELTA_ZETA&& = 1.9917032425777641 +ZODI_COMP_V&& = 0.89999997615814209 +ZODI_COMP_P&& = 4.0 +ZODI_COMP_DELTA_R&& = 0.94121881201651147 +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v91.h5:8 +@END 03 + +@START 04 +ZODI_COMP_TYPE&& = band +ZODI_COMP_LABEL&& = band3 +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 5.2 + +ZODI_COMP_N_0&& = 1.4369827283512384d-10 +ZODI_COMP_X_0&& = 0.0 +ZODI_COMP_Y_0&& = 0.0 +ZODI_COMP_Z_0&& = 0.0 +ZODI_COMP_I&& = 0.80000001192092896 +ZODI_COMP_OMEGA&& = 80.0 +ZODI_COMP_DELTA_ZETA&& = 15 +ZODI_COMP_V&& = 0.050000000745058060 +ZODI_COMP_P&& = 4.0 +ZODI_COMP_DELTA_R&& = 1.5 +ZODI_COMP_INIT_FROM_HDF&& = none +@END 04 + +@START 05 +ZODI_COMP_TYPE&& = ring +ZODI_COMP_LABEL&& = ring +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 1.5 + +ZODI_COMP_N_0&& = 1.8260527826501675d-08 +ZODI_COMP_X_0&& = 0.0 +ZODI_COMP_Y_0&& = 0.0 +ZODI_COMP_Z_0&& = 0.0 +ZODI_COMP_I&& = 0.48707166006819241 +ZODI_COMP_OMEGA&& = 22.278979678854448 +ZODI_COMP_R&& = 1.0281924326308751 +ZODI_COMP_SIGMA_R&& = 0.025000000372529030 +ZODI_COMP_SIGMA_Z&& = 0.054068037356978099 +ZODI_COMP_THETA&& = 0.0 +ZODI_COMP_SIGMA_THETA&& = 0.0001 +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v91.h5:8 +@END 05 + +@START 06 +ZODI_COMP_TYPE&& = feature +ZODI_COMP_LABEL&& = feature +ZODI_COMP_INCLUDE&& = .true. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 1.5 + +ZODI_COMP_N_0&& = 2.0094267183590947d-08 +ZODI_COMP_X_0&& = 0.0 +ZODI_COMP_Y_0&& = 0.0 +ZODI_COMP_Z_0&& = 0.0 +ZODI_COMP_I&& = 0.48707166006819241 +ZODI_COMP_OMEGA&& = 22.278979678854448 +ZODI_COMP_R&& = 1.0579182694524214 +ZODI_COMP_SIGMA_R&& = 0.10287314662396611 +ZODI_COMP_SIGMA_Z&& = 0.091442963768716023 +ZODI_COMP_THETA&& = -10.0 +ZODI_COMP_SIGMA_THETA&& = 12.115210933938741 +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v88.h5:7 +@END 06 + +@START 07 +ZODI_COMP_TYPE&& = interstellar +ZODI_COMP_LABEL&& = interstellar +ZODI_COMP_INCLUDE&& = .false. +ZODI_COMP_N_LOS_STEP&& = 50 +ZODI_COMP_R_MIN&& = 0.0 +ZODI_COMP_R_MAX&& = 30 + +ZODI_COMP_N_0&& = 1.1344373881427960d-10 +ZODI_COMP_X_0&& = 0. +ZODI_COMP_Y_0&& = 0. +ZODI_COMP_Z_0&& = 0. +ZODI_COMP_I&& = 0 +ZODI_COMP_OMEGA&& = 0 +ZODI_COMP_R&& = 0. +ZODI_COMP_ALPHA&& = 0. +ZODI_COMP_INIT_FROM_HDF&& = none /mn/stornext/u3/hke/data_d5/dirbe/zodi/data/init_chain_hke_v91.h5:8 +@END 07 From 8b8de1d91ba8faf1c601ff952dc1d91971afd6b2 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 31 Jan 2025 19:45:18 +0100 Subject: [PATCH 087/171] Implemented new ptsrc preconditioner based on PARDISO, a sparse matrix solver. Next step: Optimize --- cmake/projects/commander3.cmake | 1 + commander3/src/Makefile | 8 +- commander3/src/comm_cr_mod.f90 | 133 +++++---- commander3/src/comm_cr_precond_mod.f90 | 13 +- commander3/src/comm_diffuse_comp_smod.f90 | 6 + commander3/src/comm_ptsrc_comp_mod.f90 | 330 +++++++++++++++------ commander3/src/comm_signal_mod.f90 | 40 +-- commander3/src/comm_sparse_mod.f90 | 332 ++++++++++++++++++++++ commander3/src/commander.f90 | 3 +- 9 files changed, 695 insertions(+), 171 deletions(-) create mode 100644 commander3/src/comm_sparse_mod.f90 diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 3e75bb22c..79188261f 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -132,6 +132,7 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_conviqt_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_map_mod.f90 ${COMMANDER3_SOURCE_DIR}/math_tools.f90 + ${COMMANDER3_SOURCE_DIR}/comm_sparse_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_cr_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_mbb_comp_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_mbbtab_comp_mod.f90 diff --git a/commander3/src/Makefile b/commander3/src/Makefile index 7b2c178e6..d29ffedae 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -28,6 +28,7 @@ F90SOURCES=hashtbl.f90 \ hmc_mod.f90 \ comm_hdf_mod.f90 \ sharp.f90 \ + comm_sparse_mod.f90 \ sort_utils.f90 \ ars_mod.f90 \ math_tools.f90 \ @@ -153,6 +154,7 @@ hashtbl.o : sharp.o : locate_mod.o : math_tools.o : +comm_sparse_mod.o : math_tools.o powell_mod.o : hmc_mod.o : spline_1d_mod.o : math_tools.o locate_mod.o @@ -233,7 +235,7 @@ comm_f_mod.o : comm_f_int_mod.o comm_f_int_0d_mod.o comm_f_int_1d comm_cl_mod.o : comm_map_mod.o comm_bp_utils.o comm_diffuse_comp_mod.o : comm_f_mod.o comm_cl_mod.o comm_diffuse_comp_smod.o : comm_diffuse_comp_mod.o -comm_ptsrc_comp_mod.o : comm_f_mod.o +comm_ptsrc_comp_mod.o : comm_f_mod.o comm_sparse_mod.o comm_template_comp_mod.o : comm_f_mod.o comm_comp_interface_mod.o : comm_diffuse_comp_mod.o comm_ptsrc_comp_mod.o comm_template_comp_mod.o @@ -265,9 +267,9 @@ comm_signal_mod.o : comm_chisq_mod.o comm_cr_mod.o comm_ame_lognormal_ comm_mh_specind_mod.o : comm_signal_mod.o comm_gain_mod.o : comm_signal_mod.o comm_nonlin_mod.o : comm_gain_mod.o - comm_nonlin_smod.o : comm_nonlin_mod.o +comm_nonlin_smod.o : comm_nonlin_mod.o -commander.o : comm_nonlin_mod.o comm_mh_specind_mod.o comm_zodi_samp_mod.o +commander.o : comm_nonlin_mod.o comm_mh_specind_mod.o comm_zodi_samp_mod.o comm_sparse_mod.o diff --git a/commander3/src/comm_cr_mod.f90 b/commander3/src/comm_cr_mod.f90 index 25b85c676..cdbc284e8 100644 --- a/commander3/src/comm_cr_mod.f90 +++ b/commander3/src/comm_cr_mod.f90 @@ -46,7 +46,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) integer(i4b) :: i, j, k, l, m, n, maxiter, root, ierr integer(i4b), save :: samp_group_prev real(dp) :: eps, tol, delta0, delta_new, delta_old, alpha, beta, t1, t2, t3, t4 - real(dp) :: lim_convergence, val_convergence, chisq, chisq_prev, buff + real(dp) :: lim_convergence, val_convergence, chisq, chisq_prev, buff, dq real(dp), allocatable, dimension(:) :: Ax, r, d, q, temp_vec, s, x_out real(dp), allocatable, dimension(:,:) :: alm, pamp class(comm_comp), pointer :: c => null() @@ -94,7 +94,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) deallocate(alm) end if class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then call cr_extract_comp(c%id, x, pamp) do j = 1, c%nmaps do i = 1, c%nsrc @@ -139,6 +139,15 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) !!$ call mpi_finalize(ierr) !!$ stop +!!$ x = 0.d0 +!!$ x(1) = 1.d0 +!!$ r = cr_matmulA(x, samp_group) ! x is zero +!!$ +!!$ write(*,*) 'Ax = ', r +!!$ +!!$ call mpi_finalize(ierr) +!!$ stop + call update_status(status, "cr4") r = b - cr_matmulA(x, samp_group) ! x is zero call update_status(status, "cr5") @@ -194,7 +203,12 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) !if (delta_new < eps * delta0 .and. (i >= cpar%cg_miniter .or. delta_new <= 1d-30 * delta0)) exit q = cr_matmulA(d, samp_group) - alpha = delta_new / mpi_dot_product(cpar%comm_chain, d, q) + dq = mpi_dot_product(cpar%comm_chain, d, q) +!!$ if (dq == 0.d0) then +!!$ val_convergence = 0.d0 +!!$ cycle +!!$ end if + alpha = delta_new / dq x = x + alpha * d ! Restart every 50th iteration to suppress numerical errors @@ -203,8 +217,8 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) else r = r - alpha*q end if - - call update_status(status, "cg3") + + call update_status(status, "cg3") call wall_time(t3) s = cr_invM(cpar%comm_chain, r, samp_group) call wall_time(t4) @@ -239,7 +253,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) deallocate(alm) end if class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then call cr_extract_comp(c%id, x_out, pamp) do j = 1, c%nmaps do k = 1, c%nsrc @@ -313,7 +327,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) deallocate(alm) end if class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then call cr_extract_comp(c%id, x, pamp) do j = 1, c%nmaps do k = 1, c%nsrc @@ -383,7 +397,7 @@ subroutine cr_compute_chisq(comm, samp_group, x, chisq) deallocate(alm) end if class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then call cr_extract_comp(c%id, x_out, pamp) do j = 1, c%nmaps do k = 1, c%nsrc @@ -429,9 +443,9 @@ subroutine cr_amp2x_full(samp_group, x) ind = ind + c%x%info%nalm end do class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0) then do i = 1, c%nmaps - if (c%active_samp_group(samp_group)) x(ind:ind+c%nsrc-1) = c%x(:,i) + if (c%active_samp_group(samp_group)) x(ind:ind+c%nsrc-1) = c%x(1:c%nsrc,i) ind = ind + c%nsrc end do end if @@ -466,7 +480,7 @@ subroutine cr_x2amp_full(samp_group, x) class is (comm_ptsrc_comp) do i = 1, c%nmaps if (c%myid == 0) then - if (c%active_samp_group(samp_group)) c%x(:,i) = x(ind:ind+c%nsrc-1) + if (c%active_samp_group(samp_group)) c%x(1:c%nsrc,i) = x(ind:ind+c%nsrc-1) ind = ind + c%nsrc end if end do @@ -608,20 +622,19 @@ subroutine cr_computeRHS(operation, resamp_cmb, only_pol, handle, handle_noise, call Tm%dealloc(); deallocate(Tm) nullify(info) class is (comm_ptsrc_comp) - if(.not. c%precomputed_amps) then - - allocate(Tp(c%nsrc,c%nmaps)) - Tp = c%projectBand(i,map) - if (c%myid == 0) then - do j = 1, c%nmaps - do k = 1, c%nsrc - Tp(k,j) = Tp(k,j) * c%src(k)%P_x(j,2) - end do - end do - call cr_insert_comp(c%id, .true., Tp, rhs) - end if - deallocate(Tp) + allocate(Tp(c%nsrc,c%nmaps)) + Tp = c%projectBand(i,map) + if (c%myid == 0) then + if (allocated(c%src(1)%P_x)) then + do j = 1, c%nmaps + do k = 1, c%nsrc + Tp(k,j) = Tp(k,j) * c%src(k)%P_x(j,2) + end do + end do + end if + call cr_insert_comp(c%id, .true., Tp, rhs) end if + deallocate(Tp) class is (comm_template_comp) allocate(Tp(1,1)) Tp = c%projectBand(i,map) @@ -678,27 +691,25 @@ subroutine cr_computeRHS(operation, resamp_cmb, only_pol, handle, handle_noise, deallocate(eta) end if class is (comm_ptsrc_comp) - if (.not. c%precomputed_amps) then - if (c%myid == 0) then - allocate(eta(1:c%nsrc,c%nmaps)) - eta = 0.d0 - ! Variance term - if (trim(operation) == 'sample') then - do j = 1, c%nmaps - do i = 1, c%nsrc - eta(i,j) = rand_gauss(handle) - end do - end do - end if - ! Mean term - do j = 1, c%nmaps - do i = 1, c%nsrc - eta(i,j) = eta(i,j) + c%src(i)%P_x(j,1)/c%src(i)%P_x(j,2) - end do - end do - call cr_insert_comp(c%id, .true., eta, rhs) - deallocate(eta) - end if + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then + allocate(eta(1:c%nsrc,c%nmaps)) + eta = 0.d0 + ! Variance term + if (trim(operation) == 'sample') then + do j = 1, c%nmaps + do i = 1, c%nsrc + eta(i,j) = rand_gauss(handle) + end do + end do + end if + ! Mean term + do j = 1, c%nmaps + do i = 1, c%nsrc + eta(i,j) = eta(i,j) + c%src(i)%P_x(j,1)/c%src(i)%P_x(j,2) + end do + end do + call cr_insert_comp(c%id, .true., eta, rhs) + deallocate(eta) end if class is (comm_template_comp) if (c%myid == 0) then @@ -750,7 +761,7 @@ function cr_matmulA(x, samp_group) !call update_status(status, "A3") c => compList lmax = -1 -! !write(*,*) 'df2' + ! !write(*,*) 'df2' do while (associated(c)) if (.not. c%active_samp_group(samp_group)) then c => c%nextComp() @@ -769,7 +780,7 @@ function cr_matmulA(x, samp_group) end if lmax = max(max(lmax, c%lmax_amp),2) class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then call cr_extract_comp(c%id, sqrtS_x, pamp) do j = 1, c%nmaps do i = 1, c%nsrc @@ -832,13 +843,11 @@ function cr_matmulA(x, samp_group) deallocate(alm, m) !write(*,*) 'df6' class is (comm_ptsrc_comp) - if(.not. c%precomputed_amps) then - call cr_extract_comp(c%id, sqrtS_x, pamp) - allocate(m(0:data(i)%info%np-1,data(i)%info%nmaps)) - m = c%getBand(i, amp_in=pamp) - pmap%map = pmap%map + m - deallocate(pamp, m) - end if + call cr_extract_comp(c%id, sqrtS_x, pamp) + allocate(m(0:data(i)%info%np-1,data(i)%info%nmaps)) + m = c%getBand(i, amp_in=pamp) + pmap%map = pmap%map + m + deallocate(pamp, m) class is (comm_template_comp) call cr_extract_comp(c%id, sqrtS_x, pamp) allocate(m(0:data(i)%info%np-1,data(i)%info%nmaps)) @@ -877,7 +886,7 @@ function cr_matmulA(x, samp_group) call wall_time(t2) !call update_status(status, "A12") !if (myid == 0) write(*,fmt='(a,f8.2)') 'invN time = ', real(t2-t1,sp) - + ! Project summed map into components, ie., row-wise matrix elements call wall_time(t1) c => compList @@ -905,12 +914,10 @@ function cr_matmulA(x, samp_group) call cr_insert_comp(c%id, .true., alm, y) deallocate(alm) class is (comm_ptsrc_comp) - if(.not. c%precomputed_amps) then - allocate(pamp(0:c%nsrc-1,c%nmaps)) - pamp = c%projectBand(i, map) - if (c%myid == 0) call cr_insert_comp(c%id, .true., pamp, y) - deallocate(pamp) - end if + allocate(pamp(0:c%nsrc-1,c%nmaps)) + pamp = c%projectBand(i, map) + if (c%myid == 0) call cr_insert_comp(c%id, .true., pamp, y) + deallocate(pamp) class is (comm_template_comp) allocate(pamp(1,1)) pamp = c%projectBand(i, map) @@ -927,7 +934,7 @@ function cr_matmulA(x, samp_group) end do !call update_status(status, "A16") !write(*,*) 'df6' - + ! Add prior term and multiply with sqrt(S) for relevant components call wall_time(t1) c => compList @@ -954,7 +961,7 @@ function cr_matmulA(x, samp_group) end if !write(*,*) 'df9' class is (comm_ptsrc_comp) - if (c%myid == 0 .and. .not. c%precomputed_amps) then + if (c%myid == 0 .and. allocated(c%src(1)%P_x)) then ! Multiply with sqrt(Cl) call cr_extract_comp(c%id, y, pamp) do j = 1, c%nmaps diff --git a/commander3/src/comm_cr_precond_mod.f90 b/commander3/src/comm_cr_precond_mod.f90 index 516d6343b..00bb40ec9 100644 --- a/commander3/src/comm_cr_precond_mod.f90 +++ b/commander3/src/comm_cr_precond_mod.f90 @@ -20,6 +20,7 @@ !================================================================================ module comm_cr_precond_mod use comm_utils + use comm_sparse_mod implicit none type invM @@ -28,10 +29,16 @@ module comm_cr_precond_mod real(dp), allocatable, dimension(:,:) :: M0, M end type invM + type invM_sparse + integer(i4b) :: n + integer(i4b), allocatable, dimension(:) :: ind, comp2ind + class(sparse_system), pointer :: M + end type invM_sparse + type precond - type(invM), allocatable, dimension(:,:) :: invM_diff ! (0:nalm-1,nmaps) - type(invM), allocatable, dimension(:,:) :: invM_src ! (1,nmaps) - type(invM), allocatable, dimension(:,:) :: invM_temp ! (1,1) + type(invM), allocatable, dimension(:,:) :: invM_diff ! (0:nalm-1,nmaps) + type(invM_sparse), allocatable, dimension(:,:) :: invM_src ! (1,nmaps) + type(invM), allocatable, dimension(:,:) :: invM_temp ! (1,1) end type precond type(precond), allocatable, dimension(:) :: P_cr ! (n_sampgroup) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 36f505c60..c6e9afe61 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -1291,6 +1291,8 @@ module subroutine initDiffPrecond(comm, samp_group) implicit none integer(i4b), intent(in) :: comm, samp_group + if (npre == 0) return + select case (trim(precond_type)) case ("diagonal") call initDiffPrecond_diagonal(comm, samp_group) @@ -1441,6 +1443,8 @@ module subroutine updateDiffPrecond(samp_group, force_update) integer(i4b), intent(in) :: samp_group logical(lgt), intent(in) :: force_update + if (npre == 0) return + select case (trim(precond_type)) case ("diagonal") call updateDiffPrecond_diagonal(samp_group, force_update) @@ -2173,6 +2177,8 @@ module subroutine applyDiffPrecond(x, samp_group) real(dp), dimension(:), intent(inout) :: x integer(i4b), intent(in) :: samp_group + if (npre == 0) return + select case (trim(precond_type)) case ("diagonal") call applyDiffPrecond_diagonal(x, samp_group) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 487c083a5..75bff5c5c 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -89,7 +89,7 @@ module comm_ptsrc_comp_mod integer(i4b) :: myid_pre = -1 integer(i4b) :: numprocs_pre = -1 logical(lgt) :: recompute_ptsrc_precond = .false. - logical(lgt) :: apply_ptsrc_precond = .false. + logical(lgt) :: apply_ptsrc_precond = .true. character(len=24), private :: operation @@ -514,7 +514,7 @@ function projectPtsrcBand(self, band, map, alm_in, det) if(self%precomputed_amps) then ! so far just used for stars - m = self%src(i)%amp_precomp(band_active) *self%x(i,j) + m = self%src(i)%amp_precomp(band_active) !*self%x(i,j) else m = self%src(i)%T(band_active)%F(j,d) end if @@ -777,14 +777,18 @@ subroutine read_sources(self, cpar, id, id_abs) end do end if if (skip_src) then - self%nsrc = self%nsrc-1 + self%nsrc = self%nsrc-1 + npre = npre - 1 + nmaps_pre = max(nmaps_pre, nmaps) + self%ncr_tot = self%ncr_tot - nmaps + if (cpar%myid_chain == 0) self%ncr = self%ncr - nmaps else i = i+1 allocate(self%src(i)%theta(self%npar,self%nmaps), self%src(i)%T(nactive)) allocate(self%src(i)%theta_rms(self%npar,self%nmaps)) allocate(self%src(i)%amp_rms(self%nmaps)) allocate(self%src(i)%P_theta(self%npar,self%nmaps,2)) - allocate(self%src(i)%P_x(self%nmaps,2)) +! allocate(self%src(i)%P_x(self%nmaps,2)) self%src(i)%id = id_ptsrc self%src(i)%glon = glon * DEG2RAD self%src(i)%glat = glat * DEG2RAD @@ -792,8 +796,8 @@ subroutine read_sources(self, cpar, id, id_abs) self%x(i,:) = amp / self%cg_scale !if (self%myid == 0) write(*,*) 'amp', self%x(i,:) self%src(i)%vec = vec - self%src(i)%P_x(:,1) = amp / self%cg_scale - self%src(i)%P_x(:,2) = amp_rms / self%cg_scale +! self%src(i)%P_x(:,1) = amp / self%cg_scale + ! self%src(i)%P_x(:,2) = amp_rms / self%cg_scale self%src(i)%P_theta(:,:,1) = beta self%src(i)%P_theta(:,:,2) = beta_rms self%src(i)%theta_rms = 0.d0 @@ -871,7 +875,6 @@ subroutine read_sources(self, cpar, id, id_abs) call init_beam_templates(self, cpar, id, id_abs) - end subroutine read_sources @@ -954,9 +957,10 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) type(hdf_file) :: stars_file - integer(i4b) :: i, j, ja + integer(i4b) :: i, j, k, ja, ii, ierr + real(dp) :: vec(3), dist character(len=512), dimension(:), allocatable :: band_list - logical(lgt) :: found + logical(lgt) :: found, skip_src real(dp), dimension(:,:), allocatable :: catalog, star_catalog, coords call open_hdf_file(trim(adjustl(cpar%cs_catalog(id_abs))), stars_file, 'r') @@ -992,50 +996,63 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) allocate(self%x(self%nsrc,self%nmaps), self%x_buff(self%nsrc,self%nmaps), self%src(self%nsrc)) - self%x = 0.d0 - self%x(1,1) = 1.d0 + self%x = 1.d0 +! self%x(1,1) = 1.d0 !store each pointsource in a source object + self%ncr = 0 + self%ncr_tot = 0 + ii = 0 do i=1, self%nsrc - allocate(self%src(i)%amp_precomp(self%nactive)) - allocate(self%src(i)%T(self%nactive)) - !self%src(i)%glon = coords(1,i) * DEG2RAD - !self%src(i)%glat = coords(2,i) * DEG2RAD - self%src(i)%glon = coords(1,i) - self%src(i)%glat = coords(2,i) -!!$ write(*,*) i, coords(:,i) -!!$ write(*,*) i, self%src(i)%glon, self%src(i)%glat -!!$ write(*,*) - - ! Normalize to first frequency - self%src(i)%amp_precomp = star_catalog(:,i)/star_catalog(1,i) + if (myid_pre == 0) then + if (mod(ii,10000) == 0) then + write(*,fmt='(a,i6,a,i6,a,a)') ' | Reading src ', ii, ' of ', self%nsrc + end if + end if - do j=1, numband !self%nactive - ja = self%b2a(j) - if (ja == -1) cycle - self%src(i)%T(ja)%nside = data(j)%info%nside - self%src(i)%T(ja)%nside_febecop = self%nside_febecop - !self%src(i)%T(j)%np = - self%src(i)%T(ja)%nmaps = self%nmaps - end do + ii = ii+1 + self%src(ii)%glon = coords(1,i) + self%src(ii)%glat = coords(2,i) + call ang2vec(0.5d0*pi-coords(2,i), coords(1,i), self%src(ii)%vec) + ! Check for too close neighbours + skip_src = .false. + if (cpar%cs_min_src_dist(id_abs) > 0.d0) then + do j = 1+self%myid, ii-1, self%numprocs + call angdist(self%src(ii)%vec, self%src(j)%vec, dist) + if (dist*RAD2DEG*60.d0 < cpar%cs_min_src_dist(id_abs)) then + skip_src = .true. + exit + end if + end do + end if + call mpi_allreduce(MPI_IN_PLACE, skip_src, 1, MPI_LOGICAL, & + & MPI_LOR, self%comm, ierr) + if (skip_src) then + ii = ii-1 + cycle + end if - ! Check for processing mask; disable source if within mask -! call ang2pix_ring(data(1)%info%nside, 0.5d0*pi-glat*DEG2RAD, glon*DEG2RAD, pix) -! p = locate(data(1)%info%pix, pix) -! if (associated(data(1)%procmask)) then -! if (p > 0) then -! if (data(1)%info%pix(p) == pix) then -! do j = 1, self%nmaps -! if (data(1)%procmask%map(p,j) < 0.5d0) then -! mask(i,j) = 0 -! end if -! end do -! end if -! end if -! end if + allocate(self%src(ii)%amp_precomp(self%nactive)) + allocate(self%src(ii)%T(self%nactive)) + npre = npre + 1 + nmaps_pre = max(nmaps_pre, self%nmaps) + self%ncr_tot = self%ncr_tot + self%nmaps + if (cpar%myid_chain == 0) self%ncr = self%ncr + self%nmaps + + ! Normalize to first frequency + self%src(ii)%amp_precomp = star_catalog(:,i)/star_catalog(1,i) + + do j=1, numband !self%nactive + ja = self%b2a(j) + if (ja == -1) cycle + self%src(ii)%T(ja)%nside = data(j)%info%nside + self%src(ii)%T(ja)%nside_febecop = self%nside_febecop + self%src(ii)%T(ja)%nmaps = self%nmaps + end do end do - + self%nsrc = ii + self%cg_scale=1 deallocate(star_catalog, coords) @@ -1045,6 +1062,18 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) !load in the beam information call init_beam_templates(self, cpar, id, id_abs) + ! Update mixing matrix + do i=1, self%nsrc + do j=1, numband !self%nactive + ja = self%b2a(j) + if (ja == -1) cycle + do k = 0, data(j)%ndet ! Only T for now + self%src(i)%T(ja)%F(1,k) = self%src(i)%amp_precomp(self%b2a(j)) + end do + end do + end do + + end subroutine read_star_catalogue @@ -1502,26 +1531,98 @@ subroutine initPtsrcPrecond(comm, samp_group) integer(i4b), intent(in) :: comm, samp_group integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt - real(dp) :: t1, t2, t3, t4 + real(dp) :: t1, t2, t3, t4, dist, tot logical(lgt) :: skip + real(dp), allocatable, dimension(:) :: buff class(comm_comp), pointer :: c => null(), c1 => null(), c2 => null() class(comm_ptsrc_comp), pointer :: pt1 => null(), pt2 => null() real(dp), allocatable, dimension(:,:) :: mat, mat2 + if (npre == 0) return if (ncomp_pre == 0) return if (.not. recompute_ptsrc_precond) return if (.not. apply_ptsrc_precond) return - if (allocated(P_cr(samp_group)%invM_src)) deallocate(P_cr(samp_group)%invM_src) + if (allocated(P_cr(samp_group)%invM_src)) then + do j = 1, nmaps_pre + call P_cr(samp_group)%invM_src(1,j)%M%dealloc() + end do + deallocate(P_cr(samp_group)%invM_src) + end if call mpi_comm_rank(comm, myid, ierr) - + ! Build frequency-dependent part of preconditioner call wall_time(t1) allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) - allocate(mat(npre,npre), mat2(npre,npre)) + !allocate(mat(npre,npre), mat2(npre,npre)) do j = 1, nmaps_pre - mat = 0.d0 + ! Find number of matrix elements + if (myid_pre == 0) then + n = 0 + i1 = 0 + c1 => compList + do while (associated(c1)) + skip = .true. + select type (c1) + class is (comm_ptsrc_comp) + pt1 => c1 + skip = j > pt1%nmaps + end select + if (skip) then + c1 => c1%nextComp() + cycle + end if + do k1 = 1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc, n + i1 = i1+1 + + i2 = 0 + c2 => compList + do while (associated(c2)) + !do j2 = 1, ncomp_pre + skip = .true. + select type (c2) + class is (comm_ptsrc_comp) + pt2 => c2 + skip = j > pt2%nmaps + end select + if (skip) then + c2 => c2%nextComp() + cycle + end if + do k2 = 1, pt2%nsrc + !write(*,*) k2, pt2%nsrc + i2 = i2+1 + if (i2 < i1) cycle + !if (mod(k2,nprocs) == myid) then + !call angdist(pt1%src(k1)%vec, pt2%src(k2)%vec, dist) + dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) +!!$ write(*,*) k1, k2, dist, dist*180.d0/pi +!!$ write(*,*) pt1%src(k1)%vec +!!$ write(*,*) pt2%src(k2)%vec + + if (dist <= 3.d0*pi/180.d0) n = n+1 + !end if + end do + c2 => c2%nextComp() + end do + end do + c1 => c1%nextComp() + end do + !call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) + end if + + if (myid_pre == 0) then + write(*,*) 'Number of matrix elements = ', n + end if + + ! Allocate sparse matrix + call mpi_bcast(n, 1, MPI_INTEGER, 0, comm, ierr) + P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre, n) + + ! Construct matrix + !mat = 0.d0 i1 = 0 c1 => compList do while (associated(c1)) @@ -1529,13 +1630,14 @@ subroutine initPtsrcPrecond(comm, samp_group) select type (c1) class is (comm_ptsrc_comp) pt1 => c1 - skip = .false. + skip = j > pt1%nmaps end select - if (skip .or. j > pt1%nmaps) then + if (skip) then c1 => c1%nextComp() cycle end if do k1 = 1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc !write(*,*) k1, pt1%nsrc i1 = i1+1 @@ -1547,9 +1649,9 @@ subroutine initPtsrcPrecond(comm, samp_group) select type (c2) class is (comm_ptsrc_comp) pt2 => c2 - skip = .false. + skip = j > pt2%nmaps end select - if (skip .or. j > pt2%nmaps) then + if (skip) then c2 => c2%nextComp() cycle end if @@ -1557,7 +1659,11 @@ subroutine initPtsrcPrecond(comm, samp_group) !write(*,*) k2, pt2%nsrc i2 = i2+1 if (i2 < i1) cycle + !call angdist(pt1%src(k1)%vec, pt2%src(k2)%vec, dist) + dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) + if (dist > 3.d0*pi/180.d0) cycle ! Cutoff should be user defined + tot = 0.d0 do l = 1, numband if (pt1%F_null(l)) cycle la = pt1%b2a(l) @@ -1577,11 +1683,13 @@ subroutine initPtsrcPrecond(comm, samp_group) do while (.true.) if (pt1%src(k1)%T(la)%pix(p1,1) == pt2%src(k2)%T(la)%pix(p2,1)) then p = pt1%src(k1)%T(la)%pix(p1,1) -!!$ write(*,*) 'a', data(l)%N%invN_diag%map(p,j) -!!$ write(*,*) 'b', pt1%src(k1)%T(l)%map(p1,j), pt2%src(k2)%T(l)%map(p2,j) -!!$ write(*,*) 'c', pt1%src(k1)%T(l)%F(j,0), pt2%src(k2)%T(l)%F(j,0) -!!$ write(*,*) 'd', pt1%getScale(l,k1,j), pt2%getScale(l,k2,j) - mat(i1,i2) = mat(i1,i2) + & + if (.false. .and. myid == 0) then + write(*,*) 'a', data(l)%N%invN_diag%map(p,j) + write(*,*) 'b', pt1%src(k1)%T(l)%map(p1,j), pt2%src(k2)%T(l)%map(p2,j) + write(*,*) 'c', pt1%src(k1)%T(l)%F(j,0), pt2%src(k2)%T(l)%F(j,0) + write(*,*) 'd', pt1%getScale(l,k1,j), pt2%getScale(l,k2,j) + end if + tot = tot + & & 1.d0/data(l)%N%rms_pix(p,j)**2 * & ! invN_{p,p} & pt1%src(k1)%T(la)%map(p1,j) * & ! B_1 & pt2%src(k2)%T(la)%map(p2,j) * & ! B_2 @@ -1601,7 +1709,10 @@ subroutine initPtsrcPrecond(comm, samp_group) if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(p2,1)) exit end do end do - mat(i2,i1) = mat(i1,i2) + ! Update sparse matrix + !mat(i1,i2) = tot + !mat(i2,i1) = mat(i1,i2) + call P_cr(samp_group)%invM_src(1,j)%M%set_A(i1,i2, tot) end do c2 => c2%nextComp() end do @@ -1610,9 +1721,16 @@ subroutine initPtsrcPrecond(comm, samp_group) end do ! Collect contributions from all cores - call mpi_reduce(mat, mat2, size(mat2), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + allocate(buff(size(P_cr(samp_group)%invM_src(1,j)%M%a))) + call mpi_reduce(P_cr(samp_group)%invM_src(1,j)%M%a, buff, size(P_cr(samp_group)%invM_src(1,j)%M%a), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + P_cr(samp_group)%invM_src(1,j)%M%a = buff + deallocate(buff) + !call mpi_reduce(mat, mat2, size(mat2), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) if (myid == 0) then + write(*,*) "Done reducing" + !call P_cr(samp_group)%invM_src(1,j)%M%print() + ! Multiply with sqrtS from left side i1 = 0 c1 => compList @@ -1621,17 +1739,20 @@ subroutine initPtsrcPrecond(comm, samp_group) select type (c1) class is (comm_ptsrc_comp) pt1 => c1 - skip = .false. + skip = j > pt1%nmaps end select - if (skip .or. j > pt1%nmaps) then + if (skip) then c1 => c1%nextComp() cycle end if do k1 = 1, pt1%nsrc i1 = i1+1 - mat2(i1,:) = mat2(i1,:) * pt1%src(k1)%P_x(j,2) + !mat2(i1,:) = mat2(i1,:) * pt1%src(k1)%P_x(j,2) + !write(*,*) k1, i1, P_cr(samp_group)%invM_src(1,j)%M%ni, pt1%src(k1)%P_x(j,2) + if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%scale_row(i1, pt1%src(k1)%P_x(j,2)) end do c1 => c1%nextComp() + write(*,*) "Done rows" end do ! Multiply with sqrtS from right side i1 = 0 @@ -1641,38 +1762,81 @@ subroutine initPtsrcPrecond(comm, samp_group) select type (c1) class is (comm_ptsrc_comp) pt1 => c1 - skip = .false. + skip = j > pt1%nmaps end select - if (skip .or. j > pt1%nmaps) then + if (skip) then c1 => c1%nextComp() cycle end if do k1 = 1, pt1%nsrc i1 = i1+1 - mat2(:,i1) = mat2(:,i1) * pt1%src(k1)%P_x(j,2) + !mat2(:,i1) = mat2(:,i1) * pt1%src(k1)%P_x(j,2) + if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%scale_col(i1, pt1%src(k1)%P_x(j,2)) end do c1 => c1%nextComp() + write(*,*) "Done cols" end do ! Add unity - do i1 = 1, npre - mat2(i1,i1) = mat2(i1,i1) + 1.d0 + !do i1 = 1, npre + ! mat2(i1,i1) = mat2(i1,i1) + 1.d0 + !end do + i1 = 0 + c1 => compList + do while (associated(c1)) + skip = .true. + select type (c1) + class is (comm_ptsrc_comp) + pt1 => c1 + skip = j > pt1%nmaps + end select + if (skip) then + c1 => c1%nextComp() + cycle + end if + do k1 = 1, pt1%nsrc + i1 = i1+1 + !mat2(:,i1) = mat2(:,i1) * pt1%src(k1)%P_x(j,2) + !if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%add_diag(1.d0, i1) + call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.01d0, i1) + end do + c1 => c1%nextComp() + write(*,*) "Done diag" end do + !call P_cr(samp_group)%invM_src(1,j)%M%add_diag(1.d0) ! Invert matrix to finalize preconditioner call wall_time(t3) - call invert_matrix_with_mask(mat2) + !allocate(buff(npre)) + !call get_eigenvalues(mat2, buff) + !write(*,*) "W = ", buff + !deallocate(buff) + if (myid_pre == 0) write(*,*) 'ptsrc precond before' + !call invert_matrix_with_mask(mat2) + if (.false. .and. myid_pre == 0) then + do i1 = 1, npre + write(*,*) mat2(i1,:) + end do + write(*,*) "---------" + write(*,*) P_cr(samp_group)%invM_src(1,j)%M%ia + write(*,*) P_cr(samp_group)%invM_src(1,j)%M%ja + write(*,*) P_cr(samp_group)%invM_src(1,j)%M%a + end if + call P_cr(samp_group)%invM_src(1,j)%M%decomp() call wall_time(t4) if (myid_pre == 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) - allocate(P_cr(samp_group)%invM_src(1,j)%M(npre,npre)) - P_cr(samp_group)%invM_src(1,j)%M = mat2 + !allocate(P_cr(samp_group)%invM_src(1,j)%M(npre,npre)) + !P_cr(samp_group)%invM_src(1,j)%M = mat2 end if end do call wall_time(t2) if (myid_pre == 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) - deallocate(mat,mat2) +! call mpi_finalize(ierr) +! stop + + !deallocate(mat,mat2) recompute_ptsrc_precond = .false. - apply_ptsrc_precond = .false. + !apply_ptsrc_precond = .false. end subroutine initPtsrcPrecond @@ -1726,7 +1890,9 @@ subroutine applyPtsrcPrecond(x, samp_group) ! Multiply with preconditioner do j = 1, nmaps_pre - y(:,j) = matmul(P_cr(samp_group)%invM_src(1,j)%M, y(:,j)) + !y(:,j) = matmul(P_cr(samp_group)%invM_src(1,j)%M, y(:,j)) + call P_cr(samp_group)%invM_src(1,j)%M%set_rhs(y(:,j)) + call P_cr(samp_group)%invM_src(1,j)%M%solve(y(:,j)) end do ! Reformat y(npre,nmaps) structure back into linear array @@ -1752,7 +1918,7 @@ subroutine applyPtsrcPrecond(x, samp_group) c => c%nextComp() deallocate(amp) end do - + deallocate(y) end subroutine applyPtsrcPrecond @@ -1999,7 +2165,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) ! return end if - if (trim(operation) == 'optimize') then + if (.true. .or. trim(operation) == 'optimize') then !if (self%myid == 0) write(*,*) 'opimize ptsrc spectral parameters' allocate(theta(self%npar)) do iter2 = 1, n_gibbs @@ -2641,9 +2807,11 @@ function lnL_ptsrc_multi(p) if (c_lnL%myid == 0) then ! Apply amplitude prior - if (c_lnL%src(k_lnL)%P_x(p_lnL,2) > 0.d0) then -! lnL_ptsrc_multi = lnL_ptsrc_multi - 0.5d0 * (amp-c_lnL%src(k_lnL)%P_x(p_lnL,1))**2 / & -! & c_lnL%src(k_lnL)%P_x(p_lnL,2)**2 + if (allocated(c_lnL%src(k_lnL)%P_x)) then + if (c_lnL%src(k_lnL)%P_x(p_lnL,2) > 0.d0) then + ! lnL_ptsrc_multi = lnL_ptsrc_multi - 0.5d0 * (amp-c_lnL%src(k_lnL)%P_x(p_lnL,1))**2 / & + ! & c_lnL%src(k_lnL)%P_x(p_lnL,2)**2 + end if end if ! Apply index priors diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index 810509821..7c0f379b8 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -246,26 +246,26 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) end do end if - ! Sample point source amplitudes - c => compList - do while (associated(c)) - select type (c) - class is (comm_ptsrc_comp) - if(c%precomputed_amps .and. c%active_samp_group(samp_group)) then - ! Initialize residual maps - do l = 1, numband - res => compute_residual(l) - data(l)%res%map = res%map - call res%dealloc(); deallocate(res) - nullify(res) - end do - ! Perform sampling - call c%samplePtsrcAmp(cpar, handle, samp_group) - return - end if - end select - c => c%nextComp() - end do + ! Sample point source amplitudes with precomputed amplitudes +!!$ c => compList +!!$ do while (associated(c)) +!!$ select type (c) +!!$ class is (comm_ptsrc_comp) +!!$ if(c%precomputed_amps .and. c%active_samp_group(samp_group)) then +!!$ ! Initialize residual maps +!!$ do l = 1, numband +!!$ res => compute_residual(l) +!!$ data(l)%res%map = res%map +!!$ call res%dealloc(); deallocate(res) +!!$ nullify(res) +!!$ end do +!!$ ! Perform sampling +!!$ call c%samplePtsrcAmp(cpar, handle, samp_group) +!!$ return +!!$ end if +!!$ end select +!!$ c => c%nextComp() +!!$ end do ! If mono-/dipole are sampled, check if they are priors for a component zero-level c => compList diff --git a/commander3/src/comm_sparse_mod.f90 b/commander3/src/comm_sparse_mod.f90 new file mode 100644 index 000000000..9408a5e35 --- /dev/null +++ b/commander3/src/comm_sparse_mod.f90 @@ -0,0 +1,332 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ +module comm_sparse_mod + use healpix_types + use math_tools + implicit none + + private + public sparse_system, sparse_ptr, sparse_system_tester + + type sparse_system + integer(i8b) :: pt(64) + integer(i4b) :: n, ni, nj, n_a_max, icurr, iparm(64) + integer(i4b) :: maxfct, mnum, mtype, nrhs, msglvl, idum + real(dp) :: ddum + integer(i4b), allocatable, dimension(:) :: ia, ja + real(dp), allocatable, dimension(:) :: a, b, x, y + contains + procedure :: decomp => sparse_system_decomp + procedure :: solve => sparse_system_solve + procedure :: dealloc => sparse_system_dealloc + procedure :: set_A => sparse_system_add_matrix_element + procedure :: set_rhs => sparse_system_set_rhs + procedure :: add_diag => sparse_system_add_diag + procedure :: scale_row => sparse_system_scale_row + procedure :: scale_col => sparse_system_scale_col + procedure :: print => sparse_system_print + end type sparse_system + + interface sparse_system + procedure constructor_sparse_system + end interface sparse_system + + type sparse_ptr + class(sparse_system), pointer :: p => null() + end type sparse_ptr + +contains + + function constructor_sparse_system(n, n_A_max) result(c) + implicit none + integer(i4b), intent(in) :: n, n_A_max + class(sparse_system), pointer :: c + + ! Assign memory + allocate(c) + + ! General parameters + c%n = n + c%n_a_max = n_a_max + c%nrhs = 1 + c%mtype = 2 ! symmetric matrix, positive definite + c%msglvl = 1 ! output statistical information + c%maxfct = 1 + c%mnum = 1 + + ! Initialize arrays + c%ni = 0 + c%nj = 0 + c%icurr = 0 + allocate(c%ia(c%n_a_max), c%ja(c%n_a_max), c%a(c%n_a_max), c%b(n), c%x(n), c%y(n)) + c%ia = 0 + c%ja = 0 + c%a = 0.d0 + c%b = 0.d0 + + end function constructor_sparse_system + + subroutine sparse_system_add_matrix_element(self, i, j, A_ij) + implicit none + class(sparse_system), intent(inout) :: self + integer(i4b), intent(in) :: i, j + real(dp), intent(in) :: A_ij + + integer(i4b), allocatable, dimension(:) :: ibuff + real(dp), allocatable, dimension(:) :: fbuff + + ! Check if array is already full; if so, double its size + if (self%nj == self%n_a_max) then + self%n_a_max = 2*self%n_a_max + allocate(ibuff(self%nj), fbuff(self%nj)) + ! Extend row array + ibuff(1:self%ni) = self%ia(1:self%ni) + deallocate(self%ia); allocate(self%ia(self%n_a_max)) + self%ia(1:self%ni) = ibuff(1:self%ni) + ! Extend column array + ibuff(1:self%nj) = self%ja(1:self%nj) + deallocate(self%ja); allocate(self%ja(self%n_a_max)) + self%ja(1:self%nj) = ibuff(1:self%nj) + ! Extend coefficient array + fbuff(1:self%nj) = self%a(1:self%nj) + deallocate(self%a); allocate(self%a(self%n_a_max)) + self%a(1:self%nj) = fbuff(1:self%nj) + self%a(self%nj+1:) = 0.d0 + deallocate(ibuff, fbuff) + end if + + ! Insert new element + self%nj = self%nj+1 + self%ja(self%nj) = j + self%a(self%nj) = A_ij + if (i /= self%icurr) then + self%icurr = i + self%ni = self%ni+1 + self%ia(self%ni) = self%nj + self%ia(self%ni+1) = self%nj+1 ! Sentinel value indicating end of array + end if + + end subroutine sparse_system_add_matrix_element + + subroutine sparse_system_set_rhs(self, b) + implicit none + class(sparse_system), intent(inout) :: self + real(dp), dimension(:), intent(in) :: b + if (size(b) /= self%n) then + write(*,*) 'sparse_matrix_set_rhs: Incorrect size of input array = ', size(b), self%n + stop + else + self%b = b + end if + end subroutine sparse_system_set_rhs + + subroutine sparse_system_decomp(self) + implicit none + class(sparse_system), intent(inout) :: self + + integer(i4b) :: solver, error, phase + + ! Initialize PARDISO solver + solver = 10 ! use sparse direct method + call pardisoinit(self%pt, self%mtype, self%iparm) + self%iparm(3) = 1 ! OMP_NUM_THREADS + + ! Symbolic factorization + phase = 11 ! only reordering and symbolic factorization + self%iparm(33) = 1 ! compute determinant + call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & + & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & + & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) + if (error /= 0) THEN + write(*,*) 'pardiso symbolic factorization error: ', error + stop + else + !write(*,*) 'pardiso -- number of nonzeros = ', self%iparm(18) + !write(*,*) 'pardiso -- MFLOPS = ', self%iparm(19) + end if + + ! Perform factorization + phase = 22 + call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & + & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & + & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) + if (error /= 0) THEN + write(*,*) 'pardiso factorization error: ', error + stop + end if + + end subroutine sparse_system_decomp + + subroutine sparse_system_solve(self, x) + implicit none + class(sparse_system), intent(inout) :: self + real(dp), dimension(:), intent(out) :: x + + integer(i4b) :: phase, error + real(dp) :: normb, normr + + ! Solve system + self%iparm(8) = 1 ! direct solution + phase = 33 ! only solve + CALL pardiso (self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & + & self%idum, self%nrhs, self%iparm, 0, self%b, self%x, error) + if (error /= 0) THEN + write(*,*) 'pardiso solver error: ', error + stop + else + x = self%x + end if + + end subroutine sparse_system_solve + + subroutine sparse_system_dealloc(self) + implicit none + class(sparse_system), intent(inout) :: self + + integer(i4b) :: phase, error + + ! Clean up pardiso + phase = -1 ! deallocate pardiso memory + call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, self%ddum, self%idum, self%idum, & + & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) + + ! Deallocate object arrays + deallocate(self%ia, self%ja, self%a, self%b, self%x, self%y) + + ! Nullify array sizes + self%n = 0 + self%ni = 0 + self%nj = 0 + + end subroutine sparse_system_dealloc + + subroutine sparse_system_add_diag(self, val, row) + implicit none + class(sparse_system), intent(inout) :: self + real(dp), intent(in) :: val + integer(i4b), intent(in), optional :: row + integer(i4b) :: i + if (present(row)) then + self%a(self%ia(row)) = self%a(self%ia(row)) + val + else + do i = 1, self%n + self%a(self%ia(i)) = self%a(self%ia(i)) + val + end do + end if + end subroutine sparse_system_add_diag + + subroutine sparse_system_scale_row(self, row, val) + implicit none + class(sparse_system), intent(inout) :: self + integer(i4b), intent(in) :: row + real(dp), intent(in) :: val + integer(i4b) :: c1, c2 + c1 = self%ia(row) + c2 = self%ia(row+1)-1 + self%a(c1:c2) = self%a(c1:c2) * val + end subroutine sparse_system_scale_row + + subroutine sparse_system_scale_col(self, col, val) + implicit none + class(sparse_system), intent(inout) :: self + integer(i4b), intent(in) :: col + real(dp), intent(in) :: val + where (self%ja == col) + self%a = self%a * val + end where + end subroutine sparse_system_scale_col + + subroutine sparse_system_print(self) + implicit none + class(sparse_system), intent(in) :: self + + write(*,*) 'n = ', self%n, ', ni = ', self%ni, ', nj = ', self%nj + write(*,*) 'ia = ', self%ia(1:self%ni+1) + write(*,*) 'ja = ', self%ja(1:self%nj) + write(*,*) 'A = ', self%a(1:self%nj) + write(*,*) 'b = ', self%b(1:self%n) + + end subroutine sparse_system_print + + subroutine sparse_system_tester + implicit none + + integer(i4b) :: i, j, n + real(dp), allocatable, dimension(:) :: b, x + real(dp), allocatable, dimension(:,:) :: A + class(sparse_system), pointer :: ss + + ! Allocate system + n = 8 + ss => sparse_system(n, 4) + + ! Set up coefficient matrix + allocate(A(n,n)); A = 0.d0 + call ss%set_A(1,1, 7.d0); A(1,1) = 7.d0 + call ss%set_A(1,3, 1.d0); A(1,3) = 1.d0; A(3,1) = 1.d0 + call ss%set_A(1,6, 2.d0); A(1,6) = 2.d0; A(6,1) = 2.d0 + call ss%set_A(1,7, 7.d0); A(1,7) = 7.d0; A(7,1) = 7.d0 + call ss%set_A(2,2, -4.d0); A(2,2) = -4.d0 + call ss%set_A(2,3, 8.d0); A(2,3) = 8.d0; A(3,2) = 8.d0 + call ss%set_A(2,5, 2.d0); A(2,5) = 2.d0; A(5,2) = 2.d0 + call ss%set_A(3,3, 1.d0); A(3,3) = 1.d0 + call ss%set_A(3,8, 5.d0); A(3,8) = 5.d0; A(8,3) = 5.d0 + call ss%set_A(4,4, 7.d0); A(4,4) = 7.d0 + call ss%set_A(4,7, 9.d0); A(4,7) = 9.d0; A(7,4) = 9.d0 + call ss%set_A(5,5, 5.d0); A(5,5) = 5.d0 + call ss%set_A(5,6, 1.d0); A(5,6) = 1.d0; A(6,5) = 1.d0 + call ss%set_A(5,7, 5.d0); A(5,7) = 5.d0; A(7,5) = 5.d0 + call ss%set_A(6,6, 0.d0); A(6,6) = 0.d0 + call ss%set_A(6,8, 5.d0); A(6,8) = 5.d0; A(8,6) = 5.d0 + call ss%set_A(7,7, 11.d0); A(7,7) = 11.d0 + call ss%set_A(8,8, 5.d0); A(8,8) = 5.d0 + +!!$ write(*,*) 'n = ', n, ', ni = ', ss%ni, ', nj = ', ss%nj +!!$ write(*,*) 'ia = ', ss%ia(1:ss%ni+1) +!!$ write(*,*) 'ja = ', ss%ja(1:ss%nj) +!!$ write(*,*) 'A = ', ss%a(1:ss%nj) +!!$ write(*,*) 'b = ', ss%b(1:ss%n) +!!$ stop + + ! Decompose matrix + call ss%decomp() + + ! Set up RHS + allocate(b(n), x(n)) + b = 1.d0 + call ss%set_rhs(b) + + ! Solve system + call ss%solve(x) + + ! Output solution + write(*,*) 'x(sparse) = ', x + + ! Solve brute-force + call solve_system_real(A, x, b) + write(*,*) 'x(dense) = ', x + + ! Clean up + call ss%dealloc() + + end subroutine sparse_system_tester + +end module comm_sparse_mod diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index de9b7dadb..233f02c8f 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -22,6 +22,7 @@ program commander use comm_nonlin_mod use comm_mh_specind_mod use comm_zodi_samp_mod + use comm_sparse_mod implicit none integer(i4b) :: i, j, l, iargc, ierr, iter, stat, first_sample, samp_group, curr_samp, tod_freq, modfact @@ -415,7 +416,7 @@ program commander call timer%stop(TOT_ZODI_SAMP) end if - if (mod(iter+1,modfact) == 0) then + if (mod(iter+1,modfact) == 0 .and. iter > 1) then ! Sample linear parameters with CG search; loop over CG sample groups !call output_FITS_sample(cpar, 1000+iter, .true.) From 2f8e5814c751c3ec6c8f507f8bb7054f54a31cad Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 1 Feb 2025 11:37:47 +0100 Subject: [PATCH 088/171] Optmized ptsrc preconditioner --- commander3/src/comm_ptsrc_comp_mod.f90 | 450 ++++++++++++------------- 1 file changed, 208 insertions(+), 242 deletions(-) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 75bff5c5c..37023dbdf 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -52,7 +52,7 @@ module comm_ptsrc_comp_mod character(len=512) :: outprefix real(dp) :: cg_scale, amp_rms_scale integer(i4b) :: nside, nside_febecop, nsrc, ncr_tot, ndet, nactive - logical(lgt) :: apply_pos_prior, burn_in, precomputed_amps + logical(lgt) :: apply_pos_prior, burn_in, precomputed_amps, recompute_ptsrc_precond real(dp), allocatable, dimension(:,:) :: x ! Amplitudes (nsrc,nmaps) real(dp), allocatable, dimension(:,:) :: x_buff ! Amplitudes (nsrc,nmaps) type(F_int_ptr), allocatable, dimension(:,:,:) :: F_int ! SED integrator (numband) @@ -88,7 +88,6 @@ module comm_ptsrc_comp_mod integer(i4b) :: comm_pre = -1 integer(i4b) :: myid_pre = -1 integer(i4b) :: numprocs_pre = -1 - logical(lgt) :: recompute_ptsrc_precond = .false. logical(lgt) :: apply_ptsrc_precond = .true. character(len=24), private :: operation @@ -143,8 +142,7 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) c%burn_in = cpar%cs_burn_in(id_abs) c%amp_rms_scale = cpar%cs_amp_rms_scale(id_abs) c%precomputed_amps= .false. - - if (.not. c%apply_pos_prior) recompute_ptsrc_precond = .true. + c%recompute_ptsrc_precond = .not. c%apply_pos_prior call get_tokens(cpar%output_comps, ",", comp_label, n) c%output = .false. @@ -667,7 +665,7 @@ subroutine initPtsrcHDF(self, cpar, hdffile, hdfpath) path = trim(adjustl(hdfpath))//trim(adjustl(self%label)) // '/' if (self%myid == 0) then - call read_hdf(hdffile, trim(adjustl(path))//'amp', self%x) + call read_hdf(hdffile, trim(adjustl(path))//'amp', self%x(1:self%nsrc,:)) self%x = self%x/self%cg_scale end if @@ -1530,313 +1528,281 @@ subroutine initPtsrcPrecond(comm, samp_group) implicit none integer(i4b), intent(in) :: comm, samp_group - integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt - real(dp) :: t1, t2, t3, t4, dist, tot + integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt, nactive, c1, c2 + real(dp) :: t1, t2, t3, t4, dist, tot, tot2 logical(lgt) :: skip real(dp), allocatable, dimension(:) :: buff - class(comm_comp), pointer :: c => null(), c1 => null(), c2 => null() + class(comm_comp), pointer :: c => null() class(comm_ptsrc_comp), pointer :: pt1 => null(), pt2 => null() real(dp), allocatable, dimension(:,:) :: mat, mat2 - + type(ptsrc_ptr), dimension(5) :: pc + if (npre == 0) return if (ncomp_pre == 0) return - if (.not. recompute_ptsrc_precond) return if (.not. apply_ptsrc_precond) return - if (allocated(P_cr(samp_group)%invM_src)) then - do j = 1, nmaps_pre - call P_cr(samp_group)%invM_src(1,j)%M%dealloc() - end do - deallocate(P_cr(samp_group)%invM_src) - end if + + ! Make a list of active components, and check that at least one wants update + nactive = 0 + skip = .true. + c => compList + do while (associated(c)) + select type (c) + class is (comm_ptsrc_comp) + if (c%active_samp_group(samp_group)) then + nactive = nactive+1 + pc(nactive)%p => c + if (c%recompute_ptsrc_precond) skip = .false. + end if + end select + c => c%nextComp() + end do + if (nactive == 0 .or. skip) return call mpi_comm_rank(comm, myid, ierr) ! Build frequency-dependent part of preconditioner call wall_time(t1) - allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) + if (.not. allocated(P_cr(samp_group)%invM_src)) then + allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) + end if !allocate(mat(npre,npre), mat2(npre,npre)) do j = 1, nmaps_pre ! Find number of matrix elements - if (myid_pre == 0) then + if (.not. associated(P_cr(samp_group)%invM_src(1,j)%M)) then n = 0 i1 = 0 - c1 => compList - do while (associated(c1)) - skip = .true. - select type (c1) - class is (comm_ptsrc_comp) - pt1 => c1 - skip = j > pt1%nmaps - end select - if (skip) then - c1 => c1%nextComp() - cycle - end if + do c1 = 1, nactive + pt1 => pc(c1)%p + if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc, n - i1 = i1+1 - - i2 = 0 - c2 => compList - do while (associated(c2)) - !do j2 = 1, ncomp_pre - skip = .true. - select type (c2) - class is (comm_ptsrc_comp) - pt2 => c2 - skip = j > pt2%nmaps - end select - if (skip) then - c2 => c2%nextComp() - cycle - end if - do k2 = 1, pt2%nsrc - !write(*,*) k2, pt2%nsrc - i2 = i2+1 + i1 = i1+1 + i2 = pt1%myid + do c2 = 1, nactive + pt2 => pc(c2)%p + if (j > pt2%nmaps) cycle + do k2 = 1+pt1%myid, pt2%nsrc, pt1%numprocs + i2 = i2+pt1%numprocs if (i2 < i1) cycle - !if (mod(k2,nprocs) == myid) then - !call angdist(pt1%src(k1)%vec, pt2%src(k2)%vec, dist) dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) -!!$ write(*,*) k1, k2, dist, dist*180.d0/pi -!!$ write(*,*) pt1%src(k1)%vec -!!$ write(*,*) pt2%src(k2)%vec - if (dist <= 3.d0*pi/180.d0) n = n+1 - !end if end do - c2 => c2%nextComp() end do end do - c1 => c1%nextComp() end do - !call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) + call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) + if (myid_pre == 0) write(*,*) 'Number of matrix elements = ', n + ! Allocate sparse matrix + P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre, n) end if - if (myid_pre == 0) then - write(*,*) 'Number of matrix elements = ', n - end if - - ! Allocate sparse matrix - call mpi_bcast(n, 1, MPI_INTEGER, 0, comm, ierr) - P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre, n) - - ! Construct matrix - !mat = 0.d0 - i1 = 0 - c1 => compList - do while (associated(c1)) - skip = .true. - select type (c1) - class is (comm_ptsrc_comp) - pt1 => c1 - skip = j > pt1%nmaps - end select - if (skip) then - c1 => c1%nextComp() - cycle - end if - do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc - !write(*,*) k1, pt1%nsrc - i1 = i1+1 - - i2 = 0 - c2 => compList - do while (associated(c2)) - !do j2 = 1, ncomp_pre - skip = .true. - select type (c2) - class is (comm_ptsrc_comp) - pt2 => c2 - skip = j > pt2%nmaps - end select - if (skip) then - c2 => c2%nextComp() - cycle - end if - do k2 = 1, pt2%nsrc - !write(*,*) k2, pt2%nsrc - i2 = i2+1 - if (i2 < i1) cycle - !call angdist(pt1%src(k1)%vec, pt2%src(k2)%vec, dist) - dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) - if (dist > 3.d0*pi/180.d0) cycle ! Cutoff should be user defined - - tot = 0.d0 - do l = 1, numband - if (pt1%F_null(l)) cycle - la = pt1%b2a(l) - n1 = pt1%src(k1)%T(la)%np - n2 = pt2%src(k2)%T(la)%np - - ! Search for common pixels; skip if no pixel overlap - if (n1 == 0 .or. n2 == 0) cycle - if (pt1%src(k1)%T(la)%pix(1,1) > pt2%src(k2)%T(la)%pix(n2,1)) cycle - if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(1,1)) cycle - if (j == 1 .and. data(l)%pol_only) cycle - !if (data(l)%bp(0)%p%nu_c < self%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > self%nu_max_ind(1)) cycle - - - p1 = 1 - p2 = 1 - do while (.true.) - if (pt1%src(k1)%T(la)%pix(p1,1) == pt2%src(k2)%T(la)%pix(p2,1)) then - p = pt1%src(k1)%T(la)%pix(p1,1) - if (.false. .and. myid == 0) then - write(*,*) 'a', data(l)%N%invN_diag%map(p,j) - write(*,*) 'b', pt1%src(k1)%T(l)%map(p1,j), pt2%src(k2)%T(l)%map(p2,j) - write(*,*) 'c', pt1%src(k1)%T(l)%F(j,0), pt2%src(k2)%T(l)%F(j,0) - write(*,*) 'd', pt1%getScale(l,k1,j), pt2%getScale(l,k2,j) + if (P_cr(samp_group)%invM_src(1,j)%M%ni == 0) then + ! Construct matrix with sparsity pattern + i1 = 0 + do c1 = 1, nactive + pt1 => pc(c1)%p + if (j > pt1%nmaps) cycle + do k1 = 1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc + i1 = i1+1 + + i2 = 0 + do c2 = 1, nactive + pt2 => pc(c2)%p + if (j > pt2%nmaps) cycle + do k2 = 1, pt2%nsrc + i2 = i2+1 + if (i2 < i1) cycle + dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) + if (dist > 3.d0*pi/180.d0) cycle ! Cutoff should be user defined + + tot = 0.d0 + do l = 1, numband + if (pt1%F_null(l)) cycle + if (.not. data(l)%cr_active) cycle + if (j == 1 .and. data(l)%pol_only) cycle + la = pt1%b2a(l) + n1 = pt1%src(k1)%T(la)%np + n2 = pt2%src(k2)%T(la)%np + + ! Search for common pixels; skip if no pixel overlap + if (n1 == 0 .or. n2 == 0) cycle + if (pt1%src(k1)%T(la)%pix(1,1) > pt2%src(k2)%T(la)%pix(n2,1)) cycle + if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(1,1)) cycle + + p1 = 1 + p2 = 1 + do while (.true.) + if (pt1%src(k1)%T(la)%pix(p1,1) == pt2%src(k2)%T(la)%pix(p2,1)) then + p = pt1%src(k1)%T(la)%pix(p1,1) + tot = tot + & + & 1.d0/data(l)%N%rms_pix(p,j)**2 * & ! invN_{p,p} + & pt1%src(k1)%T(la)%map(p1,j) * & ! B_1 + & pt2%src(k2)%T(la)%map(p2,j) * & ! B_2 + & pt1%src(k1)%T(la)%F(j,0) * & ! F_1 + & pt2%src(k2)%T(la)%F(j,0) * & ! F_2 + & pt1%getScale(l,k1,j) * & ! Unit 1 + & pt2%getScale(l,k2,j) ! Unit 2 + p1 = p1+1 + p2 = p2+1 + else if (pt1%src(k1)%T(la)%pix(p1,1) < pt2%src(k2)%T(la)%pix(p2,1)) then + p1 = p1+1 + else + p2 = p2+1 end if - tot = tot + & - & 1.d0/data(l)%N%rms_pix(p,j)**2 * & ! invN_{p,p} - & pt1%src(k1)%T(la)%map(p1,j) * & ! B_1 - & pt2%src(k2)%T(la)%map(p2,j) * & ! B_2 - & pt1%src(k1)%T(la)%F(j,0) * & ! F_1 - & pt2%src(k2)%T(la)%F(j,0) * & ! F_2 - & pt1%getScale(l,k1,j) * & ! Unit 1 - & pt2%getScale(l,k2,j) ! Unit 2 - p1 = p1+1 - p2 = p2+1 - else if (pt1%src(k1)%T(la)%pix(p1,1) < pt2%src(k2)%T(la)%pix(p2,1)) then - p1 = p1+1 - else - p2 = p2+1 - end if - if (p1 > n1 .or. p2 > n2) exit - if (pt1%src(k1)%T(la)%pix(p1,1) > pt2%src(k2)%T(la)%pix(n2,1)) exit - if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(p2,1)) exit + if (p1 > n1 .or. p2 > n2) exit + if (pt1%src(k1)%T(la)%pix(p1,1) > pt2%src(k2)%T(la)%pix(n2,1)) exit + if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(p2,1)) exit + end do end do + ! Update sparse matrix + call P_cr(samp_group)%invM_src(1,j)%M%set_A(i1,i2, tot) end do - ! Update sparse matrix - !mat(i1,i2) = tot - !mat(i2,i1) = mat(i1,i2) - call P_cr(samp_group)%invM_src(1,j)%M%set_A(i1,i2, tot) end do - c2 => c2%nextComp() end do end do - c1 => c1%nextComp() - end do - ! Collect contributions from all cores - allocate(buff(size(P_cr(samp_group)%invM_src(1,j)%M%a))) - call mpi_reduce(P_cr(samp_group)%invM_src(1,j)%M%a, buff, size(P_cr(samp_group)%invM_src(1,j)%M%a), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) - P_cr(samp_group)%invM_src(1,j)%M%a = buff - deallocate(buff) - !call mpi_reduce(mat, mat2, size(mat2), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + ! Collect contributions from all cores + allocate(buff(size(P_cr(samp_group)%invM_src(1,j)%M%a))) + call mpi_reduce(P_cr(samp_group)%invM_src(1,j)%M%a, buff, size(P_cr(samp_group)%invM_src(1,j)%M%a), MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + P_cr(samp_group)%invM_src(1,j)%M%a = buff + deallocate(buff) - if (myid == 0) then - write(*,*) "Done reducing" - !call P_cr(samp_group)%invM_src(1,j)%M%print() - + else + + ! Construct matrix with sparsity pattern + do i1 = 1, P_cr(samp_group)%invM_src(1,j)%M%ni + if (myid_pre == 0 .and. mod(i1,1000) == 0) write(*,*) i1, P_cr(samp_group)%invM_src(1,j)%M%ni + c1 = 1 + k1 = i1 + do while (k1 > pc(c1)%p%nsrc) + k1 = k1 - pc(c1)%p%nsrc + c1 = c1 + 1 + end do + pt1 => pc(c1)%p + if (j > pt1%nmaps) cycle + do j2 = P_cr(samp_group)%invM_src(1,j)%M%ia(i1), & + & P_cr(samp_group)%invM_src(1,j)%M%ia(i1+1)-1 + i2 = P_cr(samp_group)%invM_src(1,j)%M%ja(j2) + if (i2 < i1) cycle + c2 = 1 + k2 = i2 + do while (k2 > pc(c2)%p%nsrc) + k2 = k2 - pc(c2)%p%nsrc + c2 = c2 + 1 + end do + pt2 => pc(c2)%p + if (j > pt2%nmaps) cycle + + if (.not. pt1%recompute_ptsrc_precond .and. & + & .not. pt2%recompute_ptsrc_precond) cycle + + dist = acos(min(max(sum(pt1%src(k1)%vec*pt2%src(k2)%vec),-1.d0),1.d0)) + if (dist > 3.d0*pi/180.d0) cycle ! Cutoff should be user defined + + tot = 0.d0 + do l = 1, numband + if (pt1%F_null(l)) cycle + if (.not. data(l)%cr_active) cycle + if (j == 1 .and. data(l)%pol_only) cycle + la = pt1%b2a(l) + n1 = pt1%src(k1)%T(la)%np + n2 = pt2%src(k2)%T(la)%np + + ! Search for common pixels; skip if no pixel overlap + if (n1 == 0 .or. n2 == 0) cycle + if (pt1%src(k1)%T(la)%pix(1,1) > pt2%src(k2)%T(la)%pix(n2,1)) cycle + if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(1,1)) cycle + + p1 = 1 + p2 = 1 + do while (.true.) + if (pt1%src(k1)%T(la)%pix(p1,1) == pt2%src(k2)%T(la)%pix(p2,1)) then + p = pt1%src(k1)%T(la)%pix(p1,1) + tot = tot + & + & 1.d0/data(l)%N%rms_pix(p,j)**2 * & ! invN_{p,p} + & pt1%src(k1)%T(la)%map(p1,j) * & ! B_1 + & pt2%src(k2)%T(la)%map(p2,j) * & ! B_2 + & pt1%src(k1)%T(la)%F(j,0) * & ! F_1 + & pt2%src(k2)%T(la)%F(j,0) * & ! F_2 + & pt1%getScale(l,k1,j) * & ! Unit 1 + & pt2%getScale(l,k2,j) ! Unit 2 + p1 = p1+1 + p2 = p2+1 + else if (pt1%src(k1)%T(la)%pix(p1,1) < pt2%src(k2)%T(la)%pix(p2,1)) then + p1 = p1+1 + else + p2 = p2+1 + end if + if (p1 > n1 .or. p2 > n2) exit + if (pt1%src(k1)%T(la)%pix(p1,1) > pt2%src(k2)%T(la)%pix(n2,1)) exit + if (pt1%src(k1)%T(la)%pix(n1,1) < pt2%src(k2)%T(la)%pix(p2,1)) exit + end do + end do + ! Update sparse matrix + call mpi_reduce(tot, tot2, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + if (myid_pre == 0) P_cr(samp_group)%invM_src(1,j)%M%a(j2) = tot2 + end do + end do + end if + + if (myid == 0) then ! Multiply with sqrtS from left side - i1 = 0 - c1 => compList - do while (associated(c1)) - skip = .true. - select type (c1) - class is (comm_ptsrc_comp) - pt1 => c1 - skip = j > pt1%nmaps - end select - if (skip) then - c1 => c1%nextComp() + i1 = 0 + do c1 = 1, nactive + pt1 => pc(c1)%p + if (.not. pt1%recompute_ptsrc_precond) then + i1 = i1 + pt1%nsrc cycle end if + if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc i1 = i1+1 - !mat2(i1,:) = mat2(i1,:) * pt1%src(k1)%P_x(j,2) - !write(*,*) k1, i1, P_cr(samp_group)%invM_src(1,j)%M%ni, pt1%src(k1)%P_x(j,2) if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%scale_row(i1, pt1%src(k1)%P_x(j,2)) end do - c1 => c1%nextComp() - write(*,*) "Done rows" end do ! Multiply with sqrtS from right side i1 = 0 - c1 => compList - do while (associated(c1)) - skip = .true. - select type (c1) - class is (comm_ptsrc_comp) - pt1 => c1 - skip = j > pt1%nmaps - end select - if (skip) then - c1 => c1%nextComp() + do c1 = 1, nactive + pt1 => pc(c1)%p + if (.not. pt1%recompute_ptsrc_precond) then + i1 = i1 + pt1%nsrc cycle end if + if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc i1 = i1+1 - !mat2(:,i1) = mat2(:,i1) * pt1%src(k1)%P_x(j,2) if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%scale_col(i1, pt1%src(k1)%P_x(j,2)) end do - c1 => c1%nextComp() - write(*,*) "Done cols" end do ! Add unity - !do i1 = 1, npre - ! mat2(i1,i1) = mat2(i1,i1) + 1.d0 - !end do i1 = 0 - c1 => compList - do while (associated(c1)) - skip = .true. - select type (c1) - class is (comm_ptsrc_comp) - pt1 => c1 - skip = j > pt1%nmaps - end select - if (skip) then - c1 => c1%nextComp() + do c1 = 1, nactive + pt1 => pc(c1)%p + if (.not. pt1%recompute_ptsrc_precond) then + i1 = i1 + pt1%nsrc cycle end if + if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc i1 = i1+1 - !mat2(:,i1) = mat2(:,i1) * pt1%src(k1)%P_x(j,2) - !if (allocated(pt1%src(k1)%P_x)) call P_cr(samp_group)%invM_src(1,j)%M%add_diag(1.d0, i1) call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.01d0, i1) end do - c1 => c1%nextComp() - write(*,*) "Done diag" end do - !call P_cr(samp_group)%invM_src(1,j)%M%add_diag(1.d0) ! Invert matrix to finalize preconditioner call wall_time(t3) - !allocate(buff(npre)) - !call get_eigenvalues(mat2, buff) - !write(*,*) "W = ", buff - !deallocate(buff) - if (myid_pre == 0) write(*,*) 'ptsrc precond before' - !call invert_matrix_with_mask(mat2) - if (.false. .and. myid_pre == 0) then - do i1 = 1, npre - write(*,*) mat2(i1,:) - end do - write(*,*) "---------" - write(*,*) P_cr(samp_group)%invM_src(1,j)%M%ia - write(*,*) P_cr(samp_group)%invM_src(1,j)%M%ja - write(*,*) P_cr(samp_group)%invM_src(1,j)%M%a - end if call P_cr(samp_group)%invM_src(1,j)%M%decomp() call wall_time(t4) - if (myid_pre == 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) - !allocate(P_cr(samp_group)%invM_src(1,j)%M(npre,npre)) - !P_cr(samp_group)%invM_src(1,j)%M = mat2 + if (myid_pre == 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) end if end do call wall_time(t2) if (myid_pre == 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) -! call mpi_finalize(ierr) -! stop - - !deallocate(mat,mat2) - - recompute_ptsrc_precond = .false. - !apply_ptsrc_precond = .false. + do i = 1, nactive + pc(i)%p%recompute_ptsrc_precond = .false. + end do end subroutine initPtsrcPrecond @@ -2285,7 +2251,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) call self%updateMixmat ! Ask for CG preconditioner update - if (any(self%active_samp_group)) recompute_ptsrc_precond = .true. + if (any(self%active_samp_group)) self%recompute_ptsrc_precond = .true. return end if @@ -2642,7 +2608,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) call self%updateMixmat ! Ask for CG preconditioner update - if (any(self%active_samp_group)) recompute_ptsrc_precond = .true. + if (any(self%active_samp_group)) self%recompute_ptsrc_precond = .true. deallocate(x, P_tot, F, lnL, amp, theta, a_curr) From 3ede41c5b3c50daee5910d3df6740c329c340aaf Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 2 Feb 2025 14:34:42 +0100 Subject: [PATCH 089/171] Fixed uninitiazed call --- commander3/src/sharp.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/sharp.f90 b/commander3/src/sharp.f90 index 7f56e9be6..58181aff7 100644 --- a/commander3/src/sharp.f90 +++ b/commander3/src/sharp.f90 @@ -211,8 +211,8 @@ subroutine sharp_execute_d(type, spin, nmaps, alm, alm_info, map, geom_info, & type(c_ptr), target :: map_ptr(nmaps) mod_flags = SHARP_DP - if (present(add) .and. add) then - mod_flags = or(mod_flags, SHARP_ADD) + if (present(add)) then + if (add) mod_flags = or(mod_flags, SHARP_ADD) end if if (spin == 0) then From da903a50ada8be1b25c77accabf064e9a20d8733 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 3 Feb 2025 00:12:02 +0100 Subject: [PATCH 090/171] Updated debug flags to work with ifx --- cmake/compilers/intel.cmake | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/cmake/compilers/intel.cmake b/cmake/compilers/intel.cmake index ae5b365c1..cf4d958f0 100644 --- a/cmake/compilers/intel.cmake +++ b/cmake/compilers/intel.cmake @@ -70,37 +70,28 @@ if (COMMANDER3_Fortran_COMPILER_FLAGS_RELEASE MATCHES "") "-xHost" "-fpe0" "-fPIC" - #"-fp-model=strict" "-traceback" "-qopenmp" #<= we are not using it at all, it is redundant "-assume" "byterecl" # for I/O operations - #"-qopt-matmul" #<= increases linking time but doesn't increase performance - #"-DNDEBUG" - #"-ipo" # - #"-parallel" "-heap-arrays" "16384" ) endif() if(COMMANDER3_Fortran_COMPILER_FLAGS_DEBUG MATCHES "") list(APPEND COMMANDER3_Fortran_COMPILER_FLAGS_DEBUG "-O0" - "-g" + "-g" "-xHost" - "-debug" "all" - "-check" "all,noarg_temp_created" - "-warn" "all,nounused,noexternal" - "-fp-stack-check" - "-fstack-protector-all" + "-debug" "all" + "-check" "all,nouninit" + "-warn" "all,nounused,noexternal" + "-fp-stack-check" + "-fstack-protector-all" "-traceback" - "-parallel" "-qopenmp" - "-C" "-assume" "byterecl" "-heap-arrays" "16384" "-fpe0" "-fPIC" - #"-ftrapuv" - #"-init=snan,arrays" ) endif() if(COMMANDER3_Fortran_COMPILER_FLAGS_RELWITHDEBINFO MATCHES "") @@ -110,24 +101,10 @@ if(COMMANDER3_Fortran_COMPILER_FLAGS_RELWITHDEBINFO MATCHES "") "-g" "-fpe0" "-fPIC" - #"-fp-model=strict" "-qopenmp" "-assume" "byterecl" # for I/O operations - #"-qopt-matmul" #<= increases linking time but doesn't increase performance "-traceback" "-heap-arrays" "16384" - # - #"-O2" - #"-g" - #"-traceback" - #"-DNDEBUG" - #"-parallel" - #"-qopenmp" - #"-qopt-matmul" - #"-C" - #"-assume" "byterecl" - #"-fpe0" - #"-fPIC" ) endif() if(COMMANDER3_Fortran_COMPILER_FLAGS_MINSIZEREL MATCHES "") @@ -135,9 +112,7 @@ if(COMMANDER3_Fortran_COMPILER_FLAGS_MINSIZEREL MATCHES "") "-Os" "-traceback" "-DNDEBUG" - "-parallel" "-qopenmp" - "-C" "-assume" "byterecl" "-heap-arrays" "16384" "-fpe0" From 1cfd9e92c633a34b8bdbbe375100aa83c297e0ce Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 3 Feb 2025 00:18:13 +0100 Subject: [PATCH 091/171] Fixed potential uninitialized error --- commander3/src/comm_param_mod.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 00398b30b..55f2121d6 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -581,7 +581,8 @@ subroutine read_data_params_hash(htbl, cpar) character(len=3) :: itext character(len=2) :: jtext - len_itext=len(trim(itext)) !! FIXME + call int2string(1, itext) + len_itext=len(trim(itext)) call get_parameter_hashtable(htbl, 'NUMBAND', par_int=cpar%numband) !call get_parameter_hashtable(htbl, 'DATA_DIRECTORY', par_string=cpar%datadir) call get_parameter_hashtable(htbl, 'SOURCE_MASKFILE', par_string=cpar%ds_sourcemask, path=.true.) @@ -763,7 +764,8 @@ subroutine read_component_params_hash(htbl, cpar) pol_labels(2)='POL' pol_labels(3)='POL3' - len_itext=len(trim(itext)) !FIXME!! + call int2string(1, itext) + len_itext=len(trim(itext)) call get_parameter_hashtable(htbl, 'INSTRUMENT_PARAM_FILE', par_string=cpar%cs_inst_parfile, path=.true.) call get_parameter_hashtable(htbl, 'INIT_INSTRUMENT_FROM_HDF', par_string=cpar%cs_init_inst_hdf) call get_parameter_hashtable(htbl, 'NUM_SIGNAL_COMPONENTS', par_int=cpar%cs_ncomp_tot) From 7d813b24d03f3b30363603e8b338a20fe166332d Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 3 Feb 2025 00:19:03 +0100 Subject: [PATCH 092/171] Added updated compilers --- install_ita.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/install_ita.sh b/install_ita.sh index 61b98bfca..c9c93c72f 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -152,15 +152,16 @@ then elif [[ "$toolchain" =~ "oneapi" ]] then # Compilers - fc="ifort" - cc="icc" - cxx="icpc" + fc="ifx" + cc="icx" + cxx="icpx" # MPI compilers - mpifc="mpiifort" - mpicc="mpiicc" - mpicxx="mpiicpc" + mpifc="mpiifx" + mpicc="mpiicx" + mpicxx="mpiicpx" printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" - module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 + #module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 + module load intel/oneapi compiler/latest mpi/latest elif [[ "$toolchain" =~ "gnu" ]] then # Compilers From cb96076336bac4c2524765cfddfbeb85b05d0e80 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 3 Feb 2025 10:48:44 +0100 Subject: [PATCH 093/171] Enabled relative gain estimation in DIRBE --- commander3/src/comm_ptsrc_comp_mod.f90 | 17 +++++++++-------- commander3/src/comm_tod_dirbe_mod.f90 | 12 ++++++++---- commander3/src/comm_zodi_samp_mod.f90 | 16 +++++++++------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 37023dbdf..55c97b6bf 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -907,7 +907,7 @@ subroutine init_beam_templates(self, cpar, id, id_abs) !if (self%myid == 0) write(*,*) 'a3' ! Construct beam on-the-fly do j = 1, self%nsrc - if (mod(j,1000) == 0 .and. self%myid == 0) & + if (mod(j,10000) == 0 .and. self%myid == 0) & & write(*,fmt='(a,i8,a,i8)') ' | Initializing src no. ', j, ' of ', self%nsrc self%src(j)%T(ia)%nside = data(i)%info%nside self%src(j)%T(ia)%nmaps = min(data(i)%info%nmaps, self%nmaps) @@ -966,7 +966,8 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) call read_alloc_hdf(stars_file, '/reported_values', catalog) !nstars, nbands call read_alloc_hdf(stars_file, '/band_column_mapping', band_list) - ! trim unused bands from star catalog + + ! trim unused bands from star catalog allocate(star_catalog(self%nactive, size(catalog(1,:)))) do i=1, numband @@ -974,7 +975,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) found = .false. do j=1, size(band_list) if(trim(data(i)%instlabel) == trim(band_list(j))) then ! band is in catalog - star_catalog(self%b2a(i),:) = catalog(j,:) + star_catalog(self%b2a(i),:) = catalog(j,:)/ catalog(1,:) found = .true. !write(*,*) "Found band ", trim(data(i)%label), " at position ", j exit @@ -1003,7 +1004,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) ii = 0 do i=1, self%nsrc if (myid_pre == 0) then - if (mod(ii,10000) == 0) then + if (mod(ii,100000) == 0) then write(*,fmt='(a,i6,a,i6,a,a)') ' | Reading src ', ii, ' of ', self%nsrc end if end if @@ -1038,7 +1039,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) if (cpar%myid_chain == 0) self%ncr = self%ncr + self%nmaps ! Normalize to first frequency - self%src(ii)%amp_precomp = star_catalog(:,i)/star_catalog(1,i) + self%src(ii)%amp_precomp = star_catalog(:,i)!/star_catalog(1,i) do j=1, numband !self%nactive ja = self%b2a(j) @@ -1576,7 +1577,7 @@ subroutine initPtsrcPrecond(comm, samp_group) pt1 => pc(c1)%p if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc, n + if (myid_pre == 0 .and. mod(k1,10000) == 0) write(*,*) 'Precomp sparsity =', k1, pt1%nsrc, n i1 = i1+1 i2 = pt1%myid do c2 = 1, nactive @@ -1604,7 +1605,7 @@ subroutine initPtsrcPrecond(comm, samp_group) pt1 => pc(c1)%p if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,1000) == 0) write(*,*) k1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,10000) == 0) write(*,*) 'Computing A =', k1, pt1%nsrc i1 = i1+1 i2 = 0 @@ -1673,7 +1674,7 @@ subroutine initPtsrcPrecond(comm, samp_group) ! Construct matrix with sparsity pattern do i1 = 1, P_cr(samp_group)%invM_src(1,j)%M%ni - if (myid_pre == 0 .and. mod(i1,1000) == 0) write(*,*) i1, P_cr(samp_group)%invM_src(1,j)%M%ni + if (myid_pre == 0 .and. mod(i1,10000) == 0) write(*,*) 'Updating A =', i1, P_cr(samp_group)%invM_src(1,j)%M%ni c1 = 1 k1 = i1 do while (k1 > pc(c1)%p%nsrc) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 3f4aa8089..b2426ccf6 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -121,6 +121,10 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) c%nmaps = info%nmaps c%ndet = num_tokens(trim(cpar%ds_tod_dets(id_abs)), ",") c%sol_elong_range = cpar%zs_sol_elong + + c%gain_tune_sigma0 = .false. + c%gain_samprate = 1.d0 / 3600.d0 / 24.d0 + c%gain_sigma_0 = 0.005 nside_beam = 128 nmaps_beam = 1 @@ -280,7 +284,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, sample_abs_bandpass = .false. ! don't sample absolute bandpasses select_data = .false. !self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration - sample_gain = .false. ! Gain sampling, LB TOD sims have perfect gain + sample_gain = .true. ! Gain sampling, LB TOD sims have perfect gain !!$ if (trim(self%freq) == '01' .or. trim(self%freq) == '02' .or. & !!$ & trim(self%freq) == '03' .or. & !!$ & trim(self%freq) == '09' .or. trim(self%freq) == '10') then @@ -343,13 +347,13 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, !------------------------------------ ! Sample gain components in separate TOD loops; marginal with respect to n_corr - if (sample_gain) then + if (iter > 1 .and. sample_gain) then ! 'abscal': the global constant gain factor - call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2) + !call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2) ! 'relcal': the gain factor that is constant in time but varying between detectors ! call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) ! 'deltaG': the time-variable and detector-variable gain - call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) + call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask2, procmask2, smooth=.true.) end if ! Prepare intermediate data structures diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 16004fb0e..2e869dc83 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -1398,9 +1398,10 @@ function lnL_zodi(p) !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'noise', data(i)%tod%scans(scan)%d(j)%N_psd%sigma0 chisq = sum( & & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - & - mono & + & - data(i)%tod%scans(scan)%d(j)%gain * & + & (data(i)%tod%scans(scan)%d(j)%downsamp_sky & + & + data(i)%tod%scans(scan)%d(j)%downsamp_zodi & + & + mono) & & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & &) chisq_tot = chisq_tot + chisq @@ -1408,7 +1409,7 @@ function lnL_zodi(p) call wall_time(t4) !if (data(1)%tod%myid == 10) write(*,*) ' CPU3 = ', t4-t3 -!!$ write(*,*) 'a', i, scan!, allocated(data(i)%tod%scans(scan)%d(j)%downsamp_tod) +!!$ write(*,*) 'a', i, scan!, allocated(data(i)%tod%scans(scan)%d(j)%downsa1mp_tod) !!$ write(*,*) 'b', j!, allocated(data(i)%tod%scans(scan)%d(j)%downsamp_tod) !write(*,*) 'do not remove -- memory corruption bug "fix"', ndof!, allocated(data(i)%tod%scans(scan)%d(j)%downsamp_tod) ndof = ndof + size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) @@ -1428,9 +1429,10 @@ function lnL_zodi(p) open(58,file=trim(cpar%outdir)//'/todres_'//trim(data(i)%tod%freq)//'_'//scan_str//'.dat', recl=2048) do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) write(58,*) data(i)%tod%scans(scan)%d(j)%downsamp_point(k,:), data(i)%tod%scans(scan)%d(j)%downsamp_tod(k) & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky(k) & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi(k) & - & - mono + & - data(i)%tod%scans(scan)%d(j)%gain * & + & (data(i)%tod%scans(scan)%d(j)%downsamp_sky(k) & + & + data(i)%tod%scans(scan)%d(j)%downsamp_zodi(k) & + & + mono) end do close(58) end if From 3306a1032edbbd60d92449861455644ecdc02bd9 Mon Sep 17 00:00:00 2001 From: Angela Bonato Date: Tue, 4 Feb 2025 13:39:14 +0100 Subject: [PATCH 094/171] added deallocate(mask_zodi) statement --- commander3/src/comm_tod_driver_mod.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index c60943ee2..b28df91b2 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -600,6 +600,7 @@ subroutine dealloc_scan_data(sd) if (allocated(sd%s_zodi)) deallocate(sd%s_zodi) if (allocated(sd%s_zodi_scat)) deallocate(sd%s_zodi_scat) if (allocated(sd%s_zodi_therm)) deallocate(sd%s_zodi_therm) + if (allocated(sd%mask_zodi)) deallocate(sd%mask_zodi) if (allocated(sd%s_totA)) deallocate(sd%s_totA) if (allocated(sd%s_totB)) deallocate(sd%s_totB) if (allocated(sd%s_inst)) deallocate(sd%s_inst) From 726627fdd1279e6e5c970308b03e2fbd8ca0dad9 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 5 Feb 2025 00:14:23 +0100 Subject: [PATCH 095/171] Added missing mkl module load --- install_ita.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_ita.sh b/install_ita.sh index c9c93c72f..9bf467a6a 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -161,7 +161,7 @@ then mpicxx="mpiicpx" printf "Using Intel:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" #module load intel/oneapi mpi/2021.11 compiler-rt/2023.2.1 mkl/2023.2.0 icc/2023.2.1 - module load intel/oneapi compiler/latest mpi/latest + module load intel/oneapi compiler/latest mpi/latest mkl/latest elif [[ "$toolchain" =~ "gnu" ]] then # Compilers From 46478e5b3c0f52803b1681bd1503a8a2b5d0015e Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 5 Feb 2025 00:14:55 +0100 Subject: [PATCH 096/171] Fixed initialization error --- commander3/src/comm_param_mod.f90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 55f2121d6..d71440c6b 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -522,6 +522,7 @@ subroutine read_global_params_hash(htbl, cpar) call get_parameter_hashtable(htbl, 'FFTW3_MAGIC_NUMBERS', par_string=cpar%fft_magic_number_file, path=.true.) call get_parameter_hashtable(htbl, 'TOD_NUM_BP_PROPOSALS_PER_ITER', par_int=cpar%num_bp_prop) call get_parameter_hashtable(htbl, 'NUM_GIBBS_STEPS_PER_TOD_SAMPLE', par_int=cpar%tod_freq) + if (cpar%tod_freq .eq. 0) cpar%tod_freq = cpar%num_gibbs_iter + 1 call get_parameter_hashtable(htbl, 'TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER', par_int=cpar%output_4D_map_nth_iter) call get_parameter_hashtable(htbl, 'TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER', par_int=cpar%output_aux_maps) call get_parameter_hashtable(htbl, 'TOD_INCLUDE_ZODI', par_lgt=cpar%include_TOD_zodi) @@ -534,6 +535,8 @@ subroutine read_global_params_hash(htbl, cpar) call get_parameter_hashtable(htbl, 'ZODI_STATIC_MAP_BANDS', par_string=cpar%zodi_static_bands) end if end if + else + cpar%tod_freq = cpar%num_gibbs_iter + 1 end if if (cpar%resamp_CMB) then From d50596475571c702abcbe017f5cd600cd1f9b971 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 5 Feb 2025 00:29:31 +0100 Subject: [PATCH 097/171] Removed potentially dangerous array temporary behavior --- commander3/src/comm_tod_dirbe_mod.f90 | 3 ++- commander3/src/comm_tod_mod.f90 | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index d32e6d012..1784ef4af 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -372,7 +372,8 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, if (self%first_call) then do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle - call self%create_dynamic_mask(i, j, sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j), [-10.,10.], sd%mask(:,j)) + call self%create_dynamic_mask(i, j, sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j), [-10.,10.], sd%mask) + end do call sd%dealloc if (.not. any(self%scans(i)%d%accept)) cycle diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 1073a3062..1911a45ff 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -3002,10 +3002,10 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) integer(i4b), intent(in) :: scan, det real(sp), dimension(:), intent(in) :: res real(sp), dimension(2), intent(in) :: rms_range - real(sp), dimension(:), intent(inout) :: mask + real(sp), dimension(:,:), intent(inout) :: mask logical(lgt) :: cut - integer(i4b) :: i, j, k, n, ntod, nmax + integer(i4b) :: i, n, ntod, nmax real(dp) :: box_width, rms, vec(3), elon integer(i4b), allocatable, dimension(:,:) :: bad, buffer !real(dp), allocatable, dimension(:,:) :: mask_solar @@ -3017,7 +3017,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) rms = 0.d0 n = 0 do i = 1, ntod - if (mask(i) /= 1.) cycle + if (mask(i,det) /= 1.) cycle rms = rms + res(i)**2 n = n + 1 end do @@ -3043,7 +3043,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) do i = 1, ntod ! Apply RMS selection criterium - if (mask(i) == 1) then + if (mask(i,det) == 1) then cut = res(i) < rms_range(1)*rms .or. res(i) > rms_range(2)*rms else cut = .false. @@ -3060,7 +3060,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) if (cut) then ! Start new range if not already active if (bad(1,n+1) == -1) bad(1,n+1) = i - mask(i) = 0. + mask(i,det) = 0. else ! Close active range if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then From 1a9465819f17b84f855eb91f2dd1c598d51f47f3 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 5 Feb 2025 01:25:14 +0100 Subject: [PATCH 098/171] Working paramter file when using libsharp in debug mode --- commander3/parameter_files/param_continuous_integration.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/commander3/parameter_files/param_continuous_integration.txt b/commander3/parameter_files/param_continuous_integration.txt index 20f3652c9..c1dcef0bd 100644 --- a/commander3/parameter_files/param_continuous_integration.txt +++ b/commander3/parameter_files/param_continuous_integration.txt @@ -719,6 +719,7 @@ CG_SAMPLING_GROUP&& = cmb,ff,ame,synch,dust CG_SAMPLING_GROUP_MASK&& = fullsky CG_SAMPLING_GROUP_MAXITER&& = 60 CG_SAMPLING_GROUP_BANDS&& = all + @END 02 #@START 02 From b8dff3d2d503bc1c13677a17c2a72abc754c83c5 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 5 Feb 2025 18:46:29 +0100 Subject: [PATCH 099/171] Working version with ifx --- cmake/projects/healpix.cmake | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cmake/projects/healpix.cmake b/cmake/projects/healpix.cmake index 916b35203..4d60f2e6e 100644 --- a/cmake/projects/healpix.cmake +++ b/cmake/projects/healpix.cmake @@ -44,28 +44,19 @@ if(COMPILE_HEALPIX) # Below flags used to configure Libsharp as part of HEALPix if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) #set(healpix_sharp2_C_FLAGS "-static-intel -O3 -ffast-math -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") - #set(healpix_sharp2_C_FLAGS "-static-intel -O3 -ffast-math -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") - set(healpix_sharp2_C_FLAGS "-static-intel -O3 -ffast-math -mavx2 -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") - # MPI support, OpenMP, portable binary: - #set(healpix_sharp2_C_FLAGS "-DUSE_MPI -DMULTIARCH -std=c99 -O3 -ffast-math") + set(healpix_sharp2_C_FLAGS "-static-intel -O3 -fp-speculation=safe -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") elseif(CMAKE_Fortran_COMPILER_ID MATCHES GNU) - #set(healpix_sharp2_C_FLAGS "-O3 -ffast-math -march=native -std=c99 -DUSE_MPI -fopenmp") - #set(healpix_sharp2_C_FLAGS "-DUSE_MPI -DMULTIARCH -std=c99 -O3 -ffast-math") set(healpix_sharp2_C_FLAGS "-O3 -ffast-math -mavx2 -std=c99 -DUSE_MPI -fopenmp") elseif(CMAKE_Fortran_COMPILER_ID MATCHES PGI) set(healpix_sharp2_C_FLAGS "-O4 -fast -Mipa=fast,inline -Msmartalloc -std=c99 -DUSE_MPI -mp") - #elseif(CMAKE_Fortran_COMPILER_ID MATCHES NVIDIA) - #set(healpix_sharp2_C_FLAGS "-O4 -fast -Mipa=fast,inline -Msmartalloc -std=c99 -DUSE_MPI -mp") elseif(CMAKE_Fortran_COMPILER_ID MATCHES Flang) - #set(healpix_sharp2_C_FLAGS "-O4 -fast -Mipa=fast,inline -Msmartalloc -std=c99 -DUSE_MPI -mp") set(healpix_sharp2_C_FLAGS "-DUSE_MPI -DMULTIARCH -std=c99 -O3 -ffast-math") endif() #------------------------------------------------------------------------------ - # Copying modyfied configure script to healpix root + # Copying modified configure script to healpix root list(APPEND healpix_copy_configure_script "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_SOURCE_DIR}/cmake/third_party/healpix/hpxconfig_functions.sh" - #"${CMAKE_DOWNLOAD_DIRECTORY}/${project}/src/${project}/hpxconfig_functions.sh" "${HEALPIX_SOURCE_DIR}/hpxconfig_functions.sh" #"&&" ) From d3dca52be113c7e3aa6f6a6704225e3667a8eac8 Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 6 Feb 2025 17:11:11 +0100 Subject: [PATCH 100/171] Added test for parameter file during readin --- commander3/src/commander.f90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index de9b7dadb..8ea6c7583 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -54,7 +54,14 @@ program commander ! Giving the simple command line arguments for user to chose from. comm3_args: do arg_indx = 1, command_argument_count() - call get_command_argument(arg_indx, arg) + call get_command_argument(arg_indx, arg, j, stat) + if (stat .ne. 0) then + if (stat == -1) then + write(*,*) 'Command line argument was truncated: ', arg + else + write(*,*) 'Command line argument retrieval failed: ', arg + end if + end if select case (arg) case ('-v', '--version') From 1789ae54c2c38917da5804749043eb1b46ed9fc7 Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 6 Feb 2025 17:23:28 +0100 Subject: [PATCH 101/171] Fixed subroutine notation --- commander3/src/comm_param_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index d71440c6b..646d7d266 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -3086,7 +3086,7 @@ subroutine read_zodi_params_hash(htbl, cpar) end if -end subroutine +end subroutine read_zodi_params_hash ! ******************************************************** ! Utility routines From 13270948c68cbf379b2c364bec504dc0a1f21168 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 11 Feb 2025 19:32:22 +0100 Subject: [PATCH 102/171] Less speed-killing, still working fine --- cmake/projects/healpix.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/projects/healpix.cmake b/cmake/projects/healpix.cmake index 4d60f2e6e..f142e087a 100644 --- a/cmake/projects/healpix.cmake +++ b/cmake/projects/healpix.cmake @@ -44,7 +44,7 @@ if(COMPILE_HEALPIX) # Below flags used to configure Libsharp as part of HEALPix if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) #set(healpix_sharp2_C_FLAGS "-static-intel -O3 -ffast-math -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") - set(healpix_sharp2_C_FLAGS "-static-intel -O3 -fp-speculation=safe -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") + set(healpix_sharp2_C_FLAGS "-static-intel -O3 -fno-strict-aliasing -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") elseif(CMAKE_Fortran_COMPILER_ID MATCHES GNU) set(healpix_sharp2_C_FLAGS "-O3 -ffast-math -mavx2 -std=c99 -DUSE_MPI -fopenmp") elseif(CMAKE_Fortran_COMPILER_ID MATCHES PGI) From 08bfc813569ddc6d5f6fff4f1f2b119b7a162e7f Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Wed, 12 Feb 2025 15:12:12 +0100 Subject: [PATCH 103/171] new empty crosstalk module for hfi --- Makefile | 4 +- cmake/projects/commander3.cmake | 1 + cmake/projects/healpix.cmake | 6 +- commander3/src/Makefile | 8 +- commander3/src/comm_tod_crosstalk_mod.f90 | 75 ++++++++++ commander3/src/comm_tod_hfi_mod.f90 | 161 +++++++++++----------- commander3/src/get_deps.sh | 3 + commander3/src/sharp_test.f90 | 1 - 8 files changed, 171 insertions(+), 88 deletions(-) create mode 100644 commander3/src/comm_tod_crosstalk_mod.f90 diff --git a/Makefile b/Makefile index 5645c752f..b35c421f5 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,8 @@ all : commander commander : @cd commander3/src; $(MAKE) +sharp_test: + @cd commander3/src; $(MAKE) sharp_test + clean : @cd commander3/src; $(MAKE) clean - diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 86e4af7d1..c556ed159 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -167,6 +167,7 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_tod_adc_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_adc_smod.f90 ${COMMANDER3_SOURCE_DIR}/comm_ame_lognormal_mod.f90 + ${COMMANDER3_SOURCE_DIR}/comm_tod_crosstalk_mod.f90 # CAMB #${COMMANDER3_SOURCE_DIR}/comm_camb_mod.f90 ) diff --git a/cmake/projects/healpix.cmake b/cmake/projects/healpix.cmake index 4d60f2e6e..9400c56fa 100644 --- a/cmake/projects/healpix.cmake +++ b/cmake/projects/healpix.cmake @@ -44,7 +44,11 @@ if(COMPILE_HEALPIX) # Below flags used to configure Libsharp as part of HEALPix if(CMAKE_Fortran_COMPILER_ID MATCHES Intel) #set(healpix_sharp2_C_FLAGS "-static-intel -O3 -ffast-math -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") - set(healpix_sharp2_C_FLAGS "-static-intel -O3 -fp-speculation=safe -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") + if(CMAKE_BUILD_TYPE MATCHES Release) + set(healpix_sharp2_C_FLAGS "-static-intel -O3 -fp-speculation=safe -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") + elseif(CMAKE_BUILD_TYPE MATCHES Debug) + set(healpix_sharp2_C_FLAGS "-static-intel -O0 -g -fp-speculation=safe -march=native -std=c99 -DUSE_MPI -qopenmp -D__PURE_INTEL_C99_HEADERS__") + endif() elseif(CMAKE_Fortran_COMPILER_ID MATCHES GNU) set(healpix_sharp2_C_FLAGS "-O3 -ffast-math -mavx2 -std=c99 -DUSE_MPI -fopenmp") elseif(CMAKE_Fortran_COMPILER_ID MATCHES PGI) diff --git a/commander3/src/Makefile b/commander3/src/Makefile index e91f1ed59..a4a5af002 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -96,6 +96,7 @@ F90SOURCES=hashtbl.f90 \ comm_tod_mod.f90 \ comm_tod_mapmaking_mod.f90 \ comm_tod_bandpass_mod.f90 \ + comm_tod_crosstalk_mod.f90 \ comm_tod_gain_mod.f90 comm_tod_gain_smod.f90 \ comm_tod_pointing_mod.f90 \ comm_tod_lfi_mod.f90 comm_tod_lfi_smod.f90 \ @@ -130,6 +131,10 @@ all: commander commander: $(subst .f,.o,$(FSOURCES)) $(subst .f90,.o,$(F90SOURCES)) $(MPF90) -o commander $+ $(LINK) $(MPFCLIBS) +sharp_test: sharp.o sharp_test.o + $(MPF90) -o sharp_test sharp_test.o sharp.o comm_map_mod.o $(LINK) $(MPFCLIBS) + + .PHONY: clean clean: -rm -f *.o commander *.{mod,smod} @@ -216,12 +221,13 @@ comm_timing_mod.o : comm_utils.o comm_tod_adc_mod.o : math_tools.o spline_1d_mod.o comm_tod_mod.o comm_map_mod.o comm_param_mod.o invsamp_mod.o comm_hdf_mod.o comm_tod_adc_smod.o : comm_tod_adc_mod.o comm_tod_bandpass_mod.o : comm_tod_mod.o comm_utils.o comm_status_mod.o +comm_tod_crosstalk_mod.o : comm_tod_mod.o comm_status_mod.o comm_tod_cray_mod.o : comm_param_mod.o comm_tod_dirbe_mod.o : comm_tod_driver_mod.o comm_tod_driver_mod.o : comm_tod_mod.o comm_tod_gain_mod.o comm_tod_noise_mod.o comm_tod_pointing_mod.o comm_tod_bandpass_mod.o comm_tod_orbdipole_mod.o comm_tod_simulations_mod.o comm_tod_mapmaking_mod.o comm_tod_jump_mod.o comm_tod_adc_mod.o comm_zodi_mod.o comm_tod_cray_mod.o comm_shared_arr_mod.o comm_huffman_mod.o comm_4d_map_mod.o comm_tod_gain_mod.o : comm_tod_noise_mod.o comm_tod_gain_smod.o : comm_tod_gain_mod.o -comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_tod_cray_mod.o +comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_tod_cray_mod.o comm_tod_crosstalk_mod.o comm_tod_inst_mod.o : comm_tod_mod.o comm_tod_lfi_mod.o comm_tod_wmap_mod.o comm_tod_hfi_mod.o comm_tod_spider_mod.o comm_tod_dirbe_mod.o comm_tod_lb_mod.o comm_tod_jump_mod.o : comm_utils.o comm_tod_lb_mod.o : comm_tod_mod.o comm_tod_driver_mod.o comm_conviqt_mod.o diff --git a/commander3/src/comm_tod_crosstalk_mod.f90 b/commander3/src/comm_tod_crosstalk_mod.f90 new file mode 100644 index 000000000..73cd9ac77 --- /dev/null +++ b/commander3/src/comm_tod_crosstalk_mod.f90 @@ -0,0 +1,75 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +! +! This file is part of Commander3. +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ + +module comm_tod_crosstalk_mod + use comm_tod_mod + use comm_status_mod + use comm_tod_driver_mod + implicit none + private + + public comm_crosstalk + + type :: comm_crosstalk + real(dp), dimension (:,:), allocatable :: crosstalk_matrix + contains + procedure :: estimate_crosstalk_matrix + procedure :: remove_crosstalk_signal + end type comm_crosstalk + + interface comm_crosstalk + procedure xtalk_constructor + end interface comm_crosstalk + + type crosstalk_pointer + class(comm_crosstalk), pointer :: p => null() + end type crosstalk_pointer + +contains + + !initializes a comm_crosstalk class + function xtalk_constructor(correlations) result(c) + implicit none + logical(lgt), dimension(:,:), intent(in) :: correlations + class(comm_crosstalk), pointer :: c + + allocate(c) + allocate(c%crosstalk_matrix(size(correlations(1,:)), size(correlations(:,1)))) + + end function xtalk_constructor + + ! estimates the crosstalk coeficients between each detector + subroutine estimate_crosstalk_matrix(self) + implicit none + class(comm_crosstalk), intent(in) :: self + + + end subroutine estimate_crosstalk_matrix + + subroutine remove_crosstalk_signal(self, sd, i) + implicit none + class(comm_crosstalk), intent(in) :: self + class(comm_scandata), intent(inout) :: sd + integer(i4b), intent(in) :: i + + end subroutine remove_crosstalk_signal + +end module comm_tod_crosstalk_mod diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index b71c3df71..e67050907 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -32,6 +32,8 @@ module comm_tod_HFI_mod ! use comm_tod_driver_mod use comm_tod_cray_mod + use comm_conviqt_mod + use comm_tod_crosstalk_mod implicit none private @@ -39,6 +41,7 @@ module comm_tod_HFI_mod type, extends(comm_tod) :: comm_HFI_tod integer(i4b), allocatable, dimension(:,:) :: mod_phase + class(comm_crosstalk), pointer :: xtalk contains procedure :: process_tod => process_HFI_tod procedure :: read_tod_inst => read_tod_inst_HFI @@ -86,9 +89,11 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) character(len=128), intent(in) :: tod_type class(comm_HFI_tod), pointer :: c - integer(i4b) :: i, j, nside_beam, lmax_beam, nmaps_beam, ierr + integer(i4b) :: i, j, lmax_beam, nmaps_beam, ierr logical(lgt) :: pol_beam + logical(lgt), dimension(:,:), allocatable :: correlations + ! Allocate object allocate(c) @@ -122,7 +127,11 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%samprate_lowres = 1.d0 ! Lowres samprate in Hz c%nhorn = 1 c%compressed_tod = .true. - c%correct_sl = .false. + if(c%freq == '545' .or. c%freq == '857') then !currently no sidelobe models + c%correct_sl = .false. + else + c%correct_sl = .true. + end if c%correct_orb = .true. c%orb_4pi_beam = .false. c%symm_flags = .false. @@ -132,10 +141,9 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%ntime = 1 c%partner = -1 - nside_beam = 512 - nmaps_beam = 3 - pol_beam = .true. - c%nside_beam = nside_beam + nmaps_beam = 3 + pol_beam = .true. + c%nside_beam = 512 ! Get detector labels call get_tokens(cpar%ds_tod_dets(id_abs), ",", c%label) @@ -150,7 +158,7 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) call c%precompute_lookups() ! Load the instrument file - call c%load_instrument_file(nside_beam, nmaps_beam, pol_beam, cpar%comm_chain) + call c%load_instrument_file(c%nside_beam, nmaps_beam, pol_beam, cpar%comm_chain) ! Allocate sidelobe convolution data structures !allocate(c%slconv(c%ndet), c%orb_dp) @@ -168,7 +176,14 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Allocate modulation phase allocate(c%mod_phase(c%ndet,c%nscan)) c%mod_phase = 1.d0 - + + ! initialize crosstalk class + allocate(correlations(c%ndet, c%ndet)) + correlations = .true. + + ! allocate(c%xtalk) + c%xtalk => comm_crosstalk(correlations) + end function constructor_hfi !************************************************** @@ -282,16 +297,16 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! stop ! Precompute far sidelobe Conviqt structures - !if (self%correct_sl) then - ! if (self%myid == 0) write(*,*) 'Precomputing sidelobe convolved sky' - ! do i = 1, self%ndet + if (self%correct_sl) then + if (self%myid == 0) write(*,*) 'Precomputing sidelobe convolved sky' + do i = 1, self%ndet !TODO: figure out why this is rotated - ! call map_in(i,1)%p%YtW() ! Compute sky a_lms - ! self%slconv(i)%p => comm_conviqt(self%myid_shared, self%comm_shared, & - ! & self%myid_inter, self%comm_inter, self%slbeam(i)%p%info%nside, & - ! & 100, 3, 100, self%slbeam(i)%p, map_in(i,1)%p, 2) - ! end do - !end if + call map_in(i,1)%p%YtW() ! Compute sky a_lms + self%slconv(i)%p => comm_conviqt(self%myid_shared, self%comm_shared, & + & self%myid_inter, self%comm_inter, self%slbeam(i)%p%info%nside, & + & 100, 3, 100, self%slbeam(i)%p, map_in(i,1)%p, 2) + end do + end if ! write(*,*) 'qqq', self%myid ! if (.true. .or. self%myid == 78) write(*,*) 'a', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires !!$ call mpi_finalize(ierr) @@ -303,12 +318,22 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Perform main sampling steps !------------------------------------ - ! Fit low-level non-linearity parameters - do i = 1, self%nscan - + + do i =1, self%nscan ! Skip scan if no accepted data if (.not. any(self%scans(i)%d%accept)) cycle call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, skip_nonlin=.true.) + end do + + ! estimate A/B detector crosstalk coeficients + call self%xtalk%estimate_crosstalk_matrix() + + ! Fit per-chunk low-level non-linearity parameters + do i = 1, self%nscan + ! Subtract A/B detector crosstalk + ! Not implemented yet + + call self%xtalk%remove_crosstalk_signal(sd, i) ! Estimate modulation baselines; separate for odd and even samples if (self%first_call) then @@ -320,14 +345,38 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Fix modulation phase if (self%first_call) call set_modulation_phase(sd, self, i) - ! Estimate ADC corrections - ! Not implemented yet - + ! Fix dc level jumps + ! Not implemented yet + + ! Dark bolometer drift correction + ! Not implemented yet + ! Clean up call sd%dealloc end do - + + ! Fit global timestream contaminants + + ! Subtract cosmic ray contribution + ! Not implemented yet + + ! Estimate ADC corrections + ! Not implemented yet + + ! Fit 4k Line emission + ! Not implemented yet + + ! Fit bolometer transfer function parameters? + ! Not implemented yet + + + + + ! NOW Sample high level tod components that require cleaned data + ! Sample gain components in separate TOD loops; marginal with respect to n_corr + ! TODO: Also sample non-linear gain response here? + call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask2, procmask2) !call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) !call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) @@ -360,48 +409,9 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m else call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if - -!!$ ! Calling Simulation Routine -!!$ if (self%enable_tod_simulations) then -!!$ call simulate_tod(self, i, sd%s_tot, sd%n_corr, handle) -!!$ call sd%dealloc -!!$ cycle -!!$ end if - - ! ************************************************************************************ - ! Perform low-level TOD processing; raw modulated TOD -> clean demodulated TOD - ! ************************************************************************************ - - if (self%first_call) then - ! Search for jumps - ! Not implemented yet - end if - - ! Apply jump corrections - ! Not implemented yet - - ! Fit and subtract dark bolometer signal; should this come before or after cosmic rays..? - ! Not implemented yet - - ! remove cosmic rays -!!$ do j=1, sd%ndet -!!$ call self%cray(j)%p%build_cray_templates() -!!$ call self%cray(j)%p%fit_cray_amplitudes() -!!$ end do - - ! Fit and subtract 4K lines - ! Not implemented yet - - ! Fit and deconvolve bolometer transfer function - ! Not implemented yet - - - - ! ************************************************************************************ - ! Perform high-level TOD processing; clean demodulated TOD -> maps - ! ************************************************************************************ - + ! Sample correlated noise + !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) sd%n_corr = 0.d0 @@ -424,7 +434,6 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Compute calibrated TOD for mapmaking allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) call compute_calibrated_data(self, i, sd, d_calib) - ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) @@ -446,30 +455,14 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end do - ! calculate gain as a median of all scans - !do j = 1, self%ndet - ! allocate(temp(self%nscan)) - - ! do i = 1, self%nscan - ! temp(i) = self%scans(i)%d(j)%gain - ! end do - - ! gain_median = median(temp) - - ! do i = 1, self%nscan - ! self%scans(i)%d(j)%gain = gain_median - ! end do - - ! deallocate(temp) - !end do - - if (self%myid == 0) write(*,*) ' --> Finalizing maps, bp' ! Output latest scan list with new timing information if (output_scanlist) call self%output_scan_list(slist) ! Solve for maps + ! TODO: update mapmaker to n+2 maps + ! TODO: handle bolometer transfer function in the mapmaking call synchronize_binmap(binmap, self) if (sample_rel_bandpass) then if (self%nmaps > 1) then diff --git a/commander3/src/get_deps.sh b/commander3/src/get_deps.sh index cfde50276..579299dce 100755 --- a/commander3/src/get_deps.sh +++ b/commander3/src/get_deps.sh @@ -1,4 +1,7 @@ #!/bin/bash +# Produces makefiles that ocntain the actual dependancies of each file +# usage: bash get_deps.sh *.f90 + declare -A blacklist declare -A srcs_lower diff --git a/commander3/src/sharp_test.f90 b/commander3/src/sharp_test.f90 index 99cadfde9..3e528c445 100644 --- a/commander3/src/sharp_test.f90 +++ b/commander3/src/sharp_test.f90 @@ -1,6 +1,5 @@ program sharp_test use comm_map_mod - use comm_param_mod use ARS_mod implicit none From 30e4b436bea3384f39a791ca0af2cd0c5081afca Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 13 Feb 2025 06:34:52 +0100 Subject: [PATCH 104/171] Added synch chipass defaults --- .../components/synch/synch_CHIPASS.defaults | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 commander3/parameter_files/defaults/components/synch/synch_CHIPASS.defaults diff --git a/commander3/parameter_files/defaults/components/synch/synch_CHIPASS.defaults b/commander3/parameter_files/defaults/components/synch/synch_CHIPASS.defaults new file mode 100644 index 000000000..b3e4c6f2b --- /dev/null +++ b/commander3/parameter_files/defaults/components/synch/synch_CHIPASS.defaults @@ -0,0 +1,57 @@ +# Synchrotron component for LFI TOD analysis +COMP_LABEL&& = synch +COMP_TYPE&& = power_law +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .true. +COMP_CG_SCALE_T&& = 5.d5 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 100 #50, increased to 100 due to prior sampling convergence +COMP_NSIDE&& = 1024 +COMP_MONOPOLE_PRIOR&& = bandmono:0.4-Haslam # +COMP_DEFLATION_MASK&& = fullsky +COMP_L_APOD&& = 2900 +COMP_OUTPUT_FWHM&& = 15 # arcmin +COMP_UNIT&& = uK_RJ +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_NU_REF_T&& = 0.408 +COMP_NU_REF_P&& = 30 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_synch_beta_sampling_BP10_n1024_TQU.fits mask_clean_synch_tr40_others_tr40_radio_tr30_chisq_tr5_n1024_udgraded_tr75ptc_TQU.fits + +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 2900 +COMP_AMP_INPUT_MAP&& = init_synch_amp_BP8.1_v1.fits +COMP_AMP_PRIOR_MAP&& = none + +COMP_IND_LMAX&& = 0 + +COMP_CL_TYPE&& = gauss # {none, single_l, binned, power_law} +COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.5 +COMP_CL_BETA_PRIOR_RMS&& = 0.1 +COMP_CL_L_PIVOT&& = 100 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 1e14 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 200 +COMP_CL_DEFAULT_AMP_B&& = 100 +COMP_CL_DEFAULT_BETA_T&& = 15d0 +COMP_CL_DEFAULT_BETA_E&& = 30d0 +COMP_CL_DEFAULT_BETA_B&& = 30d0 + +COMP_BETA_PRIOR_UNI_LOW&& = -4.5 +COMP_BETA_PRIOR_UNI_HIGH&& = -1.5 +COMP_BETA_PRIOR_GAUSS_MEAN&& = -3.1 +COMP_BETA_PRIOR_GAUSS_RMS&& = 0.1 #0.1 +COMP_BETA_SMOOTHING_SCALE&& = 3 +COMP_BETA_POLTYPE&& = 2 # index {1 = {T+Q+U}, 2 = {T,Q+U}, 3 = {T,Q,U}} +COMP_BETA_NU_MIN&& = 0. # Lowest frequency for index estimation in GHz +COMP_BETA_NU_MAX&& = 98. # Highest frequency for index estimation in GHz +COMP_BETA_INPUT_MAP&& = init_synch_beta_BP8.1_v1.fits +COMP_BETA_DEFAULT&& = -3.1 + +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_OUTPUT_EB_MAP&& = .false. +COMP_INIT_FROM_HDF&& = default + + From 1ae92959609281e732e9958bc43ecc4903a518d4 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Fri, 14 Feb 2025 15:58:48 +0100 Subject: [PATCH 105/171] added now framework for one channel over the full flight processing for hfi --- commander3/src/comm_tod_cray_mod.f90 | 4 +- commander3/src/comm_tod_driver_mod.f90 | 76 ++++++++++++- commander3/src/comm_tod_hfi_mod.f90 | 126 ++++++++++++++++++---- commander3/src/comm_tod_mapmaking_mod.f90 | 38 ++++++- commander3/src/comm_tod_mod.f90 | 29 +++++ 5 files changed, 247 insertions(+), 26 deletions(-) diff --git a/commander3/src/comm_tod_cray_mod.f90 b/commander3/src/comm_tod_cray_mod.f90 index 2d70b037c..e05db2331 100644 --- a/commander3/src/comm_tod_cray_mod.f90 +++ b/commander3/src/comm_tod_cray_mod.f90 @@ -68,9 +68,11 @@ subroutine build_cray_templates(self) end subroutine build_cray_templates ! fits the constructed templates to the cosmic rays in the timestreams - subroutine fit_cray_amplitudes(self) + subroutine fit_cray_amplitudes(self, tod, cr) implicit none class(comm_cray), intent(inout) :: self + real(sp), dimension(:), intent(in) :: tod + real(sp), dimension(:), intent(inout) :: cr end subroutine fit_cray_amplitudes diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index b28df91b2..c80623ba3 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -18,6 +18,18 @@ module comm_tod_driver_mod use omp_lib implicit none + ! Class for uncompressed data of a single detector over the full flight + type :: comm_detdata + + integer(i4b) :: nscan + integer(i4b), allocatable, dimension(:) :: ntod, scans + real(sp), allocatable, dimension(:,:) :: tod + contains + procedure init_singlehorn => init_det_data_singlehorn + procedure dealloc => dealloc_det_data + + end type comm_detdata + ! Class for uncompressed data for a given scan type :: comm_scandata integer(i4b) :: ntod, ndet, nhorn, ndelta @@ -51,6 +63,7 @@ module comm_tod_driver_mod real(sp), allocatable, dimension(:,:) :: s_gainB ! Total signal, horn B (differential only) real(sp), allocatable, dimension(:,:) :: s_orbA ! Orbital signal, horn A (differential only) real(sp), allocatable, dimension(:,:) :: s_orbB ! Orbital signal, horn B (differential only) + real(sp), allocatable, dimension(:,:) :: dark ! Dark bolometer signals integer(i4b) :: band ! Band ID contains procedure :: init_singlehorn => init_scan_data_singlehorn @@ -66,7 +79,7 @@ module comm_tod_driver_mod ! Scan data routines !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, procmask2, procmask_zodi, & - & init_s_bp, init_s_bp_prop, init_s_sky_prop, skip_nonlin) + & init_s_bp, init_s_bp_prop, init_s_sky_prop, skip_nonlin, darkdata) implicit none class(comm_scandata), intent(inout) :: sd class(comm_tod), intent(inout) :: tod @@ -80,9 +93,10 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, logical(lgt), intent(in), optional :: init_s_bp_prop logical(lgt), intent(in), optional :: init_s_sky_prop logical(lgt), intent(in), optional :: skip_nonlin + logical(lgt), intent(in), optional :: darkdata integer(i4b) :: i, j, k, ndelta - logical(lgt) :: init_s_bp_, init_s_bp_prop_, init_s_sky_prop_, skip_nonlin_ + logical(lgt) :: init_s_bp_, init_s_bp_prop_, init_s_sky_prop_, skip_nonlin_, darkdata_ call timer%start(TOD_ALLOC, tod%band) @@ -95,7 +109,9 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, init_s_bp_ = .false.; if (present(init_s_bp)) init_s_bp_ = init_s_bp init_s_sky_prop_ = .false.; if (present(init_s_sky_prop)) init_s_sky_prop_ = init_s_sky_prop - skip_nonlin_ = .false.; if (present(skip_nonlin)) skip_nonlin_ = skip_nonlin + skip_nonlin_ = .false.; if (present(skip_nonlin)) skip_nonlin_ = skip_nonlin + darkdata_ = .false.; if (present(darkdata)) darkdata_ = darkdata + init_s_bp_prop_ = .false. if (present(init_s_bp_prop)) then init_s_bp_prop_ = init_s_bp_prop @@ -126,6 +142,11 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, if (init_s_sky_prop_) allocate(sd%mask2(sd%ntod, sd%ndet)) if (tod%sample_mono) allocate(sd%s_mono(sd%ntod, sd%ndet)) if (tod%apply_inst_corr) allocate(sd%s_inst(sd%ntod, sd%ndet)) + + if (darkdata_) then + allocate(sd%dark(sd%ntod, tod%ndark)) + end if + if (tod%subtract_zodi) then call tod%clear_zodi_cache() allocate(sd%s_zodi(sd%ntod, sd%ndet)) @@ -145,6 +166,12 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, call tod%decompress_pointing_and_flags(scan, j, sd%pix(:,j,:), & & sd%psi(:,j,:), sd%flag(:,j)) end do + + if(darkdata_) then + do j=1, tod%ndark + call tod%decompress_dark_data(scan, j, sd%dark(:,j)) + end do + end if call timer%stop(TOD_DECOMP, tod%band) !call update_status(status, "todinit_decomp") @@ -612,6 +639,49 @@ subroutine dealloc_scan_data(sd) end subroutine dealloc_scan_data + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! detdata routines + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + ! deallocates a det_data struture + subroutine dealloc_det_data(dd) + implicit none + class(comm_detdata), intent(inout) :: dd + + dd%nscan = -1 + deallocate(dd%scans) + deallocate(dd%ntod) + deallocate(dd%tod) + + end subroutine dealloc_det_data + + ! initializes a det_data structure for a single detector over the entire flight + ! for a singlehorn experiment like planck + subroutine init_det_data_singlehorn(dd, tod, det) + implicit none + class(comm_detdata), intent(inout) :: dd + class(comm_tod), intent(inout) :: tod + integer(i4b), intent(in) :: det + + + + end subroutine init_det_data_singlehorn + + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Scandata 2 detdata + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + subroutine populate_sd_from_dd(sd, dd, scan, det) + implicit none + class(comm_scandata), intent(inout) :: sd + class(comm_detdata), intent(inout) :: dd + integer(i4b), intent(in) :: scan + integer(i4b), intent(in) :: det + + + end subroutine populate_sd_from_dd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Sampling drivers etc. diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index e67050907..cc3893153 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -50,6 +50,10 @@ module comm_tod_HFI_mod procedure :: dumpToHDF_inst => dumpToHDF_HFI procedure :: construct_corrtemp_inst => construct_corrtemp_hfi procedure :: apply_nonlin_corr_inst => apply_nonlin_corr_hfi + + procedure, private :: stitch_hfi_dc_level + procedure, private :: hfi_dark_correction + procedure, private :: estimate_hfi_4k_lines end type comm_HFI_tod interface comm_HFI_tod @@ -140,6 +144,8 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%ndet = num_tokens(cpar%ds_tod_dets(id_abs), "," ) c%ntime = 1 c%partner = -1 + !TODO: set the number of dark bolometers to be correct + c%ndark = 1 nmaps_beam = 3 pol_beam = .true. @@ -183,6 +189,7 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! allocate(c%xtalk) c%xtalk => comm_crosstalk(correlations) + end function constructor_hfi @@ -242,6 +249,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, output_scanlist type(comm_binmap) :: binmap type(comm_scandata) :: sd + type(comm_detdata) :: dd character(len=4) :: ctext, myid_text character(len=6) :: samptext, scantext character(len=512) :: prefix, postfix, prefix4D, filename @@ -318,18 +326,15 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Perform main sampling steps !------------------------------------ - - do i =1, self%nscan - ! Skip scan if no accepted data - if (.not. any(self%scans(i)%d%accept)) cycle - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, skip_nonlin=.true.) - end do - ! estimate A/B detector crosstalk coeficients call self%xtalk%estimate_crosstalk_matrix() ! Fit per-chunk low-level non-linearity parameters do i = 1, self%nscan + ! Skip scan if no accepted data + if (.not. any(self%scans(i)%d%accept)) cycle + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, skip_nonlin=.true., darkdata=.true.) + ! Subtract A/B detector crosstalk ! Not implemented yet @@ -346,10 +351,14 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m if (self%first_call) call set_modulation_phase(sd, self, i) ! Fix dc level jumps - ! Not implemented yet + call self%stitch_hfi_dc_level(i, sd) ! Dark bolometer drift correction - ! Not implemented yet + call self%hfi_dark_correction(i, sd) + + ! 4k Line corrections + call self%estimate_hfi_4k_lines(i, sd) + ! Clean up call sd%dealloc @@ -358,20 +367,30 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Fit global timestream contaminants ! Subtract cosmic ray contribution - ! Not implemented yet + do j=1, self%ndet + + call init_det_data_singlehorn(dd, self, j) + + call self%cray(j)%p%build_cray_templates() + + do i=1, self%nscan + call populate_sd_from_dd(sd, dd, i, j) + + call self%cray(j)%p%fit_cray_amplitudes(sd%tod(j,:), sd%s_inst(j, :)) + + call sd%dealloc + end do + + call dd%dealloc + end do ! Estimate ADC corrections ! Not implemented yet - ! Fit 4k Line emission - ! Not implemented yet - ! Fit bolometer transfer function parameters? ! Not implemented yet - - ! NOW Sample high level tod components that require cleaned data ! Sample gain components in separate TOD loops; marginal with respect to n_corr @@ -466,9 +485,9 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m call synchronize_binmap(binmap, self) if (sample_rel_bandpass) then if (self%nmaps > 1) then - call finalize_binned_map(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2) + call finalize_binned_map_nplus2(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2, correct_transfer=.true.) else - call finalize_binned_map_unpol(self, binmap, rms_out, 1.d0, chisq_S=chisq_s, mask=procmask2) + call finalize_binned_map_unpol(self, binmap, rms_out, 1.d0, chisq_S=chisq_s, mask=procmask2, correct_transfer=.true.) end if else if(self%nmaps > 1) then @@ -834,10 +853,9 @@ subroutine apply_nonlin_corr_hfi(self, scan, sd) ! ! scan: int ! scan number - ! pix: int - ! index for pixel - ! psi: int - ! integer label for polarization angle + ! + ! sd: comm_scandata + ! structure holding the scan data ! ! Returns: ! -------- @@ -856,4 +874,70 @@ subroutine apply_nonlin_corr_hfi(self, scan, sd) end subroutine apply_nonlin_corr_hfi + subroutine stitch_hfi_dc_level(self, scan, sd) + ! Construct and apply HFI instrument-specific non-linear corrections + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! sd: comm_scandata object + ! structure holding the data for each scan + ! + implicit none + class(comm_hfi_tod), intent(in) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + !estimate dc levels between jumps and then update sd%tod to be flat + + end subroutine stitch_hfi_dc_level + + subroutine hfi_dark_correction(self, scan, sd) + ! Construct and apply HFI instrument-specific corrections + ! from dark bolometer timestreams + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! sd: comm_scandata object + ! structure holding the data for each scan + ! + implicit none + class(comm_hfi_tod), intent(in) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + !estimate dark correction then update sd%tod to be flat + + end subroutine hfi_dark_correction + + subroutine estimate_hfi_4k_lines(self, scan, sd) + ! Construct and apply HFI instrument-specific corrections + ! from 4k lines + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + ! scan: int + ! scan number + ! sd: comm_scandata object + ! structure holding the data for each scan + ! + implicit none + class(comm_hfi_tod), intent(in) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + !estimate 4k line signal + + end subroutine estimate_hfi_4k_lines + + end module comm_tod_HFI_mod diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index a6c9baedb..03ec0d14e 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -482,7 +482,7 @@ subroutine compute_Ax(tod, x_imarr, pmask, comp_S, M_diag, split, x, y, x_in, y_ end subroutine compute_Ax - subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) + subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask, correct_transfer) ! ! Routine to finalize temperature-only binned maps ! @@ -502,6 +502,7 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) real(dp), intent(in) :: scale real(dp), dimension(1:,1:), intent(out), optional :: chisq_S real(sp), dimension(0:), intent(in), optional :: mask + logical(lgt), intent(in), optional :: correct_transfer integer(i4b) :: i, j, k, nmaps, ierr, ndet, ncol, n_A, off, ndelta @@ -510,6 +511,10 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) real(dp), allocatable, dimension(:,:,:) :: b_tot, bs_tot real(dp), allocatable, dimension(:) :: W, eta real(dp), allocatable, dimension(:,:) :: A_tot + logical(lgt) :: correct_transfer_ + + correct_transfer_ = .false. + if(present(correct_transfer)) correct_transfer_ = correct_transfer myid = tod%myid nprocs= tod%numprocs @@ -604,6 +609,37 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask) end subroutine finalize_binned_map_unpol + subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, correct_transfer) + ! + ! Routine to finalize the binned maps + ! Makes one T map per detector but joint Q+U maps + ! + ! Arguments: + ! ---------- + ! tod: + ! binmap: + ! rms: + ! scale + ! chisq_S + ! mask + ! + implicit none + class(comm_tod), intent(in) :: tod + type(comm_binmap), intent(inout) :: binmap + class(comm_map), intent(inout) :: rms + real(dp), intent(in) :: scale + real(dp), dimension(1:,1:), intent(out), optional :: chisq_S + real(sp), dimension(0:), intent(in), optional :: mask + logical(lgt), intent(in), optional :: correct_transfer + + logical(lgt) :: correct_transfer_ + + correct_transfer_ = .false. + if(present(correct_transfer)) correct_transfer_ = correct_transfer + + + end subroutine finalize_binned_map_nplus2 + subroutine finalize_binned_map(tod, binmap, rms, scale, chisq_S, mask) ! diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 1911a45ff..1fc427d68 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -132,6 +132,7 @@ module comm_tod_mod integer(i4b) :: flag0 integer(i4b) :: n_xi ! Number of noise parameters integer(i4b) :: ntime ! Number of time values + integer(i4b) :: ndark = 0 ! number of dark bolometers integer(i4b) :: n_cray_temps = 0 ! number of classes of cosmic rays we have integer(i4b) :: baseline_order ! Polynomial order for baseline real(dp) :: central_freq !Central frequency @@ -271,6 +272,7 @@ module comm_tod_mod procedure :: decompress_pointing_and_flags procedure :: decompress_tod procedure :: decompress_diodes + procedure :: decompress_dark_data procedure :: tod_constructor procedure :: load_instrument_file procedure :: load_instrument_inst @@ -2467,6 +2469,33 @@ subroutine decompress_pointing_and_flags(self, scan, det, pix, psi, flag) end subroutine decompress_pointing_and_flags + subroutine decompress_dark_data(self, scan, det, dark) + ! Decompress dark tods + ! + ! Inputs: + ! ---------- + ! self: comm_tod + ! + ! scan: integer + ! scan integer label + ! det: integer + ! dark detector number + ! + ! Returns: + ! ---------- + ! dark : real(sp) (ntod, ndark) + ! dark bolometer data + + implicit none + class(comm_tod), intent(in) :: self + integer(i4b), intent(in) :: scan, det + real(sp), dimension(:), intent(out) :: dark + + dark = 0.0 + !TODO: this + + end subroutine decompress_dark_data + subroutine decompress_diodes(self, scan, det, diodes, flag, pix, psi) ! Decompress per-diode tod information ! From cc8bd306156e1d1f1e31700bfc8e3241f8360a2d Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 16 Feb 2025 19:40:39 +0100 Subject: [PATCH 106/171] Improved TOD masking; extended parameter field length from 256 to 2048 characters --- .../components/dust/dust_stars_n512.defaults | 2 +- commander3/src/comm_output_mod.f90 | 3 +- commander3/src/comm_param_mod.f90 | 298 ++++++++--------- commander3/src/comm_ptsrc_comp_mod.f90 | 106 +++--- commander3/src/comm_signal_mod.f90 | 2 +- commander3/src/comm_sparse_mod.f90 | 2 +- commander3/src/comm_tod_dirbe_mod.f90 | 38 ++- commander3/src/comm_tod_driver_mod.f90 | 8 +- commander3/src/comm_tod_gain_smod.f90 | 94 +++--- commander3/src/comm_tod_lfi_smod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 309 +++++++++++++++++- commander3/src/comm_zodi_comp_mod.f90 | 9 +- commander3/src/comm_zodi_mod.f90 | 26 +- commander3/src/comm_zodi_samp_mod.f90 | 4 +- commander3/src/commander.f90 | 4 +- commander3/src/math_tools.f90 | 165 ++++++++++ 16 files changed, 806 insertions(+), 266 deletions(-) diff --git a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults index 132dc64d2..673a53bd0 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults @@ -1,5 +1,5 @@ # Stars component -COMP_LABEL&& = stars_diff +COMP_LABEL&& = stars_dust COMP_TYPE&& = MBB COMP_CLASS&& = diffuse # {diffuse, ptsrc} COMP_POLARIZATION&& = .false. diff --git a/commander3/src/comm_output_mod.f90 b/commander3/src/comm_output_mod.f90 index e8d3f6159..3b57d08ac 100644 --- a/commander3/src/comm_output_mod.f90 +++ b/commander3/src/comm_output_mod.f90 @@ -145,7 +145,7 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) call create_hdf_group(file, trim(adjustl(itext))//'/md') end if call update_status(status, "output_chain") - + !Prepare mean foregrounds values print to file if (cpar%myid_chain == 0) then fg_file=trim(cpar%outdir)//'/fg_ind_mean_c' // trim(adjustl(ctext))//'.dat' @@ -512,6 +512,7 @@ subroutine write_params_to_hdf(cpar, chainfile) n = size(cpar%cs_label) do i = 1, n + !write(*,*) i, trim(adjustl(cpar%cs_label(i))) hdf_path = 'parameters/'//trim(adjustl(cpar%cs_label(i))) call create_hdf_group(chainfile, trim(hdf_path)) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 81364ef1e..15db50771 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -41,18 +41,18 @@ module comm_param_mod type(status_file) :: status type InterplanetaryDustParamLabels - character(len=128), dimension(2) :: general = [character(len=128) :: "T_0", "T_DELTA"] - character(len=128), dimension(6) :: common = [character(len=128) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] - character(len=128), dimension(4) :: cloud = [character(len=128) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] - character(len=128), dimension(4) :: band = [character(len=128) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] - character(len=128), dimension(5) :: ring = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(5) :: feature = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(2) :: interstellar = [character(len=128) :: 'R', 'ALPHA'] - character(len=128), dimension(5) :: fan = [character(len=128) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] - character(len=128), dimension(4) :: comet = [character(len=128) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] - character(len=128), dimension(16) :: WrightCloudRing = [character(len=128) :: 'p1', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p13', 'p14', 'p15', 'p16', 'p17', 'p18', 'p19'] - character(len=128), dimension(6) :: WrightBand = [character(len=128) :: 'q1', 'q5', 'q6', 'q7', 'q8', 'R_1'] - character(len=128), dimension(6) :: comp_types = [character(len=128) :: 'CLOUD', 'BAND', 'RING', 'FEATURE', 'WRIGHTCLOUDRING', 'WRIGHTBAND'] + character(len=2048), dimension(2) :: general = [character(len=2048) :: "T_0", "T_DELTA"] + character(len=2048), dimension(6) :: common = [character(len=2048) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] + character(len=2048), dimension(4) :: cloud = [character(len=2048) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] + character(len=2048), dimension(4) :: band = [character(len=2048) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] + character(len=2048), dimension(5) :: ring = [character(len=2048) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=2048), dimension(5) :: feature = [character(len=2048) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=2048), dimension(2) :: interstellar = [character(len=2048) :: 'R', 'ALPHA'] + character(len=2048), dimension(5) :: fan = [character(len=2048) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] + character(len=2048), dimension(4) :: comet = [character(len=2048) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] + character(len=2048), dimension(16) :: WrightCloudRing = [character(len=2048) :: 'p1', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p13', 'p14', 'p15', 'p16', 'p17', 'p18', 'p19'] + character(len=2048), dimension(6) :: WrightBand = [character(len=2048) :: 'q1', 'q5', 'q6', 'q7', 'q8', 'R_1'] + character(len=2048), dimension(6) :: comp_types = [character(len=2048) :: 'CLOUD', 'BAND', 'RING', 'FEATURE', 'WRIGHTCLOUDRING', 'WRIGHTBAND'] contains procedure :: get_labels @@ -72,11 +72,11 @@ module comm_param_mod integer(i4b) :: first_samp_resamp, last_samp_resamp, numsamp_per_resamp integer(i4b) :: verbosity, base_seed, base_seed_noise, numchain, num_smooth_scales integer(i4b) :: num_gibbs_iter, thinning, num_init_chains - character(len=512) :: chain_status, init_chain_prefix + character(len=2048) :: chain_status, init_chain_prefix real(dp) :: T_CMB - character(len=512) :: MJysr_convention - character(len=512) :: fft_magic_number_file - character(len=512) :: output_comps + character(len=2048) :: MJysr_convention + character(len=2048) :: fft_magic_number_file + character(len=2048) :: output_comps logical(lgt) :: only_pol, only_I logical(lgt) :: enable_TOD_analysis logical(lgt) :: enable_TOD_simulations !< start commander in simulation regime @@ -85,21 +85,21 @@ module comm_param_mod integer(i4b) :: output_4D_map_nth_iter, output_aux_maps logical(lgt) :: include_tod_zodi, sample_zodi, incl_zodi_solar_comp integer(i4b) :: zodi_solar_nside - character(len=512) :: zodi_solar_initmap, zodi_static_bands + character(len=2048) :: zodi_solar_initmap, zodi_static_bands real(dp), allocatable, dimension(:) :: fwhm_smooth real(dp), allocatable, dimension(:) :: fwhm_postproc_smooth integer(i4b), allocatable, dimension(:) :: lmax_smooth integer(i4b), allocatable, dimension(:) :: nside_smooth - character(len=512), allocatable, dimension(:) :: pixwin_smooth - character(len=512), allocatable, dimension(:) :: init_chain_prefixes - character(len=512) :: sims_output_dir !< simulations directory + character(len=2048), allocatable, dimension(:) :: pixwin_smooth + character(len=2048), allocatable, dimension(:) :: init_chain_prefixes + character(len=2048) :: sims_output_dir !< simulations directory ! alm-sampler integer(i4b) :: almsamp_nsamp, almsamp_nside_chisq_lowres, almsamp_prior_fwhm, almsamp_burnin logical(lgt) :: almsamp_optimize, almsamp_apply_prior, almsamp_pixreg, almsamp_priorsamp_frozen ! Output parameters - character(len=512) :: outdir + character(len=2048) :: outdir integer(i4b) :: nside_chisq, nmaps_chisq logical(lgt) :: pol_chisq, output_mixmat, output_residuals, output_chisq, output_cg_eigenvals integer(i4b) :: output_cg_freq @@ -107,70 +107,70 @@ module comm_param_mod logical(lgt) :: sample_signal_amplitudes, sample_specind, sample_powspec ! Numerical parameters - character(len=512) :: cg_conv_crit, cg_precond + character(len=2048) :: cg_conv_crit, cg_precond integer(i4b) :: cg_lmax_precond, cg_maxiter, cg_num_samp_groups, cg_num_user_samp_groups, cg_miniter, cg_check_conv_freq, cg_samp_group_md logical(lgt) :: cg_init_zero, set_noise_to_mean real(dp) :: cg_tol integer(i4b) :: num_bp_prop - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group_mask + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group_mask integer(i4b), dimension(MAXSAMPGROUP) :: cg_samp_group_maxiter - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group_bands + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group_bands ! Data parameters integer(i4b) :: numband - character(len=512) :: datadir, ds_sourcemask, ds_procmask + character(len=2048) :: datadir, ds_sourcemask, ds_procmask logical(lgt), allocatable, dimension(:) :: ds_active integer(i4b), allocatable, dimension(:) :: ds_period logical(lgt), allocatable, dimension(:) :: ds_polarization integer(i4b), allocatable, dimension(:) :: ds_nside integer(i4b), allocatable, dimension(:) :: ds_lmax - character(len=512), allocatable, dimension(:) :: ds_label - character(len=512), allocatable, dimension(:) :: ds_instlabel - character(len=512), allocatable, dimension(:) :: ds_unit - character(len=512), allocatable, dimension(:) :: ds_noise_format + character(len=2048), allocatable, dimension(:) :: ds_label + character(len=2048), allocatable, dimension(:) :: ds_instlabel + character(len=2048), allocatable, dimension(:) :: ds_unit + character(len=2048), allocatable, dimension(:) :: ds_noise_format integer(i4b), allocatable, dimension(:) :: ds_noise_lcut - character(len=512), allocatable, dimension(:) :: ds_mapfile - character(len=512), allocatable, dimension(:) :: ds_noisefile - character(len=512), allocatable, dimension(:) :: ds_regnoise - character(len=512), allocatable, dimension(:,:) :: ds_noise_rms_smooth + character(len=2048), allocatable, dimension(:) :: ds_mapfile + character(len=2048), allocatable, dimension(:) :: ds_noisefile + character(len=2048), allocatable, dimension(:) :: ds_regnoise + character(len=2048), allocatable, dimension(:,:) :: ds_noise_rms_smooth real(dp), allocatable, dimension(:) :: ds_noise_uni_fsky - character(len=512), allocatable, dimension(:) :: ds_maskfile - character(len=512), allocatable, dimension(:) :: ds_maskfile_calib - character(len=512), allocatable, dimension(:) :: ds_beamtype - character(len=512), allocatable, dimension(:) :: ds_blfile - character(len=512), allocatable, dimension(:) :: ds_btheta_file - character(len=512), allocatable, dimension(:) :: ds_pixwin + character(len=2048), allocatable, dimension(:) :: ds_maskfile + character(len=2048), allocatable, dimension(:) :: ds_maskfile_calib + character(len=2048), allocatable, dimension(:) :: ds_beamtype + character(len=2048), allocatable, dimension(:) :: ds_blfile + character(len=2048), allocatable, dimension(:) :: ds_btheta_file + character(len=2048), allocatable, dimension(:) :: ds_pixwin logical(lgt), allocatable, dimension(:) :: ds_samp_noiseamp - character(len=512), allocatable, dimension(:) :: ds_bptype - character(len=512), allocatable, dimension(:) :: ds_bpfile - character(len=512), allocatable, dimension(:) :: ds_bpmodel + character(len=2048), allocatable, dimension(:) :: ds_bptype + character(len=2048), allocatable, dimension(:) :: ds_bpfile + character(len=2048), allocatable, dimension(:) :: ds_bpmodel real(dp), allocatable, dimension(:) :: ds_nu_c logical(lgt), allocatable, dimension(:) :: ds_sample_gain real(dp), allocatable, dimension(:,:) :: ds_gain_prior - character(len=512), allocatable, dimension(:) :: ds_gain_calib_comp + character(len=2048), allocatable, dimension(:) :: ds_gain_calib_comp integer(i4b), allocatable, dimension(:) :: ds_gain_lmin integer(i4b), allocatable, dimension(:) :: ds_gain_lmax - character(len=512), allocatable, dimension(:) :: ds_gain_apodmask - character(len=512), allocatable, dimension(:) :: ds_gain_fwhm + character(len=2048), allocatable, dimension(:) :: ds_gain_apodmask + character(len=2048), allocatable, dimension(:) :: ds_gain_fwhm real(dp), allocatable, dimension(:,:) :: ds_defaults - character(len=512), allocatable, dimension(:) :: ds_component_sensitivity + character(len=2048), allocatable, dimension(:) :: ds_component_sensitivity real(dp), allocatable, dimension(:, :):: ds_zodi_emissivity, ds_zodi_albedo logical(lgt), allocatable, dimension(:) :: ds_zodi_reference_band !TOD data parameters - character(len=512), allocatable, dimension(:) :: ds_tod_type - character(len=512), allocatable, dimension(:) :: ds_tod_procmask1 - character(len=512), allocatable, dimension(:) :: ds_tod_procmask2 - character(len=512), allocatable, dimension(:) :: ds_tod_procmask_zodi - character(len=512), allocatable, dimension(:) :: ds_tod_filelist - character(len=512), allocatable, dimension(:) :: ds_tod_jumplist - character(len=512), allocatable, dimension(:) :: ds_tod_instfile - character(len=512), allocatable, dimension(:) :: ds_tod_dets - character(len=512), allocatable, dimension(:) :: ds_tod_bp_init - character(len=512), allocatable, dimension(:) :: ds_tod_initHDF - character(len=512), allocatable, dimension(:) :: ds_tod_level - character(len=512), allocatable, dimension(:) :: ds_tod_abscal + character(len=2048), allocatable, dimension(:) :: ds_tod_type + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask1 + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask2 + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask_zodi + character(len=2048), allocatable, dimension(:) :: ds_tod_filelist + character(len=2048), allocatable, dimension(:) :: ds_tod_jumplist + character(len=2048), allocatable, dimension(:) :: ds_tod_instfile + character(len=2048), allocatable, dimension(:) :: ds_tod_dets + character(len=2048), allocatable, dimension(:) :: ds_tod_bp_init + character(len=2048), allocatable, dimension(:) :: ds_tod_initHDF + character(len=2048), allocatable, dimension(:) :: ds_tod_level + character(len=2048), allocatable, dimension(:) :: ds_tod_abscal integer(i4b), allocatable, dimension(:,:) :: ds_tod_scanrange integer(i4b), allocatable, dimension(:) :: ds_tod_tot_numscan integer(i4b), allocatable, dimension(:) :: ds_tod_flag @@ -178,40 +178,40 @@ module comm_param_mod logical(lgt), allocatable, dimension(:) :: ds_tod_orb_abscal logical(lgt), allocatable, dimension(:) :: ds_tod_subtract_zodi integer(i4b), allocatable, dimension(:) :: ds_tod_freq - character(len=512), allocatable, dimension(:) :: ds_tod_solar_mask - character(len=512), allocatable, dimension(:) :: ds_tod_solar_model - character(len=512), allocatable, dimension(:) :: ds_tod_solar_init + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_mask + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_model + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_init ! Component parameters - character(len=512) :: cs_inst_parfile - character(len=512) :: cs_init_inst_hdf + character(len=2048) :: cs_inst_parfile + character(len=2048) :: cs_init_inst_hdf integer(i4b) :: cs_ncomp, cs_ncomp_tot, cs_local_burn_in logical(lgt) :: cs_output_localsamp_maps real(dp) :: cmb_dipole_prior(3) - character(len=512) :: cmb_dipole_prior_mask + character(len=2048) :: cmb_dipole_prior_mask logical(lgt), allocatable, dimension(:) :: cs_include - character(len=512), allocatable, dimension(:) :: cs_initHDF - character(len=512), allocatable, dimension(:) :: cs_label - character(len=512), allocatable, dimension(:) :: cs_type - character(len=512), allocatable, dimension(:) :: cs_class + character(len=2048), allocatable, dimension(:) :: cs_initHDF + character(len=2048), allocatable, dimension(:) :: cs_label + character(len=2048), allocatable, dimension(:) :: cs_type + character(len=2048), allocatable, dimension(:) :: cs_class logical(lgt), allocatable, dimension(:) :: cs_polarization real(dp), allocatable, dimension(:,:) :: cs_cg_scale integer(i4b), allocatable, dimension(:) :: cs_nside integer(i4b), allocatable, dimension(:,:) :: cs_poltype integer(i4b), allocatable, dimension(:) :: cs_cg_samp_group_maxiter - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_lnLtype - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_pixreg - character(len=512), allocatable, dimension(:,:) :: cs_spec_pixreg_map - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_fix_pixreg - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_pixreg_priors - character(len=512), allocatable, dimension(:,:) :: cs_spec_mask - character(len=512), allocatable, dimension(:,:) :: cs_spec_nprop - character(len=512), allocatable, dimension(:,:) :: cs_spec_proplen - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_mask - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_freeze - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_type - character(len=512), allocatable, dimension(:,:) :: cs_almsamp_init - character(len=512), allocatable, dimension(:,:) :: cs_pixreg_init_theta + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_lnLtype + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_pixreg + character(len=2048), allocatable, dimension(:,:) :: cs_spec_pixreg_map + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_fix_pixreg + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_pixreg_priors + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mask + character(len=2048), allocatable, dimension(:,:) :: cs_spec_nprop + character(len=2048), allocatable, dimension(:,:) :: cs_spec_proplen + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_mask + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_freeze + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_type + character(len=2048), allocatable, dimension(:,:) :: cs_almsamp_init + character(len=2048), allocatable, dimension(:,:) :: cs_pixreg_init_theta integer(i4b), allocatable, dimension(:,:,:) :: cs_spec_nprop_init real(dp), allocatable, dimension(:,:,:) :: cs_spec_proplen_init real(dp), allocatable, dimension(:,:) :: cs_spec_corr_limit @@ -229,40 +229,40 @@ module comm_param_mod integer(i4b), allocatable, dimension(:) :: cs_lmax_amp_prior integer(i4b), allocatable, dimension(:) :: cs_l_apod integer(i4b), allocatable, dimension(:) :: cs_lmax_ind - character(len=512), allocatable, dimension(:) :: cs_unit + character(len=2048), allocatable, dimension(:) :: cs_unit real(dp), allocatable, dimension(:,:) :: cs_nu_ref real(dp), allocatable, dimension(:) :: cs_nu_min, cs_nu_max - character(len=512), allocatable, dimension(:) :: cs_band_ref + character(len=2048), allocatable, dimension(:) :: cs_band_ref real(dp), allocatable, dimension(:) :: cs_fwhm - character(len=512), allocatable, dimension(:) :: cs_cltype - character(len=512), allocatable, dimension(:) :: cs_clfile - character(len=512), allocatable, dimension(:) :: cs_binfile + character(len=2048), allocatable, dimension(:) :: cs_cltype + character(len=2048), allocatable, dimension(:) :: cs_clfile + character(len=2048), allocatable, dimension(:) :: cs_binfile integer(i4b), allocatable, dimension(:) :: cs_lpivot - character(len=512), allocatable, dimension(:) :: cs_mask - character(len=512), allocatable, dimension(:) :: cs_mono_prior + character(len=2048), allocatable, dimension(:) :: cs_mask + character(len=2048), allocatable, dimension(:) :: cs_mono_prior real(dp), allocatable, dimension(:) :: cs_latmask - character(len=512), allocatable, dimension(:) :: cs_indmask - character(len=512), allocatable, dimension(:) :: cs_defmask + character(len=2048), allocatable, dimension(:) :: cs_indmask + character(len=2048), allocatable, dimension(:) :: cs_defmask real(dp), allocatable, dimension(:,:) :: cs_cl_prior real(dp), allocatable, dimension(:,:) :: cs_cl_amp_def real(dp), allocatable, dimension(:,:) :: cs_cl_beta_def real(dp), allocatable, dimension(:,:) :: cs_cl_theta_def integer(i4b), allocatable, dimension(:) :: cs_cl_poltype logical(lgt), allocatable, dimension(:) :: cs_output_EB - character(len=512), allocatable, dimension(:) :: cs_input_amp - character(len=512), allocatable, dimension(:) :: cs_prior_amp - character(len=512), allocatable, dimension(:,:) :: cs_input_ind - character(len=512), allocatable, dimension(:,:) :: cs_SED_template - character(len=512), allocatable, dimension(:) :: cs_MBBtab_type + character(len=2048), allocatable, dimension(:) :: cs_input_amp + character(len=2048), allocatable, dimension(:) :: cs_prior_amp + character(len=2048), allocatable, dimension(:,:) :: cs_input_ind + character(len=2048), allocatable, dimension(:,:) :: cs_SED_template + character(len=2048), allocatable, dimension(:) :: cs_MBBtab_type real(dp), allocatable, dimension(:) :: cs_SED_prior real(dp), allocatable, dimension(:,:) :: cs_theta_def real(dp), allocatable, dimension(:,:) :: cs_nu_break integer(i4b), allocatable, dimension(:,:) :: cs_smooth_scale real(dp), allocatable, dimension(:,:,:) :: cs_p_gauss real(dp), allocatable, dimension(:,:,:) :: cs_p_uni - character(len=512), allocatable, dimension(:) :: cs_catalog - character(len=512), allocatable, dimension(:) :: cs_init_catalog - character(len=512), allocatable, dimension(:) :: cs_ptsrc_template + character(len=2048), allocatable, dimension(:) :: cs_catalog + character(len=2048), allocatable, dimension(:) :: cs_init_catalog + character(len=2048), allocatable, dimension(:) :: cs_ptsrc_template real(dp), allocatable, dimension(:,:) :: cs_nu_min_beta real(dp), allocatable, dimension(:,:) :: cs_nu_max_beta logical(lgt), allocatable, dimension(:) :: cs_burn_in @@ -280,7 +280,7 @@ module comm_param_mod real(dp), allocatable, dimension(:) :: zs_nu_ref, zs_solar_irradiance ! (n_band) real(dp) :: zs_comp_params(MAXZODICOMPS, MAXZODIPARAMS, 4), zs_delta_t_reset, zs_general_params(MAXZODIPARAMS, 4), zs_r_min(MAXZODICOMPS), zs_r_max(MAXZODICOMPS), zs_randomize_rms real(dp) :: zs_tod_thin_factor, zs_tod_thin_threshold, zs_sol_elong(2) - character(len=128) :: zs_comp_labels(MAXZODICOMPS), zs_comp_types(MAXZODICOMPS), zs_init_hdf(MAXZODICOMPS), zs_sample_method, zs_init_ascii, zs_refband, zs_em_global, zs_al_global + character(len=2048) :: zs_comp_labels(MAXZODICOMPS), zs_comp_types(MAXZODICOMPS), zs_init_hdf(MAXZODICOMPS), zs_sample_method, zs_init_ascii, zs_refband, zs_em_global, zs_al_global character(len=2048) :: zs_wiring character(len=2048), allocatable :: zs_samp_groups(:), zs_samp_group_bands(:) logical(lgt) :: zs_output_comps, zs_output_ascii, zs_joint_mono, zs_output_tod_res @@ -291,9 +291,9 @@ module comm_param_mod integer(i4b) :: mcmc_num_user_samp_groups ! NUM_MCMC_SAMPLING_GROUPS integer(i4b) :: mcmc_num_samp_groups ! NUM_MCMC_SAMPLING_GROUPS character(len=2048), allocatable :: mcmc_samp_groups(:) ! MCMC_SAMPLING_GROUP_PARAMS, MCMC_SAMPLING_GROUP_CHISQ_BANDS - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_samp_group_mask - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_samp_group_bands - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_update_cg_groups ! MCMC_SAMPLING_GROUP_UPDATE_CG_GROUPS&& + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_samp_group_mask + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_samp_group_bands + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_update_cg_groups ! MCMC_SAMPLING_GROUP_UPDATE_CG_GROUPS&& ! Sample using specificed cg ! groups. If none, skip amplitude ! sampling @@ -313,8 +313,8 @@ subroutine read_comm_params(cpar) type(comm_params), intent(inout) :: cpar integer(i4b) :: paramfile_len, ierr, i, idx - character(len=512) :: paramfile, paramfile_name - character(len=512), allocatable, dimension(:) :: paramfile_cache + character(len=2048) :: paramfile, paramfile_name + character(len=2048), allocatable, dimension(:) :: paramfile_cache call getarg(1, paramfile) ! read parameter file once, save to ascii array @@ -325,7 +325,7 @@ subroutine read_comm_params(cpar) ! Read parameters into cache if (cpar%myid == cpar%root) then - paramfile_len = 512 + paramfile_len = 2048 allocate(paramfile_cache(paramfile_len)) call read_paramfile_to_ascii(paramfile,paramfile_cache,paramfile_len) end if @@ -334,7 +334,7 @@ subroutine read_comm_params(cpar) allocate(paramfile_cache(paramfile_len)) end if do i=1,paramfile_len - call mpi_bcast(paramfile_cache(i), 512, MPI_CHAR, cpar%root, MPI_COMM_WORLD, ierr) + call mpi_bcast(paramfile_cache(i), 2048, MPI_CHAR, cpar%root, MPI_COMM_WORLD, ierr) end do !Initialize a hash table call init_hash_tbl_sll(htable,tbl_len=10*paramfile_len) @@ -755,8 +755,8 @@ subroutine read_component_params_hash(htbl, cpar) integer(i4b) :: i, j, k, n, len_itext, idx real(dp) :: amp, lat, lon character(len=2) :: itext - character(len=512) :: maskfile, tokens(4) - character(len=512) :: pol_labels(3) + character(len=2048) :: maskfile, tokens(4) + character(len=2048) :: pol_labels(3) logical(lgt) :: bool_flag pol_labels(1)='INT' @@ -1005,11 +1005,11 @@ subroutine read_diffuse_gen_params_hash(htbl, cpar, itext, i, len_itext, bool_fl type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k, idx - character(len=512) :: maskfile + character(len=2048) :: maskfile call get_parameter_hashtable(htbl, 'COMP_POLARIZATION'//itext, len_itext=len_itext, par_lgt=cpar%cs_polarization(i)) @@ -1113,7 +1113,7 @@ subroutine read_cmb_params_hash(htbl, cpar) type(comm_params), intent(inout) :: cpar real(dp) :: amp, lat, lon - character(len=512) :: tokens(4) + character(len=2048) :: tokens(4) call get_parameter_hashtable(htbl, 'CMB_DIPOLE_PRIOR', par_string=cpar%cmb_dipole_prior_mask, path=.true.) if (trim(cpar%cmb_dipole_prior_mask) /= 'none') then @@ -1138,7 +1138,7 @@ subroutine read_power_law_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1265,7 +1265,7 @@ subroutine read_power_law_break_params_hash(htbl, cpar, itext, i, len_itext, boo type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1496,7 +1496,7 @@ subroutine read_curvature_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1716,7 +1716,7 @@ subroutine read_physdust_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1845,7 +1845,7 @@ subroutine read_spindust_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1969,7 +1969,7 @@ subroutine read_spindust2_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2188,7 +2188,7 @@ subroutine read_pah_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_ type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2205,7 +2205,7 @@ subroutine read_lognormal_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2426,7 +2426,7 @@ subroutine read_mbb_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_ type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2655,7 +2655,7 @@ subroutine read_freefree_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2795,7 +2795,7 @@ subroutine read_freefreeEM_params_hash(htbl, cpar, itext, i, len_itext, bool_fla type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2941,13 +2941,13 @@ subroutine read_zodi_params_hash(htbl, cpar) character(len=2) :: itext2 character(len=3) :: itext character(len=64), allocatable :: parameter_labels(:) - character(len=512), dimension(4) :: value_and_priors_str - character(len=512), dimension(20) :: zs_comp_lens_str + character(len=2048), dimension(4) :: value_and_priors_str + character(len=2048), dimension(20) :: zs_comp_lens_str real(dp), dimension(4) :: value_and_priors character(len=64) :: value_string logical(lgt) :: use_comp - character(len=512) :: temp_emissivity, temp_albedo - character(len=512), allocatable, dimension(:) :: samp_group_strings, emissivity_string, albedo_string + character(len=2048) :: temp_emissivity, temp_albedo + character(len=2048), allocatable, dimension(:) :: samp_group_strings, emissivity_string, albedo_string real(dp), parameter :: DEFAULT_PRIOR_LOWER_LIMIT = -1d300, DEFAULT_PRIOR_UPPER_LIMIT = 1d300 call get_parameter_hashtable(htbl, 'NUM_ZODI_COMPS', par_int=cpar%zs_ncomps) @@ -3076,7 +3076,7 @@ subroutine read_zodi_params_hash(htbl, cpar) subroutine parse_parameter(line, parname, found, par_int, par_char, par_string, par_sp, par_dp, par_lgt) implicit none character(len=*) :: line, parname - character(len=256) :: toks(2), key, value, par + character(len=2048) :: toks(2), key, value, par logical(lgt) :: found integer(i4b), optional :: par_int character(len=*), optional :: par_char @@ -3133,7 +3133,7 @@ subroutine get_parameter_arg(parname, par_int, par_char, & logical(lgt), optional :: par_present character(len=*), optional :: desc - character(len=512) :: line + character(len=2048) :: line integer(i4b) :: i logical(lgt) :: found do i = 1, command_argument_count() !iargc() @@ -3159,7 +3159,7 @@ end subroutine get_parameter_arg subroutine dump_expanded_paramfile(parfile, outfile) implicit none character(len=*) :: parfile, outfile - integer(i4b), parameter :: maxdepth = 256 + integer(i4b), parameter :: maxdepth = 2048 integer(i4b) :: depth, units(maxdepth), i, num, ounit, stat character(len=1024) :: key, value, arg, default_path @@ -3395,8 +3395,8 @@ subroutine tokenize(string, sep, ext, group, allow_empty) implicit none character(len=*) :: string, sep character(len=*), optional :: group - character(len=256) :: op, cl - integer(i4b), save :: level(256), nl + character(len=2048) :: op, cl + integer(i4b), save :: level(2048), nl integer(i4b), intent(inout) :: ext(2) logical(lgt), optional :: allow_empty @@ -3473,7 +3473,7 @@ subroutine validate_params(cpar) type(comm_params), intent(inout) :: cpar integer(i4b) :: i, j - character(len=512) :: chaindir + character(len=2048) :: chaindir character(len=2) :: itext, jtext logical(lgt) :: exist @@ -3680,17 +3680,17 @@ end subroutine validate_file subroutine read_paramfile_to_ascii(paramfile,paramfile_cache, paramfile_len) implicit none - character(len=512), intent(in) :: paramfile - character(len=512), allocatable, dimension(:), intent(inout) :: paramfile_cache + character(len=2048), intent(in) :: paramfile + character(len=2048), allocatable, dimension(:), intent(inout) :: paramfile_cache integer(i4b),intent(inout) :: paramfile_len - integer(i4b), parameter :: maxdepth = 256 + integer(i4b), parameter :: maxdepth = 2048 integer(i4b) :: depth, units(maxdepth), line_nr,i, stat, pos - character(len=512) :: key, value, filenames(maxdepth), line + character(len=2048) :: key, value, filenames(maxdepth), line character(len=1024) :: default_path character(len=3) :: band_num - character(len=512), allocatable, dimension(:) :: new_cache + character(len=2048), allocatable, dimension(:) :: new_cache ! read file to ascii array @@ -3868,10 +3868,10 @@ subroutine get_parameter_from_hash(htbl, parname, len_itext, par_int, par_char, logical(lgt), optional :: par_present character(len=*), optional :: desc logical(lgt), optional :: path - character(len=256) :: key + character(len=2048) :: key character(len=:), ALLOCATABLE :: itext,jtext CHARACTER(len=:), ALLOCATABLE :: val,val2,val3 - character(len=512) :: val4 + character(len=2048) :: val4 integer(i4b) :: i,j logical(lgt) :: loc_path @@ -3967,8 +3967,8 @@ end subroutine get_parameter_from_hash ! outputs the parameter file to the path provided subroutine save_ascii_parameter_file(outfile, ascii_table) implicit none - character(len=512), intent(in) :: outfile - character(len=512), dimension(:), intent(in) :: ascii_table + character(len=2048), intent(in) :: outfile + character(len=2048), dimension(:), intent(in) :: ascii_table integer(i4b) :: unit, i @@ -3990,10 +3990,10 @@ end subroutine save_ascii_parameter_file ! filling the hash table with elements from the parameter file (ascii array) subroutine put_ascii_into_hashtable(asciitbl,htbl) implicit none - character(len=512), allocatable, dimension(:), intent(in) :: asciitbl + character(len=2048), allocatable, dimension(:), intent(in) :: asciitbl type(hash_tbl_sll), intent(inout) :: htbl - character(len=512) :: key, val - character(len=256) :: toks(2) + character(len=2048) :: key, val + character(len=2048) :: toks(2) integer :: i, n do i = 1,size(asciitbl) call get_tokens(trim(asciitbl(i)), "=", group="''" // '""', maxnum=2, toks=toks, num=n) @@ -4016,11 +4016,11 @@ end subroutine put_ascii_into_hashtable subroutine get_chainfile_and_samp(string, chainfile, initsamp) implicit none character(len=*), intent(in) :: string - character(len=512), intent(out) :: chainfile + character(len=2048), intent(out) :: chainfile integer(i4b), intent(out) :: initsamp integer(i4b) :: i, num, e - character(len=512), dimension(2) :: toks + character(len=2048), dimension(2) :: toks call get_tokens(string, ":", toks, num) @@ -4101,8 +4101,8 @@ function get_labels(self, comp_type, add_common) result(labels) class(InterplanetaryDustParamLabels), intent(in) :: self character(len=*), intent(in) :: comp_type logical(lgt), intent(in), optional :: add_common - character(len=128), allocatable :: labels(:) - character(len=128) :: comp_type_upper + character(len=2048), allocatable :: labels(:) + character(len=2048) :: comp_type_upper comp_type_upper = comp_type call toupper(comp_type_upper) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 55c97b6bf..a45a01ed3 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -51,7 +51,7 @@ module comm_ptsrc_comp_mod type, extends (comm_comp) :: comm_ptsrc_comp character(len=512) :: outprefix real(dp) :: cg_scale, amp_rms_scale - integer(i4b) :: nside, nside_febecop, nsrc, ncr_tot, ndet, nactive + integer(i4b) :: nside, nside_febecop, nsrc, ndet, nactive logical(lgt) :: apply_pos_prior, burn_in, precomputed_amps, recompute_ptsrc_precond real(dp), allocatable, dimension(:,:) :: x ! Amplitudes (nsrc,nmaps) real(dp), allocatable, dimension(:,:) :: x_buff ! Amplitudes (nsrc,nmaps) @@ -82,13 +82,11 @@ module comm_ptsrc_comp_mod class(comm_ptsrc_comp), pointer :: p => null() end type ptsrc_ptr - integer(i4b) :: ncomp_pre = 0 - integer(i4b) :: npre = 0 - integer(i4b) :: nmaps_pre = -1 + integer(i4b), allocatable, dimension(:) :: npre, nmaps_pre integer(i4b) :: comm_pre = -1 integer(i4b) :: myid_pre = -1 integer(i4b) :: numprocs_pre = -1 - logical(lgt) :: apply_ptsrc_precond = .true. + logical(lgt) :: apply_ptsrc_precond = .false. character(len=24), private :: operation @@ -112,6 +110,7 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) call update_status(status, "init_ptsrc1") ! General parameters + apply_ptsrc_precond = .true. allocate(c) ! Initialize general parameters @@ -136,7 +135,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) c%comm = cpar%comm_chain c%numprocs = cpar%numprocs_chain c%init_from_HDF = cpar%cs_initHDF(id_abs) - ncomp_pre = ncomp_pre + 1 operation = cpar%operation c%apply_pos_prior = cpar%cs_apply_pos_prior(id_abs) c%burn_in = cpar%cs_burn_in(id_abs) @@ -252,19 +250,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) call report_error("Unknown point source model: " // trim(c%type)) end select - ! Read and allocate source structures - call update_status(status, "init_ptsrc2") - if( trim(c%type) == 'stars') then - ! stars uses an hdf catalogue instead of a txt file - call read_star_catalogue(c, cpar, id, id_abs) - else - call read_sources(c, cpar, id, id_abs) - end if - - ! Update mixing matrix - call update_status(status, "init_ptsrc3") - call c%updateMixmat - ! Set up CG sampling groups allocate(c%active_samp_group(cpar%cg_num_samp_groups)) c%active_samp_group = .false. @@ -281,6 +266,19 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) ! Disable CG search when asking for positivity prior if (c%apply_pos_prior) c%active_samp_group = .false. + + ! Read and allocate source structures + call update_status(status, "init_ptsrc2") + if( trim(c%type) == 'stars') then + ! stars uses an hdf catalogue instead of a txt file + call read_star_catalogue(c, cpar, id, id_abs) + else + call read_sources(c, cpar, id, id_abs) + end if + + ! Update mixing matrix + call update_status(status, "init_ptsrc3") + call c%updateMixmat call update_status(status, "init_ptsrc4") @@ -727,7 +725,12 @@ subroutine read_sources(self, cpar, id, id_abs) open(unit,file=trim(cpar%cs_catalog(id_abs)),recl=1024) self%nsrc = 0 self%ncr = 0 - self%ncr_tot = 0 + if (.not. allocated(npre)) then + allocate(npre(cpar%cg_num_samp_groups)) + allocate(nmaps_pre(cpar%cg_num_samp_groups)) + npre = 0 + nmaps_pre = 1 + end if do while (.true.) read(unit,'(a)',end=1) line line = trim(adjustl(line)) @@ -735,10 +738,13 @@ subroutine read_sources(self, cpar, id, id_abs) cycle else self%nsrc = self%nsrc + 1 - npre = npre + 1 - nmaps_pre = max(nmaps_pre, nmaps) - self%ncr_tot = self%ncr_tot + nmaps if (cpar%myid_chain == 0) self%ncr = self%ncr + nmaps + do i = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(i)) then + npre(i) = npre(i) + 1 + nmaps_pre(i) = max(nmaps_pre(i), nmaps) + end if + end do end if end do 1 close(unit) @@ -776,10 +782,12 @@ subroutine read_sources(self, cpar, id, id_abs) end if if (skip_src) then self%nsrc = self%nsrc-1 - npre = npre - 1 - nmaps_pre = max(nmaps_pre, nmaps) - self%ncr_tot = self%ncr_tot - nmaps if (cpar%myid_chain == 0) self%ncr = self%ncr - nmaps + do j = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(j)) then + npre(j) = npre(j) - 1 + end if + end do else i = i+1 allocate(self%src(i)%theta(self%npar,self%nmaps), self%src(i)%T(nactive)) @@ -1000,7 +1008,6 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) !store each pointsource in a source object self%ncr = 0 - self%ncr_tot = 0 ii = 0 do i=1, self%nsrc if (myid_pre == 0) then @@ -1032,10 +1039,13 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) end if allocate(self%src(ii)%amp_precomp(self%nactive)) - allocate(self%src(ii)%T(self%nactive)) - npre = npre + 1 - nmaps_pre = max(nmaps_pre, self%nmaps) - self%ncr_tot = self%ncr_tot + self%nmaps + allocate(self%src(ii)%T(self%nactive)) + do j = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(j)) then + npre(j) = npre(j) + 1 + nmaps_pre(j) = max(nmaps_pre(j), self%nmaps) + end if + end do if (cpar%myid_chain == 0) self%ncr = self%ncr + self%nmaps ! Normalize to first frequency @@ -1538,9 +1548,8 @@ subroutine initPtsrcPrecond(comm, samp_group) real(dp), allocatable, dimension(:,:) :: mat, mat2 type(ptsrc_ptr), dimension(5) :: pc - if (npre == 0) return - if (ncomp_pre == 0) return if (.not. apply_ptsrc_precond) return + if (npre(samp_group) == 0) return ! Make a list of active components, and check that at least one wants update nactive = 0 @@ -1564,10 +1573,10 @@ subroutine initPtsrcPrecond(comm, samp_group) ! Build frequency-dependent part of preconditioner call wall_time(t1) if (.not. allocated(P_cr(samp_group)%invM_src)) then - allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) + allocate(P_cr(samp_group)%invM_src(1,nmaps_pre(samp_group))) end if !allocate(mat(npre,npre), mat2(npre,npre)) - do j = 1, nmaps_pre + do j = 1, nmaps_pre(samp_group) ! Find number of matrix elements if (.not. associated(P_cr(samp_group)%invM_src(1,j)%M)) then @@ -1595,7 +1604,7 @@ subroutine initPtsrcPrecond(comm, samp_group) call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) if (myid_pre == 0) write(*,*) 'Number of matrix elements = ', n ! Allocate sparse matrix - P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre, n) + P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre(samp_group), n) end if if (P_cr(samp_group)%invM_src(1,j)%M%ni == 0) then @@ -1788,7 +1797,7 @@ subroutine initPtsrcPrecond(comm, samp_group) if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc i1 = i1+1 - call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.01d0, i1) + call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.0d0, i1) end do end do ! Invert matrix to finalize preconditioner @@ -1800,7 +1809,7 @@ subroutine initPtsrcPrecond(comm, samp_group) end do call wall_time(t2) if (myid_pre == 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) - + do i = 1, nactive pc(i)%p%recompute_ptsrc_precond = .false. end do @@ -1828,10 +1837,11 @@ subroutine applyPtsrcPrecond(x, samp_group) class(comm_comp), pointer :: c => null() class(comm_ptsrc_comp), pointer :: pt => null() - if (npre == 0 .or. myid_pre /= 0 .or. .not. apply_ptsrc_precond) return + if (.not. apply_ptsrc_precond) return + if (npre(samp_group) == 0 .or. myid_pre /= 0) return ! Reformat linear array into y(npre,nalm,nmaps) structure - allocate(y(npre,nmaps_pre)) + allocate(y(npre(samp_group),nmaps_pre(samp_group))) y = 0.d0 l = 1 c => compList @@ -1839,8 +1849,10 @@ subroutine applyPtsrcPrecond(x, samp_group) skip = .true. select type (c) class is (comm_ptsrc_comp) - pt => c - skip = .false. + if (c%active_samp_group(samp_group)) then + pt => c + skip = .false. + end if end select if (skip) then c => c%nextComp() @@ -1856,7 +1868,7 @@ subroutine applyPtsrcPrecond(x, samp_group) end do ! Multiply with preconditioner - do j = 1, nmaps_pre + do j = 1, nmaps_pre(samp_group) !y(:,j) = matmul(P_cr(samp_group)%invM_src(1,j)%M, y(:,j)) call P_cr(samp_group)%invM_src(1,j)%M%set_rhs(y(:,j)) call P_cr(samp_group)%invM_src(1,j)%M%solve(y(:,j)) @@ -1869,8 +1881,10 @@ subroutine applyPtsrcPrecond(x, samp_group) skip = .true. select type (c) class is (comm_ptsrc_comp) - pt => c - skip = .false. + if (c%active_samp_group(samp_group)) then + pt => c + skip = .false. + end if end select if (skip) then c => c%nextComp() @@ -2178,7 +2192,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) x(1) = self%x(k,p) if (self%apply_pos_prior .and. p == 1 .and. x(1) < 0.d0) x(1) = 0.d0 x(2:1+self%npar) = self%src(k)%theta(:,p) - call powell(x, lnL_ptsrc_multi, ierr) !!!!! + call powell(x, lnL_ptsrc_multi, ierr, tolerance=1d-5) !!!!! a = x(1) theta = x(2:1+self%npar) do l = 1, c_lnL%npar diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index 7c0f379b8..cce52df71 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -418,7 +418,7 @@ subroutine initialize_from_chain(cpar, handle, init_samp, init_from_output, firs integer(i4b) :: i, j, ext(2), initsamp, initsamp2 character(len=4) :: ctext character(len=6) :: itext, itext2 - character(len=512) :: chainfile, hdfpath + character(len=2048) :: chainfile, hdfpath class(comm_comp), pointer :: c => null() type(hdf_file) :: file, file2 class(comm_N), pointer :: N => null() diff --git a/commander3/src/comm_sparse_mod.f90 b/commander3/src/comm_sparse_mod.f90 index 9408a5e35..75ad94c4e 100644 --- a/commander3/src/comm_sparse_mod.f90 +++ b/commander3/src/comm_sparse_mod.f90 @@ -151,7 +151,7 @@ subroutine sparse_system_decomp(self) ! Symbolic factorization phase = 11 ! only reordering and symbolic factorization - self%iparm(33) = 1 ! compute determinant + self%iparm(33) = 1 ! compute determinant call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index b2426ccf6..17334ffaa 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -161,7 +161,7 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) !do i = 1, c%nscan ! c%scans(i)%d%baseline = 0.d0 !end do - + call timer%stop(TOD_INIT, id_abs) end function constructor_dirbe @@ -249,7 +249,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, type(map_ptr), dimension(1:,1:), intent(inout), optional :: map_gain ! (ndet,1) real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps, tod_start_idx, n_tod_tot, n_comps_to_fit - logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr + logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr, apply_dynamic_mask type(comm_binmap) :: binmap type(comm_scandata) :: sd character(len=4) :: ctext, myid_text @@ -261,7 +261,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, real(sp), allocatable, dimension(:) :: procmask, procmask2, procmask_zodi real(sp), allocatable, dimension(:,:,:) :: d_calib real(sp), allocatable, dimension(:,:,:,:) :: map_sky, m_gain - real(dp), allocatable, dimension(:,:) :: chisq_S, m_buf + real(dp), allocatable, dimension(:,:) :: chisq_S, m_buf, freqmap real(dp), allocatable, dimension(:, :) :: A_T_A, A_T_A_reduced real(dp), allocatable, dimension(:) :: AY, AY_reduced, X real(dp), allocatable, dimension(:, :, :) :: s_therm_tot, s_scat_tot ! (n_tod_tot, ncomps, ndet) @@ -284,7 +284,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, sample_abs_bandpass = .false. ! don't sample absolute bandpasses select_data = .false. !self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration - sample_gain = .true. ! Gain sampling, LB TOD sims have perfect gain + !sample_gain = .true. !iter > 1 ! Gain sampling, LB TOD sims have perfect gain !!$ if (trim(self%freq) == '01' .or. trim(self%freq) == '02' .or. & !!$ & trim(self%freq) == '03' .or. & !!$ & trim(self%freq) == '09' .or. trim(self%freq) == '10') then @@ -294,7 +294,18 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, else sample_ncorr = .false. end if - + + if (trim(self%freq(1:2)) == '05' .or. trim(self%freq(1:2)) == '06' .or. & + & trim(self%freq(1:2)) == '07' .or. trim(self%freq(1:2)) == '08' .or. & + & trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then + sample_gain = .true. + apply_dynamic_mask = .true. + else + sample_gain = .false. + apply_dynamic_mask = .false. + end if + !sample_gain = .false. + ! Initialize local variables ndelta = size(delta,3) self%n_bp_prop = ndelta-1 @@ -347,13 +358,13 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, !------------------------------------ ! Sample gain components in separate TOD loops; marginal with respect to n_corr - if (iter > 1 .and. sample_gain) then + if (sample_gain) then ! 'abscal': the global constant gain factor !call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2) ! 'relcal': the gain factor that is constant in time but varying between detectors ! call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) ! 'deltaG': the time-variable and detector-variable gain - call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask2, procmask2, smooth=.true.) + call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask2, procmask2, smooth=.true., mask_threshold=0.1d0) end if ! Prepare intermediate data structures @@ -377,10 +388,11 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) ! Create dynamic mask - if (self%first_call) then + if (self%first_call .and. apply_dynamic_mask) then do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle - call self%create_dynamic_mask(i, j, sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j), [-10.,10.], sd%mask(:,j)) + call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & + & [-5.,5.], sd%mask(:,j), sd%flag(:,j)) end do call sd%dealloc if (.not. any(self%scans(i)%d%accept)) cycle @@ -410,7 +422,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Compute chisquare for bandpass fit if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) - + ! Compute binned map allocate(d_calib(self%output_n_maps, sd%ntod, sd%ndet)) d_calib = 0.d0 @@ -418,7 +430,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call compute_calibrated_data(self, i, sd, d_calib) ! For debugging: write TOD to hdf - if (.true.) then + if (.false.) then ! scan id appears to be the worst chi2 if (self%scanid(i) < 10000) then !print *, self%scanid(i) @@ -448,6 +460,10 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) +!!$ do j = 1, binmap%nobs +!!$ if (binmap%A_map(1,j) > 0.) write(*,*) j, real(binmap%b_map(1,1,j),sp), real(binmap%A_map(1,j),sp), real(binmap%b_map(1,1,j)/binmap%A_map(1,j),sp) +!!$ end do + ! Update scan list call wall_time(t2) self%scans(i)%proctime = self%scans(i)%proctime + t2-t1 diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index c51535ffc..690d34993 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -647,7 +647,7 @@ end subroutine dealloc_scan_data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, procmask2, & - & polang, smooth) + & polang, smooth, mask_threshold) ! ! Sample calibration modes ! Supported modes = {abscal, relcal, deltaG, imbal} @@ -677,8 +677,10 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr real(sp), dimension(0:), intent(in) :: procmask, procmask2 real(dp), intent(in), optional :: polang logical(lgt), intent(in), optional :: smooth + real(dp), intent(in), optional :: mask_threshold integer(i4b) :: i, j, ext(2), ierr, timer_id + real(sp) :: threshold real(dp) :: t1, t2 real(dp), allocatable, dimension(:) :: A, b real(sp), allocatable, dimension(:,:) :: s_invsqrtN, mask_lowres, s_buf @@ -688,6 +690,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr smooth_ = .true. + threshold = 0.9; if (present(mask_threshold)) threshold=mask_threshold if (present(smooth)) smooth_=smooth if (tod%myid == 0) write(*,*) '| --> Sampling calibration, mode = ', trim(mode) @@ -739,7 +742,8 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr allocate(mask_lowres(ext(1):ext(2), tod%ndet)) do j = 1, tod%ndet if (.not. tod%scans(i)%d(j)%accept) cycle - call tod%downsample_tod(sd%mask(:,j), ext, mask_lowres(:,j), threshold=0.9) + call tod%downsample_tod(sd%mask(:,j), ext, mask_lowres(:,j), threshold=threshold) + !if (size(sd%mask(:,j)) > 0) write(*,*) "fsky", sum(sd%mask(:,j))/size(sd%mask(:,j)), sum(mask_lowres(:,j))/size(mask_lowres(:,j)) if (trim(mode) == 'abscal') then if (trim(tod%abscal_comps) == 'orbital') then call tod%downsample_tod(sd%s_orb(:,j), ext, s_invsqrtN(:,j)) diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index ee5ba80d2..56da6dbf1 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -100,13 +100,15 @@ module subroutine calculate_gain_mean_std_per_scan(tod, scan_id, s_invsqrtN, mas tod%scans(scan_id)%d(j)%gain = 0.d0 tod%scans(scan_id)%d(j)%dgain = 0.d0 else - if (present(mask_lowres)) then - tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j) * mask_lowres(:,j)) - tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2 * mask_lowres(:,j)) - else - tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j)) - tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2) - end if +!!$ if (present(mask_lowres)) then +!!$ tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j) * mask_lowres(:,j)) +!!$ tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2 * mask_lowres(:,j)) +!!$ else +!!$ tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j)) +!!$ tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2) +!!$ end if + tod%scans(scan_id)%d(j)%dgain = sum(r_fill(:) * s_tot(:,j) * mask(:,j)) / tod%scans(scan_id)%d(j)%N_psd%sigma0**2 + tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_tot(:,j) * s_tot(:,j) * mask(:,j)) / tod%scans(scan_id)%d(j)%N_psd%sigma0**2 if (tod%scans(scan_id)%d(j)%gain_invsigma < 0.d0) then write(*,*) 'Warning: Not positive definite invN = ', tod%scanid(scan_id), j, tod%scans(scan_id)%d(j)%gain_invsigma end if @@ -126,23 +128,28 @@ module subroutine calculate_gain_mean_std_per_scan(tod, scan_id, s_invsqrtN, mas if (.false.) then call int2string(tod%scanid(scan_id), itext) !write(*,*) 'gain'//itext//' = ', tod%gain0(0) + tod%gain0(1), tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(1)%gain_invsigma - open(58,file='gain_delta_'//itext//'.dat') - do i = ext(1), ext(2) - write(58,*) i, residual(i,1) - end do - write(58,*) - write(58,*) - do i = 1, size(s_invsqrtN,1) - write(58,*) i, s_invsqrtN(i,1) - end do - write(58,*) - do i = 1, size(s_tot,1) - write(58,*) i, tod_arr(i, 1) - (tod%gain0(0) + tod%gain0(1)) * s_tot(i,1) - end do - write(58,*) - do i = 1, size(s_tot,1) - write(58,*) i, tod_arr(i, 1) + open(58,file='gain_delta_'//itext//'.dat', recl=1024) + write(58,*) "#", tod%scans(scan_id)%ntod, size(tod_arr), tod%gain0(0), tod%gain0(1), tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(1)%gain_invsigma + do i = 1, size(tod_arr) + write(58,*) i, r_fill(i), tod_arr(i,1), s_tot(i,1), mask(i,1) end do + +!!$ do i = ext(1), ext(2) +!!$ write(58,*) i, residual(i,1) +!!$ end do +!!$ write(58,*) +!!$ write(58,*) +!!$ do i = 1, size(s_invsqrtN,1) +!!$ write(58,*) i, s_invsqrtN(i,1) +!!$ end do +!!$ write(58,*) +!!$ do i = 1, size(s_tot,1) +!!$ write(58,*) i, tod_arr(i, 1) - (tod%gain0(0) + tod%gain0(1)) * s_tot(i,1) +!!$ end do +!!$ write(58,*) +!!$ do i = 1, size(s_tot,1) +!!$ write(58,*) i, tod_arr(i, 1) +!!$ end do close(58) end if @@ -255,14 +262,14 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) tod%gain_alpha(j) = -1.d0 ! Physically motivated value tod%gain_fknee(j) = tod%gain_samprate ! makes sigma_0 = true standard devation per sample - !if (j == 1) then - ! open(58,file='gain_in.dat') - ! do k = 1, size(g,1) - ! if (g(k,j,2) > 0) then - ! write(58,*) k, g(k,j,1)/g(k,j,2), 1/sqrt(g(k,j,2)) - ! end if - ! end do - ! close(58) + if (j == 1) then +!!$ open(58,file='gain_in.dat') +!!$ do k = 1, size(g,1) +!!$ if (g(k,j,2) > 0) then +!!$ write(58,*) k, g(k,j,1)/g(k,j,2), 1/sqrt(g(k,j,2)) +!!$ end if +!!$ end do +!!$ close(58) !write(*,*) '| psd = ', tod%gain_sigma_0(j), tod%gain_alpha(j), tod%gain_fknee(j) ! open(68,file='g.unf', form='unformatted') @@ -273,7 +280,7 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) ! write(68) tod%gain_alpha(j) ! write(68) tod%gain_fknee(j) ! close(68) - !end if + end if sample_per_jump = .false. .and. (size(tod%jumplist(j, :)) > 2) if (sample_per_jump) then @@ -288,11 +295,12 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) call wiener_filtered_gain(g(tod%jumplist(j, k):, j, 1), g(tod%jumplist(j, k):, j, 2), & & tod%gain_samprate, tod%gain_sigma_0(j), tod%gain_alpha(j), tod%gain_fknee(j), trim(tod%operation)=='sample', handle) else - call wiener_filtered_gain(g(:, j, 1), g(:, j, 2), tod%gain_samprate, tod%gain_sigma_0(j), tod%gain_alpha(j), & + call wiener_filtered_gain(g(:, j, 1), g(:, j, 2), tod%gain_samprate, 1000*tod%gain_sigma_0(j), tod%gain_alpha(j), & & tod%gain_fknee(j), trim(tod%operation)=='sample', handle) end if - ! Force flat average to zero + ! Force flat average to zero + !write(*,*) 'disabling gain mean subtraction' mu = 0.d0 denom = 0.d0 do k = 1, nscan_tot @@ -307,15 +315,15 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) g(:,j,1) = g(:,j,1) - mu end where - !if (j == 1) then - ! open(58,file='gain_out.dat') - ! do k = 1, size(g,1) - ! if (g(k,j,2) > 0) then - ! write(58,*) k, g(k,j,1), 1/sqrt(g(k,j,2)) - ! end if - ! end do - ! close(58) - !end if + if (j == 1) then +!!$ open(58,file='gain_out.dat') +!!$ do k = 1, size(g,1) +!!$ if (g(k,j,2) > 0) then +!!$ write(58,*) k, g(k,j,1), 1/sqrt(g(k,j,2)) +!!$ end if +!!$ end do +!!$ close(58) + end if end do !!$ call mpi_finalize(ierr) !!$ stop diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index 7b9e5b1eb..1755b5d49 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -65,7 +65,7 @@ module function constructor_lfi(handle, cpar, id, id_abs, info, tod_type) result logical(lgt) :: pol_beam character(len=50) :: name character(len=6) :: itext - character(len=512) :: chainfile, path + character(len=2048) :: chainfile, path type(hdf_file) :: init_file real(dp), dimension(:), allocatable :: nus diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index f3bb8a399..9d97b9d3c 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -385,6 +385,7 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%sample_abs_bp = .false. self%zodiband = -1 self%sol_elong_range = [0., 180.] + self%sample_mono = .false. if (cpar%include_tod_zodi) then self%subtract_zodi = cpar%ds_tod_subtract_zodi(self%band) @@ -2939,7 +2940,312 @@ subroutine clear_zodi_cache(self, obs_time) end if end subroutine clear_zodi_cache - subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) + subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) + implicit none + class(comm_tod), intent(inout) :: self + integer(i4b), intent(in) :: scan, det + real(sp), dimension(:), intent(in) :: res + real(sp), dimension(2), intent(in) :: rms_range + real(sp), dimension(:), intent(inout) :: mask + integer(i4b), dimension(:), intent(inout) :: flag + + integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut + real(dp) :: rms0 + real(sp) :: var0, threshold, gain + logical(lgt), allocatable, dimension(:) :: cut + integer(i4b), allocatable, dimension(:,:) :: bad, buffer + real(sp), allocatable, dimension(:) :: mask_dyn, var_window + + if (sum(mask) == 0) return + + ntod = size(res) + ntot = count(iand(flag,self%flag0) .eq. 0) + nmax = 1000 + gain = self%scans(scan)%d(det)%gain + + ! Generate dynamic mask + allocate(mask_dyn(ntod)) + mask_dyn = 1.0 + + ! Solar-centric mask + ncut = 0 + if (allocated(self%mask_solar) .and. self%use_solar_point) then + do i = 1, ntod + if (mask(i) == 0.) cycle + if (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut+1 + end if + end do + end if + + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + +!!$ open(58, file='var0.dat') +!!$ do i = 1, ntod +!!$ if (mask(i) == 1.) write(58,*) i, res(i) +!!$ end do +!!$ close(58) + + ! Extreme outliers + threshold = 20. ! White noise sigma + ncut = 0 + do i = 1, ntod + if (mask(i) == 1. .and. abs(res(i)) > threshold) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms + allocate(cut(ntod)) + ncut = 0 +! open(58, file='var1.dat') + do iter = 1, 1 + ! Compute full-scan, masked rms0 + rms0 = 0.d0 + n = 0 + do i = 1, ntod + if (mask(i) == 1.) then + rms0 = rms0 + res(i)**2 + n = n + 1 + end if + end do + rms0 = sqrt(rms0/(n-1)) + !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 + + do i = 1, ntod + cut(i) = (mask(i) == 1. .and. (res(i) < rms_range(1)*rms0 .or. res(i) > rms_range(2)*rms0)) + !if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) + end do + + ! Apply RMS selection criterium + if (cut(1) .and. (.not. cut(2) .or. mask(2) == 0.)) then + mask_dyn(1) = 0. + mask(1) = 0. + flag(1) = huge(flag(1)) + ncut = ncut + 1 + end if + do i = 2, ntod-1 + if (cut(i) .and. (.not. cut(i-1) .or. mask(i-1) == 0.) .and. (.not. cut(i+1) .or. mask(i+1) == 0.)) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + if (cut(ntod) .and. (.not. cut(ntod-1) .or. mask(ntod-1) == 0.)) then + mask_dyn(ntod) = 0. + mask(ntod) = 0. + flag(ntod) = huge(flag(ntod)) + ncut = ncut + 1 + end if + end do + !close(58) + deallocate(cut) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically cosmic rays and other short glitches + allocate(var_window(ntod)) + window = 5; threshold = 3. + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + var0 = sqrt(var0) + ncut = 0 + !open(58, file='var2.dat') + do i = 1, ntod + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + !if (mask(k) == 1) then + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + !close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. + window = 50; threshold = 2.0 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 + !open(58, file='var3.dat') + do i = 1, ntod + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + !close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. + window = 500; threshold = 1.5 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 +! open(58, file='var3.dat') + do i = 1, ntod +! if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do +! close(58) + deallocate(var_window) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove isolated samples + ncut = 0 + if (mask(1) == 1. .and. mask(2) == 0.) then + mask_dyn(1) = 0. + mask(1) = 0. + flag(1) = huge(flag(1)) + ncut = ncut + 1 + end if + do i = 2, ntod-1 + if (mask(i-1) == 0. .and. mask(i) == 1. .and. mask(i+1) == 0.) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + if (mask(ntod) == 1. .and. mask(ntod-1) == 0.) then + mask_dyn(ntod) = 0. + mask(ntod) = 0. + flag(ntod) = huge(flag(ntod)) + ncut = ncut + 1 + end if +! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove consecutive chunks with many flagged samples + window = 2000; threshold = 0.30 + ncut = 0 +! open(58, file='var4.dat') + do i = 1, ntod +! write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 + j = max(i-window,1) + k = min(i+window,ntod) + if (count(flag(j:k) == huge(flag(1)))/real(k-j+1,sp) > threshold) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do +! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove glitches in the high signal-to-noise regime + ! Must 1) be a masked pixel; 2) not already be flagged; 3) have a S/N > 10; 4) have a residual larger than some threshold times the expected signal +!!$ threshold = 0.50 +!!$ ncut = 0 +!!$ do i = 1, ntod +!!$ +!!$ if (mask(i) == 0. .and. iand(flag(i),self%flag0) .eq. 0 .and. abs(gain*s_sky(i)) > 10.d0 * self%scans(scan)%d(det)%N_psd%sigma0 .and. abs(res(i)) > threshold*abs(gain*s_sky(i))) then +!!$ mask_dyn(i) = 0. +!!$ mask(i) = 0. +!!$ flag(i) = huge(flag(i)) +!!$ ncut = ncut + 1 +!!$ end if +!!$ end do +!!$ write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, high S/N -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + + !mask_dyn(1:330000) = 0. + !mask(1:330000) = 0. + !mask_dyn(1:550000) = 0. + !mask(1:550000) = 0. + !mask_dyn(575000:) = 0. + !mask(575000:) = 0. + !flag(1:550000) = huge(flag(1)) + !flag(575000:) = huge(flag(1)) + +!!$ open(58, file='var5.dat') +!!$ do i = 1, ntod +!!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) +!!$ end do +!!$ close(58) + + ! Compress and store dynamic mask + allocate(bad(2,nmax)) + bad = -1 + n = 0 + do i = 1, ntod + if (mask_dyn(i) == 0.) then + ! Start new range if not already active + if (bad(1,n+1) == -1) bad(1,n+1) = i + else + ! Close active range + if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then + bad(2,n+1) = i-1 + n = n+1 + end if + end if + + ! Increase array size if needed + if (n == nmax) then + nmax = 2*nmax + allocate(buffer(2,nmax)) + buffer = -1 + buffer(:,1:nmax/2) = bad + deallocate(bad) + allocate(bad(2,nmax)) + bad = buffer + deallocate(buffer) + end if + end do + + ! Close open range if needed at the end + if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then + bad(2,n+1) = ntod + n = n+1 + end if + + ! Store final array + if (n > 0) then + allocate(self%scans(scan)%d(det)%mask_dyn(2,n)) + self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(mask_dyn == 0),sp) / ntot, count(mask_dyn==0), ntot + end if + + deallocate(bad, mask_dyn) + end subroutine create_dynamic_mask + + subroutine create_dynamic_mask2(self, scan, det, res, rms_range, mask) implicit none class(comm_tod), intent(inout) :: self integer(i4b), intent(in) :: scan, det @@ -3043,6 +3349,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) ! if (allocated(mask_solar)) deallocate(mask_solar) end subroutine + subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) implicit none class(comm_tod), intent(in) :: tod diff --git a/commander3/src/comm_zodi_comp_mod.f90 b/commander3/src/comm_zodi_comp_mod.f90 index 3131d3c0f..a1f042174 100644 --- a/commander3/src/comm_zodi_comp_mod.f90 +++ b/commander3/src/comm_zodi_comp_mod.f90 @@ -231,7 +231,8 @@ subroutine init_cloud_priors_and_scales(self, start_ind, prior, scale) scale(start_ind+1,:) = [1.d0, 0.03d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega scale(start_ind+2,:) = [1.d0, 0.3d0] - prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 + !prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 + prior(:,start_ind+3) = [-0.04d0, 0.04d0, 0.d0, -1.d0] ! ! X_0 scale(start_ind+3,:) = [1.d0, 1d-3] prior(:,start_ind+4) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Y_0 scale(start_ind+4,:) = [1.d0, 0.8d-3] @@ -273,9 +274,11 @@ subroutine init_band_priors_and_scales(self, start_ind, prior, scale) scale(start_ind+6,:) = [1.d0, 0.14d0] prior(:,start_ind+7) = [0.8d0, 5.4d0, 4.14d0, -1.d0] ! delta_r scale(start_ind+7,:) = [1.d0, 0.005d0] - prior(:,start_ind+8) = [0.01d0, 1.5d0, 0.942d0, -1.d0] ! v + !prior(:,start_ind+8) = [0.01d0, 1.5d0, 0.942d0, -1.d0] ! v + prior(:,start_ind+8) = [0.01d0, 3.d0, 0.942d0, -1.d0] ! v scale(start_ind+8,:) = [1.d0, 0.1d0] - prior(:,start_ind+9) = [3.99999d0, 4.000001d0, 0.189d0, -1.d0] ! p + !prior(:,start_ind+9) = [3.99999d0, 4.000001d0, 0.189d0, -1.d0] ! p + prior(:,start_ind+9) = [2.d0, 6.d0, 0.189d0, -1.d0] ! p scale(start_ind+9,:) = [1.d0, 1d-6] end subroutine init_band_priors_and_scales diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index cab608ded..6288d19c4 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -755,7 +755,7 @@ subroutine comp_from_chain(self, cpar, params, comp_idx) type(hdf_file) :: file character(len=32), allocatable :: param_labels(:) - character(len=512) :: chainfile, group_name + character(len=2048) :: chainfile, group_name if (cpar%myid == cpar%root) then if (trim(cpar%zs_init_hdf(comp_idx)) == 'default') then @@ -939,7 +939,7 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) integer(i4b), dimension(:), intent(inout) :: stat integer(i4b) :: i, c, j, k, first, last, n_params, n, m, ind, em_global, al_global, c_to, c_from, band - character(len=128) :: tokens(100), comp_param(2), wire_from(2), wire_to(2), label, param_label_tokens(10), em_from(2), em_to(2) + character(len=128) :: tokens(100), comp_param(2), wire_from(2), wire_to(2), label, param_label_tokens(10), em_from(2), em_to(2), al_from(2), al_to(2) character(len=2048) :: str ! Default: Fix everything at input @@ -1100,6 +1100,26 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) c_to = zodi_model%get_par_ind(comp_str=wire_to(1), em_string=em_to(2)) stat(c_from) = c_to end if + else if (trim(wire_from(2)(1:2)) == 'al') then + call get_tokens(wire_from(2), '@', al_from, num=n) + call get_tokens(wire_to(2), '@', al_to, num=n) + if (n == 1) then + ! Attach all bands + do c = 1, numband + if (.not. active(c)) cycle + c_from = zodi_model%get_par_ind(comp_str=wire_from(1), al_band=c) + c_to = zodi_model%get_par_ind(comp_str=wire_to(1), al_band=c) + stat(c_from) = c_to + end do + else + ! Attach specified band + j = get_string_index(band_labels, al_from(2)) + k = get_string_index(band_labels, al_to(2)) + if (.not. active(j) .or. .not. active(k)) cycle + c_from = zodi_model%get_par_ind(comp_str=wire_from(1), al_string=al_from(2)) + c_to = zodi_model%get_par_ind(comp_str=wire_to(1), al_string=al_to(2)) + stat(c_from) = c_to + end if else write(*,*) 'Unsupported zodi wire = ', trim(tokens(i)) stop @@ -1635,7 +1655,7 @@ subroutine read_tod_zodi_params(cpar, model, tod) type(hdf_file) :: file real(dp) :: lambda, lambda_min, lambda_max real(dp), allocatable :: emissivity(:), albedo(:) - character(len=512) :: chainfile, emissivity_path, albedo_path, band_path, comp_path, tod_path, group_name + character(len=2048) :: chainfile, emissivity_path, albedo_path, band_path, comp_path, tod_path, group_name !allocate(tod%zodi_emissivity(tod%zodi_n_comps)) !allocate(tod%zodi_albedo(tod%zodi_n_comps)) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 2e869dc83..73c75ae9f 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -737,7 +737,7 @@ subroutine downsamp_invariant_structs(cpar) tod = data(i)%tod%scans(scan)%d(j)%tod end if call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static, pix_static=data(i)%tod%scans(scan)%d(j)%pix_sol) - tod = tod - s_static + tod = tod - data(i)%tod%scans(scan)%d(j)%gain * s_static do k = 1, data(i)%tod%scans(scan)%ntod mask(k) = procmask_zodi(pix(k, 1)) @@ -1068,7 +1068,7 @@ subroutine create_zodi_glitch_mask(cpar, handle) if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle ! Search for strong outliers - res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%downsamp_sky - data(i)%tod%scans(scan)%d(j)%downsamp_zodi + res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%gain * (data(i)%tod%scans(scan)%d(j)%downsamp_sky + data(i)%tod%scans(scan)%d(j)%downsamp_zodi) rms = sqrt(mean(real(res**2, dp))) data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask = abs(res) > 10. * real(rms, sp) frac = count(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask)/real(size(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask),dp) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 233f02c8f..00ec09ad5 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -382,7 +382,9 @@ program commander end select ! Sample stationary zodi components with 2D model - call sample_static_zodi_map(cpar, handle) + if (.false.) then + call sample_static_zodi_map(cpar, handle) + end if !call sample_static_zodi_amps(cpar, handle) !!$ if (mod(iter-2,10) == 0) then diff --git a/commander3/src/math_tools.f90 b/commander3/src/math_tools.f90 index d3ea49023..10d3ab4e7 100644 --- a/commander3/src/math_tools.f90 +++ b/commander3/src/math_tools.f90 @@ -33,6 +33,10 @@ module math_tools interface convert_fract2sigma module procedure convert_fract2sigma_sp, convert_fract2sigma_dp + end interface convert_fract2sigma + + interface compute_running_variance + module procedure compute_running_variance_sp, compute_running_variance_dp end interface contains @@ -1695,5 +1699,166 @@ function calc_linear_regression(x_arr, y_arr, n_lim) end function calc_linear_regression + subroutine compute_running_variance_sp(x, mask, window, variance, var_mean) + implicit none + real(sp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(sp), dimension(:), intent(out) :: variance + real(sp), intent(out), optional :: var_mean + + integer(i4b) :: i, j, k, l, n, m + real(sp) :: mu + !integer(i4b), allocatable, dimension(:) :: m + + n = size(x) + + do i = 1, n + j = max(i-window,1) + k = min(i+window,n) + variance(i) = 0. + mu = 0. + m = 0 + do l = j, k + if (mask(l) == 1.) then + mu = mu + x(l) + m = m + 1 + end if + end do + if (m < 3) then + variance(i) = 0. + else + mu = mu / m + do l = j, k + if (mask(l) == 1.) then + variance(i) = variance(i) + (x(l) - mu)**2 + end if + end do + variance(i) = variance(i) / (m-1) + end if + end do + +!!$ allocate(m(n)) +!!$ variance(1) = 0.d0 +!!$ m = 0 +!!$ do j = 1, window +!!$ if (mask(j) == 1.d0) then +!!$ variance(1) = variance(1) + x(j)**2 +!!$ m(1) = m(1) + 1 +!!$ end if +!!$ end do +!!$ +!!$ ! Compute running mean variance +!!$ do i = 2, n +!!$ variance(i) = variance(i-1) +!!$ m(i) = m(i-1) +!!$ k = i-window +!!$ if (k > 0) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) - x(k)**2 +!!$ m(i) = m(i) - 1 +!!$ end if +!!$ end if +!!$ k = i+window +!!$ if (k <= n) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) + x(k)**2 +!!$ m(i) = m(i) + 1 +!!$ end if +!!$ end if +!!$ end do +!!$ do i = 1, n +!!$ if (m(i) > 2) then +!!$ variance(i) = variance(i) / (m(i) - 1.d0) +!!$ else +!!$ variance(i) = 0.d0 +!!$ end if +!!$ end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0 .and. variance(i) > 0.) then + var_mean = var_mean + variance(i) + j = j+1 + !write(*,*) i, var_mean, j, var_mean/j + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + !deallocate(m) + + end subroutine compute_running_variance_sp + + + + subroutine compute_running_variance_dp(x, mask, window, variance, var_mean) + implicit none + real(dp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(dp), dimension(:), intent(out) :: variance + real(dp), intent(out), optional :: var_mean + + integer(i4b) :: i, j, k, n + integer(i4b), allocatable, dimension(:) :: m + + n = size(x) + + allocate(m(n)) + variance(1) = 0.d0 + m = 0 + do j = 1, window + if (mask(j) == 1.d0) then + variance(1) = variance(1) + x(j)**2 + m(1) = m(1) + 1 + end if + end do + + ! Compute running mean variance + do i = 2, n + variance(i) = variance(i-1) + m(i) = m(i-1) + k = i-window + if (k > 0) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) - x(k)**2 + m(i) = m(i) - 1 + end if + end if + k = i+window + if (k <= n) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) + x(k)**2 + m(i) = m(i) + 1 + end if + end if + end do + do i = 1, n + if (m(i) > 2) then + variance(i) = variance(i) / (m(i) - 1.d0) + else + variance(i) = 0.d0 + end if + end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0) then + var_mean = var_mean + variance(i) + j = j+1 + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + deallocate(m) + + end subroutine compute_running_variance_dp + end module math_tools From 77985eab13d74082c9c7e53e029f9fb22d19b424 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sun, 16 Feb 2025 19:40:39 +0100 Subject: [PATCH 107/171] Enabled gain sampling for DIRBE; note that this breaks other experiments at the moment; need to implement proper Gaussian noise module. :Improved TOD masking; extended parameter field length from 256 to 2048 characters --- .../components/dust/dust_stars_n512.defaults | 2 +- commander3/src/comm_output_mod.f90 | 3 +- commander3/src/comm_param_mod.f90 | 298 ++++++++--------- commander3/src/comm_ptsrc_comp_mod.f90 | 106 +++--- commander3/src/comm_signal_mod.f90 | 2 +- commander3/src/comm_sparse_mod.f90 | 2 +- commander3/src/comm_tod_dirbe_mod.f90 | 38 ++- commander3/src/comm_tod_driver_mod.f90 | 8 +- commander3/src/comm_tod_gain_smod.f90 | 94 +++--- commander3/src/comm_tod_lfi_smod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 309 +++++++++++++++++- commander3/src/comm_zodi_comp_mod.f90 | 9 +- commander3/src/comm_zodi_mod.f90 | 26 +- commander3/src/comm_zodi_samp_mod.f90 | 4 +- commander3/src/commander.f90 | 4 +- commander3/src/math_tools.f90 | 165 ++++++++++ 16 files changed, 806 insertions(+), 266 deletions(-) diff --git a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults index 132dc64d2..673a53bd0 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults @@ -1,5 +1,5 @@ # Stars component -COMP_LABEL&& = stars_diff +COMP_LABEL&& = stars_dust COMP_TYPE&& = MBB COMP_CLASS&& = diffuse # {diffuse, ptsrc} COMP_POLARIZATION&& = .false. diff --git a/commander3/src/comm_output_mod.f90 b/commander3/src/comm_output_mod.f90 index e8d3f6159..3b57d08ac 100644 --- a/commander3/src/comm_output_mod.f90 +++ b/commander3/src/comm_output_mod.f90 @@ -145,7 +145,7 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) call create_hdf_group(file, trim(adjustl(itext))//'/md') end if call update_status(status, "output_chain") - + !Prepare mean foregrounds values print to file if (cpar%myid_chain == 0) then fg_file=trim(cpar%outdir)//'/fg_ind_mean_c' // trim(adjustl(ctext))//'.dat' @@ -512,6 +512,7 @@ subroutine write_params_to_hdf(cpar, chainfile) n = size(cpar%cs_label) do i = 1, n + !write(*,*) i, trim(adjustl(cpar%cs_label(i))) hdf_path = 'parameters/'//trim(adjustl(cpar%cs_label(i))) call create_hdf_group(chainfile, trim(hdf_path)) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 81364ef1e..15db50771 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -41,18 +41,18 @@ module comm_param_mod type(status_file) :: status type InterplanetaryDustParamLabels - character(len=128), dimension(2) :: general = [character(len=128) :: "T_0", "T_DELTA"] - character(len=128), dimension(6) :: common = [character(len=128) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] - character(len=128), dimension(4) :: cloud = [character(len=128) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] - character(len=128), dimension(4) :: band = [character(len=128) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] - character(len=128), dimension(5) :: ring = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(5) :: feature = [character(len=128) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] - character(len=128), dimension(2) :: interstellar = [character(len=128) :: 'R', 'ALPHA'] - character(len=128), dimension(5) :: fan = [character(len=128) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] - character(len=128), dimension(4) :: comet = [character(len=128) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] - character(len=128), dimension(16) :: WrightCloudRing = [character(len=128) :: 'p1', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p13', 'p14', 'p15', 'p16', 'p17', 'p18', 'p19'] - character(len=128), dimension(6) :: WrightBand = [character(len=128) :: 'q1', 'q5', 'q6', 'q7', 'q8', 'R_1'] - character(len=128), dimension(6) :: comp_types = [character(len=128) :: 'CLOUD', 'BAND', 'RING', 'FEATURE', 'WRIGHTCLOUDRING', 'WRIGHTBAND'] + character(len=2048), dimension(2) :: general = [character(len=2048) :: "T_0", "T_DELTA"] + character(len=2048), dimension(6) :: common = [character(len=2048) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] + character(len=2048), dimension(4) :: cloud = [character(len=2048) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] + character(len=2048), dimension(4) :: band = [character(len=2048) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] + character(len=2048), dimension(5) :: ring = [character(len=2048) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=2048), dimension(5) :: feature = [character(len=2048) :: 'R', 'SIGMA_R', 'SIGMA_Z', 'THETA', 'SIGMA_THETA'] + character(len=2048), dimension(2) :: interstellar = [character(len=2048) :: 'R', 'ALPHA'] + character(len=2048), dimension(5) :: fan = [character(len=2048) :: 'Q', 'P', 'gamma', 'Z_midplane_0', 'R_outer'] + character(len=2048), dimension(4) :: comet = [character(len=2048) :: 'P', 'Z_midplane_0', 'R_inner', 'R_outer'] + character(len=2048), dimension(16) :: WrightCloudRing = [character(len=2048) :: 'p1', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p13', 'p14', 'p15', 'p16', 'p17', 'p18', 'p19'] + character(len=2048), dimension(6) :: WrightBand = [character(len=2048) :: 'q1', 'q5', 'q6', 'q7', 'q8', 'R_1'] + character(len=2048), dimension(6) :: comp_types = [character(len=2048) :: 'CLOUD', 'BAND', 'RING', 'FEATURE', 'WRIGHTCLOUDRING', 'WRIGHTBAND'] contains procedure :: get_labels @@ -72,11 +72,11 @@ module comm_param_mod integer(i4b) :: first_samp_resamp, last_samp_resamp, numsamp_per_resamp integer(i4b) :: verbosity, base_seed, base_seed_noise, numchain, num_smooth_scales integer(i4b) :: num_gibbs_iter, thinning, num_init_chains - character(len=512) :: chain_status, init_chain_prefix + character(len=2048) :: chain_status, init_chain_prefix real(dp) :: T_CMB - character(len=512) :: MJysr_convention - character(len=512) :: fft_magic_number_file - character(len=512) :: output_comps + character(len=2048) :: MJysr_convention + character(len=2048) :: fft_magic_number_file + character(len=2048) :: output_comps logical(lgt) :: only_pol, only_I logical(lgt) :: enable_TOD_analysis logical(lgt) :: enable_TOD_simulations !< start commander in simulation regime @@ -85,21 +85,21 @@ module comm_param_mod integer(i4b) :: output_4D_map_nth_iter, output_aux_maps logical(lgt) :: include_tod_zodi, sample_zodi, incl_zodi_solar_comp integer(i4b) :: zodi_solar_nside - character(len=512) :: zodi_solar_initmap, zodi_static_bands + character(len=2048) :: zodi_solar_initmap, zodi_static_bands real(dp), allocatable, dimension(:) :: fwhm_smooth real(dp), allocatable, dimension(:) :: fwhm_postproc_smooth integer(i4b), allocatable, dimension(:) :: lmax_smooth integer(i4b), allocatable, dimension(:) :: nside_smooth - character(len=512), allocatable, dimension(:) :: pixwin_smooth - character(len=512), allocatable, dimension(:) :: init_chain_prefixes - character(len=512) :: sims_output_dir !< simulations directory + character(len=2048), allocatable, dimension(:) :: pixwin_smooth + character(len=2048), allocatable, dimension(:) :: init_chain_prefixes + character(len=2048) :: sims_output_dir !< simulations directory ! alm-sampler integer(i4b) :: almsamp_nsamp, almsamp_nside_chisq_lowres, almsamp_prior_fwhm, almsamp_burnin logical(lgt) :: almsamp_optimize, almsamp_apply_prior, almsamp_pixreg, almsamp_priorsamp_frozen ! Output parameters - character(len=512) :: outdir + character(len=2048) :: outdir integer(i4b) :: nside_chisq, nmaps_chisq logical(lgt) :: pol_chisq, output_mixmat, output_residuals, output_chisq, output_cg_eigenvals integer(i4b) :: output_cg_freq @@ -107,70 +107,70 @@ module comm_param_mod logical(lgt) :: sample_signal_amplitudes, sample_specind, sample_powspec ! Numerical parameters - character(len=512) :: cg_conv_crit, cg_precond + character(len=2048) :: cg_conv_crit, cg_precond integer(i4b) :: cg_lmax_precond, cg_maxiter, cg_num_samp_groups, cg_num_user_samp_groups, cg_miniter, cg_check_conv_freq, cg_samp_group_md logical(lgt) :: cg_init_zero, set_noise_to_mean real(dp) :: cg_tol integer(i4b) :: num_bp_prop - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group_mask + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group_mask integer(i4b), dimension(MAXSAMPGROUP) :: cg_samp_group_maxiter - character(len=512), dimension(MAXSAMPGROUP) :: cg_samp_group_bands + character(len=2048), dimension(MAXSAMPGROUP) :: cg_samp_group_bands ! Data parameters integer(i4b) :: numband - character(len=512) :: datadir, ds_sourcemask, ds_procmask + character(len=2048) :: datadir, ds_sourcemask, ds_procmask logical(lgt), allocatable, dimension(:) :: ds_active integer(i4b), allocatable, dimension(:) :: ds_period logical(lgt), allocatable, dimension(:) :: ds_polarization integer(i4b), allocatable, dimension(:) :: ds_nside integer(i4b), allocatable, dimension(:) :: ds_lmax - character(len=512), allocatable, dimension(:) :: ds_label - character(len=512), allocatable, dimension(:) :: ds_instlabel - character(len=512), allocatable, dimension(:) :: ds_unit - character(len=512), allocatable, dimension(:) :: ds_noise_format + character(len=2048), allocatable, dimension(:) :: ds_label + character(len=2048), allocatable, dimension(:) :: ds_instlabel + character(len=2048), allocatable, dimension(:) :: ds_unit + character(len=2048), allocatable, dimension(:) :: ds_noise_format integer(i4b), allocatable, dimension(:) :: ds_noise_lcut - character(len=512), allocatable, dimension(:) :: ds_mapfile - character(len=512), allocatable, dimension(:) :: ds_noisefile - character(len=512), allocatable, dimension(:) :: ds_regnoise - character(len=512), allocatable, dimension(:,:) :: ds_noise_rms_smooth + character(len=2048), allocatable, dimension(:) :: ds_mapfile + character(len=2048), allocatable, dimension(:) :: ds_noisefile + character(len=2048), allocatable, dimension(:) :: ds_regnoise + character(len=2048), allocatable, dimension(:,:) :: ds_noise_rms_smooth real(dp), allocatable, dimension(:) :: ds_noise_uni_fsky - character(len=512), allocatable, dimension(:) :: ds_maskfile - character(len=512), allocatable, dimension(:) :: ds_maskfile_calib - character(len=512), allocatable, dimension(:) :: ds_beamtype - character(len=512), allocatable, dimension(:) :: ds_blfile - character(len=512), allocatable, dimension(:) :: ds_btheta_file - character(len=512), allocatable, dimension(:) :: ds_pixwin + character(len=2048), allocatable, dimension(:) :: ds_maskfile + character(len=2048), allocatable, dimension(:) :: ds_maskfile_calib + character(len=2048), allocatable, dimension(:) :: ds_beamtype + character(len=2048), allocatable, dimension(:) :: ds_blfile + character(len=2048), allocatable, dimension(:) :: ds_btheta_file + character(len=2048), allocatable, dimension(:) :: ds_pixwin logical(lgt), allocatable, dimension(:) :: ds_samp_noiseamp - character(len=512), allocatable, dimension(:) :: ds_bptype - character(len=512), allocatable, dimension(:) :: ds_bpfile - character(len=512), allocatable, dimension(:) :: ds_bpmodel + character(len=2048), allocatable, dimension(:) :: ds_bptype + character(len=2048), allocatable, dimension(:) :: ds_bpfile + character(len=2048), allocatable, dimension(:) :: ds_bpmodel real(dp), allocatable, dimension(:) :: ds_nu_c logical(lgt), allocatable, dimension(:) :: ds_sample_gain real(dp), allocatable, dimension(:,:) :: ds_gain_prior - character(len=512), allocatable, dimension(:) :: ds_gain_calib_comp + character(len=2048), allocatable, dimension(:) :: ds_gain_calib_comp integer(i4b), allocatable, dimension(:) :: ds_gain_lmin integer(i4b), allocatable, dimension(:) :: ds_gain_lmax - character(len=512), allocatable, dimension(:) :: ds_gain_apodmask - character(len=512), allocatable, dimension(:) :: ds_gain_fwhm + character(len=2048), allocatable, dimension(:) :: ds_gain_apodmask + character(len=2048), allocatable, dimension(:) :: ds_gain_fwhm real(dp), allocatable, dimension(:,:) :: ds_defaults - character(len=512), allocatable, dimension(:) :: ds_component_sensitivity + character(len=2048), allocatable, dimension(:) :: ds_component_sensitivity real(dp), allocatable, dimension(:, :):: ds_zodi_emissivity, ds_zodi_albedo logical(lgt), allocatable, dimension(:) :: ds_zodi_reference_band !TOD data parameters - character(len=512), allocatable, dimension(:) :: ds_tod_type - character(len=512), allocatable, dimension(:) :: ds_tod_procmask1 - character(len=512), allocatable, dimension(:) :: ds_tod_procmask2 - character(len=512), allocatable, dimension(:) :: ds_tod_procmask_zodi - character(len=512), allocatable, dimension(:) :: ds_tod_filelist - character(len=512), allocatable, dimension(:) :: ds_tod_jumplist - character(len=512), allocatable, dimension(:) :: ds_tod_instfile - character(len=512), allocatable, dimension(:) :: ds_tod_dets - character(len=512), allocatable, dimension(:) :: ds_tod_bp_init - character(len=512), allocatable, dimension(:) :: ds_tod_initHDF - character(len=512), allocatable, dimension(:) :: ds_tod_level - character(len=512), allocatable, dimension(:) :: ds_tod_abscal + character(len=2048), allocatable, dimension(:) :: ds_tod_type + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask1 + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask2 + character(len=2048), allocatable, dimension(:) :: ds_tod_procmask_zodi + character(len=2048), allocatable, dimension(:) :: ds_tod_filelist + character(len=2048), allocatable, dimension(:) :: ds_tod_jumplist + character(len=2048), allocatable, dimension(:) :: ds_tod_instfile + character(len=2048), allocatable, dimension(:) :: ds_tod_dets + character(len=2048), allocatable, dimension(:) :: ds_tod_bp_init + character(len=2048), allocatable, dimension(:) :: ds_tod_initHDF + character(len=2048), allocatable, dimension(:) :: ds_tod_level + character(len=2048), allocatable, dimension(:) :: ds_tod_abscal integer(i4b), allocatable, dimension(:,:) :: ds_tod_scanrange integer(i4b), allocatable, dimension(:) :: ds_tod_tot_numscan integer(i4b), allocatable, dimension(:) :: ds_tod_flag @@ -178,40 +178,40 @@ module comm_param_mod logical(lgt), allocatable, dimension(:) :: ds_tod_orb_abscal logical(lgt), allocatable, dimension(:) :: ds_tod_subtract_zodi integer(i4b), allocatable, dimension(:) :: ds_tod_freq - character(len=512), allocatable, dimension(:) :: ds_tod_solar_mask - character(len=512), allocatable, dimension(:) :: ds_tod_solar_model - character(len=512), allocatable, dimension(:) :: ds_tod_solar_init + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_mask + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_model + character(len=2048), allocatable, dimension(:) :: ds_tod_solar_init ! Component parameters - character(len=512) :: cs_inst_parfile - character(len=512) :: cs_init_inst_hdf + character(len=2048) :: cs_inst_parfile + character(len=2048) :: cs_init_inst_hdf integer(i4b) :: cs_ncomp, cs_ncomp_tot, cs_local_burn_in logical(lgt) :: cs_output_localsamp_maps real(dp) :: cmb_dipole_prior(3) - character(len=512) :: cmb_dipole_prior_mask + character(len=2048) :: cmb_dipole_prior_mask logical(lgt), allocatable, dimension(:) :: cs_include - character(len=512), allocatable, dimension(:) :: cs_initHDF - character(len=512), allocatable, dimension(:) :: cs_label - character(len=512), allocatable, dimension(:) :: cs_type - character(len=512), allocatable, dimension(:) :: cs_class + character(len=2048), allocatable, dimension(:) :: cs_initHDF + character(len=2048), allocatable, dimension(:) :: cs_label + character(len=2048), allocatable, dimension(:) :: cs_type + character(len=2048), allocatable, dimension(:) :: cs_class logical(lgt), allocatable, dimension(:) :: cs_polarization real(dp), allocatable, dimension(:,:) :: cs_cg_scale integer(i4b), allocatable, dimension(:) :: cs_nside integer(i4b), allocatable, dimension(:,:) :: cs_poltype integer(i4b), allocatable, dimension(:) :: cs_cg_samp_group_maxiter - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_lnLtype - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_pixreg - character(len=512), allocatable, dimension(:,:) :: cs_spec_pixreg_map - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_fix_pixreg - character(len=512), allocatable, dimension(:,:,:) :: cs_spec_pixreg_priors - character(len=512), allocatable, dimension(:,:) :: cs_spec_mask - character(len=512), allocatable, dimension(:,:) :: cs_spec_nprop - character(len=512), allocatable, dimension(:,:) :: cs_spec_proplen - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_mask - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_freeze - character(len=512), allocatable, dimension(:,:) :: cs_spec_mono_type - character(len=512), allocatable, dimension(:,:) :: cs_almsamp_init - character(len=512), allocatable, dimension(:,:) :: cs_pixreg_init_theta + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_lnLtype + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_pixreg + character(len=2048), allocatable, dimension(:,:) :: cs_spec_pixreg_map + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_fix_pixreg + character(len=2048), allocatable, dimension(:,:,:) :: cs_spec_pixreg_priors + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mask + character(len=2048), allocatable, dimension(:,:) :: cs_spec_nprop + character(len=2048), allocatable, dimension(:,:) :: cs_spec_proplen + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_mask + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_freeze + character(len=2048), allocatable, dimension(:,:) :: cs_spec_mono_type + character(len=2048), allocatable, dimension(:,:) :: cs_almsamp_init + character(len=2048), allocatable, dimension(:,:) :: cs_pixreg_init_theta integer(i4b), allocatable, dimension(:,:,:) :: cs_spec_nprop_init real(dp), allocatable, dimension(:,:,:) :: cs_spec_proplen_init real(dp), allocatable, dimension(:,:) :: cs_spec_corr_limit @@ -229,40 +229,40 @@ module comm_param_mod integer(i4b), allocatable, dimension(:) :: cs_lmax_amp_prior integer(i4b), allocatable, dimension(:) :: cs_l_apod integer(i4b), allocatable, dimension(:) :: cs_lmax_ind - character(len=512), allocatable, dimension(:) :: cs_unit + character(len=2048), allocatable, dimension(:) :: cs_unit real(dp), allocatable, dimension(:,:) :: cs_nu_ref real(dp), allocatable, dimension(:) :: cs_nu_min, cs_nu_max - character(len=512), allocatable, dimension(:) :: cs_band_ref + character(len=2048), allocatable, dimension(:) :: cs_band_ref real(dp), allocatable, dimension(:) :: cs_fwhm - character(len=512), allocatable, dimension(:) :: cs_cltype - character(len=512), allocatable, dimension(:) :: cs_clfile - character(len=512), allocatable, dimension(:) :: cs_binfile + character(len=2048), allocatable, dimension(:) :: cs_cltype + character(len=2048), allocatable, dimension(:) :: cs_clfile + character(len=2048), allocatable, dimension(:) :: cs_binfile integer(i4b), allocatable, dimension(:) :: cs_lpivot - character(len=512), allocatable, dimension(:) :: cs_mask - character(len=512), allocatable, dimension(:) :: cs_mono_prior + character(len=2048), allocatable, dimension(:) :: cs_mask + character(len=2048), allocatable, dimension(:) :: cs_mono_prior real(dp), allocatable, dimension(:) :: cs_latmask - character(len=512), allocatable, dimension(:) :: cs_indmask - character(len=512), allocatable, dimension(:) :: cs_defmask + character(len=2048), allocatable, dimension(:) :: cs_indmask + character(len=2048), allocatable, dimension(:) :: cs_defmask real(dp), allocatable, dimension(:,:) :: cs_cl_prior real(dp), allocatable, dimension(:,:) :: cs_cl_amp_def real(dp), allocatable, dimension(:,:) :: cs_cl_beta_def real(dp), allocatable, dimension(:,:) :: cs_cl_theta_def integer(i4b), allocatable, dimension(:) :: cs_cl_poltype logical(lgt), allocatable, dimension(:) :: cs_output_EB - character(len=512), allocatable, dimension(:) :: cs_input_amp - character(len=512), allocatable, dimension(:) :: cs_prior_amp - character(len=512), allocatable, dimension(:,:) :: cs_input_ind - character(len=512), allocatable, dimension(:,:) :: cs_SED_template - character(len=512), allocatable, dimension(:) :: cs_MBBtab_type + character(len=2048), allocatable, dimension(:) :: cs_input_amp + character(len=2048), allocatable, dimension(:) :: cs_prior_amp + character(len=2048), allocatable, dimension(:,:) :: cs_input_ind + character(len=2048), allocatable, dimension(:,:) :: cs_SED_template + character(len=2048), allocatable, dimension(:) :: cs_MBBtab_type real(dp), allocatable, dimension(:) :: cs_SED_prior real(dp), allocatable, dimension(:,:) :: cs_theta_def real(dp), allocatable, dimension(:,:) :: cs_nu_break integer(i4b), allocatable, dimension(:,:) :: cs_smooth_scale real(dp), allocatable, dimension(:,:,:) :: cs_p_gauss real(dp), allocatable, dimension(:,:,:) :: cs_p_uni - character(len=512), allocatable, dimension(:) :: cs_catalog - character(len=512), allocatable, dimension(:) :: cs_init_catalog - character(len=512), allocatable, dimension(:) :: cs_ptsrc_template + character(len=2048), allocatable, dimension(:) :: cs_catalog + character(len=2048), allocatable, dimension(:) :: cs_init_catalog + character(len=2048), allocatable, dimension(:) :: cs_ptsrc_template real(dp), allocatable, dimension(:,:) :: cs_nu_min_beta real(dp), allocatable, dimension(:,:) :: cs_nu_max_beta logical(lgt), allocatable, dimension(:) :: cs_burn_in @@ -280,7 +280,7 @@ module comm_param_mod real(dp), allocatable, dimension(:) :: zs_nu_ref, zs_solar_irradiance ! (n_band) real(dp) :: zs_comp_params(MAXZODICOMPS, MAXZODIPARAMS, 4), zs_delta_t_reset, zs_general_params(MAXZODIPARAMS, 4), zs_r_min(MAXZODICOMPS), zs_r_max(MAXZODICOMPS), zs_randomize_rms real(dp) :: zs_tod_thin_factor, zs_tod_thin_threshold, zs_sol_elong(2) - character(len=128) :: zs_comp_labels(MAXZODICOMPS), zs_comp_types(MAXZODICOMPS), zs_init_hdf(MAXZODICOMPS), zs_sample_method, zs_init_ascii, zs_refband, zs_em_global, zs_al_global + character(len=2048) :: zs_comp_labels(MAXZODICOMPS), zs_comp_types(MAXZODICOMPS), zs_init_hdf(MAXZODICOMPS), zs_sample_method, zs_init_ascii, zs_refband, zs_em_global, zs_al_global character(len=2048) :: zs_wiring character(len=2048), allocatable :: zs_samp_groups(:), zs_samp_group_bands(:) logical(lgt) :: zs_output_comps, zs_output_ascii, zs_joint_mono, zs_output_tod_res @@ -291,9 +291,9 @@ module comm_param_mod integer(i4b) :: mcmc_num_user_samp_groups ! NUM_MCMC_SAMPLING_GROUPS integer(i4b) :: mcmc_num_samp_groups ! NUM_MCMC_SAMPLING_GROUPS character(len=2048), allocatable :: mcmc_samp_groups(:) ! MCMC_SAMPLING_GROUP_PARAMS, MCMC_SAMPLING_GROUP_CHISQ_BANDS - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_samp_group_mask - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_samp_group_bands - character(len=512), dimension(MAXSAMPGROUP) :: mcmc_update_cg_groups ! MCMC_SAMPLING_GROUP_UPDATE_CG_GROUPS&& + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_samp_group_mask + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_samp_group_bands + character(len=2048), dimension(MAXSAMPGROUP) :: mcmc_update_cg_groups ! MCMC_SAMPLING_GROUP_UPDATE_CG_GROUPS&& ! Sample using specificed cg ! groups. If none, skip amplitude ! sampling @@ -313,8 +313,8 @@ subroutine read_comm_params(cpar) type(comm_params), intent(inout) :: cpar integer(i4b) :: paramfile_len, ierr, i, idx - character(len=512) :: paramfile, paramfile_name - character(len=512), allocatable, dimension(:) :: paramfile_cache + character(len=2048) :: paramfile, paramfile_name + character(len=2048), allocatable, dimension(:) :: paramfile_cache call getarg(1, paramfile) ! read parameter file once, save to ascii array @@ -325,7 +325,7 @@ subroutine read_comm_params(cpar) ! Read parameters into cache if (cpar%myid == cpar%root) then - paramfile_len = 512 + paramfile_len = 2048 allocate(paramfile_cache(paramfile_len)) call read_paramfile_to_ascii(paramfile,paramfile_cache,paramfile_len) end if @@ -334,7 +334,7 @@ subroutine read_comm_params(cpar) allocate(paramfile_cache(paramfile_len)) end if do i=1,paramfile_len - call mpi_bcast(paramfile_cache(i), 512, MPI_CHAR, cpar%root, MPI_COMM_WORLD, ierr) + call mpi_bcast(paramfile_cache(i), 2048, MPI_CHAR, cpar%root, MPI_COMM_WORLD, ierr) end do !Initialize a hash table call init_hash_tbl_sll(htable,tbl_len=10*paramfile_len) @@ -755,8 +755,8 @@ subroutine read_component_params_hash(htbl, cpar) integer(i4b) :: i, j, k, n, len_itext, idx real(dp) :: amp, lat, lon character(len=2) :: itext - character(len=512) :: maskfile, tokens(4) - character(len=512) :: pol_labels(3) + character(len=2048) :: maskfile, tokens(4) + character(len=2048) :: pol_labels(3) logical(lgt) :: bool_flag pol_labels(1)='INT' @@ -1005,11 +1005,11 @@ subroutine read_diffuse_gen_params_hash(htbl, cpar, itext, i, len_itext, bool_fl type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k, idx - character(len=512) :: maskfile + character(len=2048) :: maskfile call get_parameter_hashtable(htbl, 'COMP_POLARIZATION'//itext, len_itext=len_itext, par_lgt=cpar%cs_polarization(i)) @@ -1113,7 +1113,7 @@ subroutine read_cmb_params_hash(htbl, cpar) type(comm_params), intent(inout) :: cpar real(dp) :: amp, lat, lon - character(len=512) :: tokens(4) + character(len=2048) :: tokens(4) call get_parameter_hashtable(htbl, 'CMB_DIPOLE_PRIOR', par_string=cpar%cmb_dipole_prior_mask, path=.true.) if (trim(cpar%cmb_dipole_prior_mask) /= 'none') then @@ -1138,7 +1138,7 @@ subroutine read_power_law_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1265,7 +1265,7 @@ subroutine read_power_law_break_params_hash(htbl, cpar, itext, i, len_itext, boo type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1496,7 +1496,7 @@ subroutine read_curvature_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1716,7 +1716,7 @@ subroutine read_physdust_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1845,7 +1845,7 @@ subroutine read_spindust_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -1969,7 +1969,7 @@ subroutine read_spindust2_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2188,7 +2188,7 @@ subroutine read_pah_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_ type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2205,7 +2205,7 @@ subroutine read_lognormal_params_hash(htbl, cpar, itext, i, len_itext, bool_flag type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2426,7 +2426,7 @@ subroutine read_mbb_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_ type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2655,7 +2655,7 @@ subroutine read_freefree_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2795,7 +2795,7 @@ subroutine read_freefreeEM_params_hash(htbl, cpar, itext, i, len_itext, bool_fla type(comm_params), intent(inout) :: cpar logical(lgt), intent(inout) :: bool_flag - character(len=512), intent(in) :: pol_labels(3) + character(len=2048), intent(in) :: pol_labels(3) character(len=2), intent(in) :: itext integer(i4b), intent(in) :: len_itext, i integer(i4b) :: j, k @@ -2941,13 +2941,13 @@ subroutine read_zodi_params_hash(htbl, cpar) character(len=2) :: itext2 character(len=3) :: itext character(len=64), allocatable :: parameter_labels(:) - character(len=512), dimension(4) :: value_and_priors_str - character(len=512), dimension(20) :: zs_comp_lens_str + character(len=2048), dimension(4) :: value_and_priors_str + character(len=2048), dimension(20) :: zs_comp_lens_str real(dp), dimension(4) :: value_and_priors character(len=64) :: value_string logical(lgt) :: use_comp - character(len=512) :: temp_emissivity, temp_albedo - character(len=512), allocatable, dimension(:) :: samp_group_strings, emissivity_string, albedo_string + character(len=2048) :: temp_emissivity, temp_albedo + character(len=2048), allocatable, dimension(:) :: samp_group_strings, emissivity_string, albedo_string real(dp), parameter :: DEFAULT_PRIOR_LOWER_LIMIT = -1d300, DEFAULT_PRIOR_UPPER_LIMIT = 1d300 call get_parameter_hashtable(htbl, 'NUM_ZODI_COMPS', par_int=cpar%zs_ncomps) @@ -3076,7 +3076,7 @@ subroutine read_zodi_params_hash(htbl, cpar) subroutine parse_parameter(line, parname, found, par_int, par_char, par_string, par_sp, par_dp, par_lgt) implicit none character(len=*) :: line, parname - character(len=256) :: toks(2), key, value, par + character(len=2048) :: toks(2), key, value, par logical(lgt) :: found integer(i4b), optional :: par_int character(len=*), optional :: par_char @@ -3133,7 +3133,7 @@ subroutine get_parameter_arg(parname, par_int, par_char, & logical(lgt), optional :: par_present character(len=*), optional :: desc - character(len=512) :: line + character(len=2048) :: line integer(i4b) :: i logical(lgt) :: found do i = 1, command_argument_count() !iargc() @@ -3159,7 +3159,7 @@ end subroutine get_parameter_arg subroutine dump_expanded_paramfile(parfile, outfile) implicit none character(len=*) :: parfile, outfile - integer(i4b), parameter :: maxdepth = 256 + integer(i4b), parameter :: maxdepth = 2048 integer(i4b) :: depth, units(maxdepth), i, num, ounit, stat character(len=1024) :: key, value, arg, default_path @@ -3395,8 +3395,8 @@ subroutine tokenize(string, sep, ext, group, allow_empty) implicit none character(len=*) :: string, sep character(len=*), optional :: group - character(len=256) :: op, cl - integer(i4b), save :: level(256), nl + character(len=2048) :: op, cl + integer(i4b), save :: level(2048), nl integer(i4b), intent(inout) :: ext(2) logical(lgt), optional :: allow_empty @@ -3473,7 +3473,7 @@ subroutine validate_params(cpar) type(comm_params), intent(inout) :: cpar integer(i4b) :: i, j - character(len=512) :: chaindir + character(len=2048) :: chaindir character(len=2) :: itext, jtext logical(lgt) :: exist @@ -3680,17 +3680,17 @@ end subroutine validate_file subroutine read_paramfile_to_ascii(paramfile,paramfile_cache, paramfile_len) implicit none - character(len=512), intent(in) :: paramfile - character(len=512), allocatable, dimension(:), intent(inout) :: paramfile_cache + character(len=2048), intent(in) :: paramfile + character(len=2048), allocatable, dimension(:), intent(inout) :: paramfile_cache integer(i4b),intent(inout) :: paramfile_len - integer(i4b), parameter :: maxdepth = 256 + integer(i4b), parameter :: maxdepth = 2048 integer(i4b) :: depth, units(maxdepth), line_nr,i, stat, pos - character(len=512) :: key, value, filenames(maxdepth), line + character(len=2048) :: key, value, filenames(maxdepth), line character(len=1024) :: default_path character(len=3) :: band_num - character(len=512), allocatable, dimension(:) :: new_cache + character(len=2048), allocatable, dimension(:) :: new_cache ! read file to ascii array @@ -3868,10 +3868,10 @@ subroutine get_parameter_from_hash(htbl, parname, len_itext, par_int, par_char, logical(lgt), optional :: par_present character(len=*), optional :: desc logical(lgt), optional :: path - character(len=256) :: key + character(len=2048) :: key character(len=:), ALLOCATABLE :: itext,jtext CHARACTER(len=:), ALLOCATABLE :: val,val2,val3 - character(len=512) :: val4 + character(len=2048) :: val4 integer(i4b) :: i,j logical(lgt) :: loc_path @@ -3967,8 +3967,8 @@ end subroutine get_parameter_from_hash ! outputs the parameter file to the path provided subroutine save_ascii_parameter_file(outfile, ascii_table) implicit none - character(len=512), intent(in) :: outfile - character(len=512), dimension(:), intent(in) :: ascii_table + character(len=2048), intent(in) :: outfile + character(len=2048), dimension(:), intent(in) :: ascii_table integer(i4b) :: unit, i @@ -3990,10 +3990,10 @@ end subroutine save_ascii_parameter_file ! filling the hash table with elements from the parameter file (ascii array) subroutine put_ascii_into_hashtable(asciitbl,htbl) implicit none - character(len=512), allocatable, dimension(:), intent(in) :: asciitbl + character(len=2048), allocatable, dimension(:), intent(in) :: asciitbl type(hash_tbl_sll), intent(inout) :: htbl - character(len=512) :: key, val - character(len=256) :: toks(2) + character(len=2048) :: key, val + character(len=2048) :: toks(2) integer :: i, n do i = 1,size(asciitbl) call get_tokens(trim(asciitbl(i)), "=", group="''" // '""', maxnum=2, toks=toks, num=n) @@ -4016,11 +4016,11 @@ end subroutine put_ascii_into_hashtable subroutine get_chainfile_and_samp(string, chainfile, initsamp) implicit none character(len=*), intent(in) :: string - character(len=512), intent(out) :: chainfile + character(len=2048), intent(out) :: chainfile integer(i4b), intent(out) :: initsamp integer(i4b) :: i, num, e - character(len=512), dimension(2) :: toks + character(len=2048), dimension(2) :: toks call get_tokens(string, ":", toks, num) @@ -4101,8 +4101,8 @@ function get_labels(self, comp_type, add_common) result(labels) class(InterplanetaryDustParamLabels), intent(in) :: self character(len=*), intent(in) :: comp_type logical(lgt), intent(in), optional :: add_common - character(len=128), allocatable :: labels(:) - character(len=128) :: comp_type_upper + character(len=2048), allocatable :: labels(:) + character(len=2048) :: comp_type_upper comp_type_upper = comp_type call toupper(comp_type_upper) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 55c97b6bf..a45a01ed3 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -51,7 +51,7 @@ module comm_ptsrc_comp_mod type, extends (comm_comp) :: comm_ptsrc_comp character(len=512) :: outprefix real(dp) :: cg_scale, amp_rms_scale - integer(i4b) :: nside, nside_febecop, nsrc, ncr_tot, ndet, nactive + integer(i4b) :: nside, nside_febecop, nsrc, ndet, nactive logical(lgt) :: apply_pos_prior, burn_in, precomputed_amps, recompute_ptsrc_precond real(dp), allocatable, dimension(:,:) :: x ! Amplitudes (nsrc,nmaps) real(dp), allocatable, dimension(:,:) :: x_buff ! Amplitudes (nsrc,nmaps) @@ -82,13 +82,11 @@ module comm_ptsrc_comp_mod class(comm_ptsrc_comp), pointer :: p => null() end type ptsrc_ptr - integer(i4b) :: ncomp_pre = 0 - integer(i4b) :: npre = 0 - integer(i4b) :: nmaps_pre = -1 + integer(i4b), allocatable, dimension(:) :: npre, nmaps_pre integer(i4b) :: comm_pre = -1 integer(i4b) :: myid_pre = -1 integer(i4b) :: numprocs_pre = -1 - logical(lgt) :: apply_ptsrc_precond = .true. + logical(lgt) :: apply_ptsrc_precond = .false. character(len=24), private :: operation @@ -112,6 +110,7 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) call update_status(status, "init_ptsrc1") ! General parameters + apply_ptsrc_precond = .true. allocate(c) ! Initialize general parameters @@ -136,7 +135,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) c%comm = cpar%comm_chain c%numprocs = cpar%numprocs_chain c%init_from_HDF = cpar%cs_initHDF(id_abs) - ncomp_pre = ncomp_pre + 1 operation = cpar%operation c%apply_pos_prior = cpar%cs_apply_pos_prior(id_abs) c%burn_in = cpar%cs_burn_in(id_abs) @@ -252,19 +250,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) call report_error("Unknown point source model: " // trim(c%type)) end select - ! Read and allocate source structures - call update_status(status, "init_ptsrc2") - if( trim(c%type) == 'stars') then - ! stars uses an hdf catalogue instead of a txt file - call read_star_catalogue(c, cpar, id, id_abs) - else - call read_sources(c, cpar, id, id_abs) - end if - - ! Update mixing matrix - call update_status(status, "init_ptsrc3") - call c%updateMixmat - ! Set up CG sampling groups allocate(c%active_samp_group(cpar%cg_num_samp_groups)) c%active_samp_group = .false. @@ -281,6 +266,19 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) ! Disable CG search when asking for positivity prior if (c%apply_pos_prior) c%active_samp_group = .false. + + ! Read and allocate source structures + call update_status(status, "init_ptsrc2") + if( trim(c%type) == 'stars') then + ! stars uses an hdf catalogue instead of a txt file + call read_star_catalogue(c, cpar, id, id_abs) + else + call read_sources(c, cpar, id, id_abs) + end if + + ! Update mixing matrix + call update_status(status, "init_ptsrc3") + call c%updateMixmat call update_status(status, "init_ptsrc4") @@ -727,7 +725,12 @@ subroutine read_sources(self, cpar, id, id_abs) open(unit,file=trim(cpar%cs_catalog(id_abs)),recl=1024) self%nsrc = 0 self%ncr = 0 - self%ncr_tot = 0 + if (.not. allocated(npre)) then + allocate(npre(cpar%cg_num_samp_groups)) + allocate(nmaps_pre(cpar%cg_num_samp_groups)) + npre = 0 + nmaps_pre = 1 + end if do while (.true.) read(unit,'(a)',end=1) line line = trim(adjustl(line)) @@ -735,10 +738,13 @@ subroutine read_sources(self, cpar, id, id_abs) cycle else self%nsrc = self%nsrc + 1 - npre = npre + 1 - nmaps_pre = max(nmaps_pre, nmaps) - self%ncr_tot = self%ncr_tot + nmaps if (cpar%myid_chain == 0) self%ncr = self%ncr + nmaps + do i = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(i)) then + npre(i) = npre(i) + 1 + nmaps_pre(i) = max(nmaps_pre(i), nmaps) + end if + end do end if end do 1 close(unit) @@ -776,10 +782,12 @@ subroutine read_sources(self, cpar, id, id_abs) end if if (skip_src) then self%nsrc = self%nsrc-1 - npre = npre - 1 - nmaps_pre = max(nmaps_pre, nmaps) - self%ncr_tot = self%ncr_tot - nmaps if (cpar%myid_chain == 0) self%ncr = self%ncr - nmaps + do j = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(j)) then + npre(j) = npre(j) - 1 + end if + end do else i = i+1 allocate(self%src(i)%theta(self%npar,self%nmaps), self%src(i)%T(nactive)) @@ -1000,7 +1008,6 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) !store each pointsource in a source object self%ncr = 0 - self%ncr_tot = 0 ii = 0 do i=1, self%nsrc if (myid_pre == 0) then @@ -1032,10 +1039,13 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) end if allocate(self%src(ii)%amp_precomp(self%nactive)) - allocate(self%src(ii)%T(self%nactive)) - npre = npre + 1 - nmaps_pre = max(nmaps_pre, self%nmaps) - self%ncr_tot = self%ncr_tot + self%nmaps + allocate(self%src(ii)%T(self%nactive)) + do j = 1, cpar%cg_num_samp_groups + if (self%active_samp_group(j)) then + npre(j) = npre(j) + 1 + nmaps_pre(j) = max(nmaps_pre(j), self%nmaps) + end if + end do if (cpar%myid_chain == 0) self%ncr = self%ncr + self%nmaps ! Normalize to first frequency @@ -1538,9 +1548,8 @@ subroutine initPtsrcPrecond(comm, samp_group) real(dp), allocatable, dimension(:,:) :: mat, mat2 type(ptsrc_ptr), dimension(5) :: pc - if (npre == 0) return - if (ncomp_pre == 0) return if (.not. apply_ptsrc_precond) return + if (npre(samp_group) == 0) return ! Make a list of active components, and check that at least one wants update nactive = 0 @@ -1564,10 +1573,10 @@ subroutine initPtsrcPrecond(comm, samp_group) ! Build frequency-dependent part of preconditioner call wall_time(t1) if (.not. allocated(P_cr(samp_group)%invM_src)) then - allocate(P_cr(samp_group)%invM_src(1,nmaps_pre)) + allocate(P_cr(samp_group)%invM_src(1,nmaps_pre(samp_group))) end if !allocate(mat(npre,npre), mat2(npre,npre)) - do j = 1, nmaps_pre + do j = 1, nmaps_pre(samp_group) ! Find number of matrix elements if (.not. associated(P_cr(samp_group)%invM_src(1,j)%M)) then @@ -1595,7 +1604,7 @@ subroutine initPtsrcPrecond(comm, samp_group) call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) if (myid_pre == 0) write(*,*) 'Number of matrix elements = ', n ! Allocate sparse matrix - P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre, n) + P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre(samp_group), n) end if if (P_cr(samp_group)%invM_src(1,j)%M%ni == 0) then @@ -1788,7 +1797,7 @@ subroutine initPtsrcPrecond(comm, samp_group) if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc i1 = i1+1 - call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.01d0, i1) + call P_cr(samp_group)%invM_src(1,j)%M%add_diag(0.0d0, i1) end do end do ! Invert matrix to finalize preconditioner @@ -1800,7 +1809,7 @@ subroutine initPtsrcPrecond(comm, samp_group) end do call wall_time(t2) if (myid_pre == 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) - + do i = 1, nactive pc(i)%p%recompute_ptsrc_precond = .false. end do @@ -1828,10 +1837,11 @@ subroutine applyPtsrcPrecond(x, samp_group) class(comm_comp), pointer :: c => null() class(comm_ptsrc_comp), pointer :: pt => null() - if (npre == 0 .or. myid_pre /= 0 .or. .not. apply_ptsrc_precond) return + if (.not. apply_ptsrc_precond) return + if (npre(samp_group) == 0 .or. myid_pre /= 0) return ! Reformat linear array into y(npre,nalm,nmaps) structure - allocate(y(npre,nmaps_pre)) + allocate(y(npre(samp_group),nmaps_pre(samp_group))) y = 0.d0 l = 1 c => compList @@ -1839,8 +1849,10 @@ subroutine applyPtsrcPrecond(x, samp_group) skip = .true. select type (c) class is (comm_ptsrc_comp) - pt => c - skip = .false. + if (c%active_samp_group(samp_group)) then + pt => c + skip = .false. + end if end select if (skip) then c => c%nextComp() @@ -1856,7 +1868,7 @@ subroutine applyPtsrcPrecond(x, samp_group) end do ! Multiply with preconditioner - do j = 1, nmaps_pre + do j = 1, nmaps_pre(samp_group) !y(:,j) = matmul(P_cr(samp_group)%invM_src(1,j)%M, y(:,j)) call P_cr(samp_group)%invM_src(1,j)%M%set_rhs(y(:,j)) call P_cr(samp_group)%invM_src(1,j)%M%solve(y(:,j)) @@ -1869,8 +1881,10 @@ subroutine applyPtsrcPrecond(x, samp_group) skip = .true. select type (c) class is (comm_ptsrc_comp) - pt => c - skip = .false. + if (c%active_samp_group(samp_group)) then + pt => c + skip = .false. + end if end select if (skip) then c => c%nextComp() @@ -2178,7 +2192,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) x(1) = self%x(k,p) if (self%apply_pos_prior .and. p == 1 .and. x(1) < 0.d0) x(1) = 0.d0 x(2:1+self%npar) = self%src(k)%theta(:,p) - call powell(x, lnL_ptsrc_multi, ierr) !!!!! + call powell(x, lnL_ptsrc_multi, ierr, tolerance=1d-5) !!!!! a = x(1) theta = x(2:1+self%npar) do l = 1, c_lnL%npar diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index 7c0f379b8..cce52df71 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -418,7 +418,7 @@ subroutine initialize_from_chain(cpar, handle, init_samp, init_from_output, firs integer(i4b) :: i, j, ext(2), initsamp, initsamp2 character(len=4) :: ctext character(len=6) :: itext, itext2 - character(len=512) :: chainfile, hdfpath + character(len=2048) :: chainfile, hdfpath class(comm_comp), pointer :: c => null() type(hdf_file) :: file, file2 class(comm_N), pointer :: N => null() diff --git a/commander3/src/comm_sparse_mod.f90 b/commander3/src/comm_sparse_mod.f90 index 9408a5e35..75ad94c4e 100644 --- a/commander3/src/comm_sparse_mod.f90 +++ b/commander3/src/comm_sparse_mod.f90 @@ -151,7 +151,7 @@ subroutine sparse_system_decomp(self) ! Symbolic factorization phase = 11 ! only reordering and symbolic factorization - self%iparm(33) = 1 ! compute determinant + self%iparm(33) = 1 ! compute determinant call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index b2426ccf6..17334ffaa 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -161,7 +161,7 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) !do i = 1, c%nscan ! c%scans(i)%d%baseline = 0.d0 !end do - + call timer%stop(TOD_INIT, id_abs) end function constructor_dirbe @@ -249,7 +249,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, type(map_ptr), dimension(1:,1:), intent(inout), optional :: map_gain ! (ndet,1) real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps, tod_start_idx, n_tod_tot, n_comps_to_fit - logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr + logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr, apply_dynamic_mask type(comm_binmap) :: binmap type(comm_scandata) :: sd character(len=4) :: ctext, myid_text @@ -261,7 +261,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, real(sp), allocatable, dimension(:) :: procmask, procmask2, procmask_zodi real(sp), allocatable, dimension(:,:,:) :: d_calib real(sp), allocatable, dimension(:,:,:,:) :: map_sky, m_gain - real(dp), allocatable, dimension(:,:) :: chisq_S, m_buf + real(dp), allocatable, dimension(:,:) :: chisq_S, m_buf, freqmap real(dp), allocatable, dimension(:, :) :: A_T_A, A_T_A_reduced real(dp), allocatable, dimension(:) :: AY, AY_reduced, X real(dp), allocatable, dimension(:, :, :) :: s_therm_tot, s_scat_tot ! (n_tod_tot, ncomps, ndet) @@ -284,7 +284,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, sample_abs_bandpass = .false. ! don't sample absolute bandpasses select_data = .false. !self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration - sample_gain = .true. ! Gain sampling, LB TOD sims have perfect gain + !sample_gain = .true. !iter > 1 ! Gain sampling, LB TOD sims have perfect gain !!$ if (trim(self%freq) == '01' .or. trim(self%freq) == '02' .or. & !!$ & trim(self%freq) == '03' .or. & !!$ & trim(self%freq) == '09' .or. trim(self%freq) == '10') then @@ -294,7 +294,18 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, else sample_ncorr = .false. end if - + + if (trim(self%freq(1:2)) == '05' .or. trim(self%freq(1:2)) == '06' .or. & + & trim(self%freq(1:2)) == '07' .or. trim(self%freq(1:2)) == '08' .or. & + & trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then + sample_gain = .true. + apply_dynamic_mask = .true. + else + sample_gain = .false. + apply_dynamic_mask = .false. + end if + !sample_gain = .false. + ! Initialize local variables ndelta = size(delta,3) self%n_bp_prop = ndelta-1 @@ -347,13 +358,13 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, !------------------------------------ ! Sample gain components in separate TOD loops; marginal with respect to n_corr - if (iter > 1 .and. sample_gain) then + if (sample_gain) then ! 'abscal': the global constant gain factor !call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2) ! 'relcal': the gain factor that is constant in time but varying between detectors ! call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) ! 'deltaG': the time-variable and detector-variable gain - call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask2, procmask2, smooth=.true.) + call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask2, procmask2, smooth=.true., mask_threshold=0.1d0) end if ! Prepare intermediate data structures @@ -377,10 +388,11 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) ! Create dynamic mask - if (self%first_call) then + if (self%first_call .and. apply_dynamic_mask) then do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle - call self%create_dynamic_mask(i, j, sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j), [-10.,10.], sd%mask(:,j)) + call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & + & [-5.,5.], sd%mask(:,j), sd%flag(:,j)) end do call sd%dealloc if (.not. any(self%scans(i)%d%accept)) cycle @@ -410,7 +422,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Compute chisquare for bandpass fit if (sample_abs_bandpass) call compute_chisq_abs_bp(self, i, sd, chisq_S) - + ! Compute binned map allocate(d_calib(self%output_n_maps, sd%ntod, sd%ndet)) d_calib = 0.d0 @@ -418,7 +430,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call compute_calibrated_data(self, i, sd, d_calib) ! For debugging: write TOD to hdf - if (.true.) then + if (.false.) then ! scan id appears to be the worst chi2 if (self%scanid(i) < 10000) then !print *, self%scanid(i) @@ -448,6 +460,10 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) +!!$ do j = 1, binmap%nobs +!!$ if (binmap%A_map(1,j) > 0.) write(*,*) j, real(binmap%b_map(1,1,j),sp), real(binmap%A_map(1,j),sp), real(binmap%b_map(1,1,j)/binmap%A_map(1,j),sp) +!!$ end do + ! Update scan list call wall_time(t2) self%scans(i)%proctime = self%scans(i)%proctime + t2-t1 diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index c51535ffc..690d34993 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -647,7 +647,7 @@ end subroutine dealloc_scan_data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, procmask2, & - & polang, smooth) + & polang, smooth, mask_threshold) ! ! Sample calibration modes ! Supported modes = {abscal, relcal, deltaG, imbal} @@ -677,8 +677,10 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr real(sp), dimension(0:), intent(in) :: procmask, procmask2 real(dp), intent(in), optional :: polang logical(lgt), intent(in), optional :: smooth + real(dp), intent(in), optional :: mask_threshold integer(i4b) :: i, j, ext(2), ierr, timer_id + real(sp) :: threshold real(dp) :: t1, t2 real(dp), allocatable, dimension(:) :: A, b real(sp), allocatable, dimension(:,:) :: s_invsqrtN, mask_lowres, s_buf @@ -688,6 +690,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr smooth_ = .true. + threshold = 0.9; if (present(mask_threshold)) threshold=mask_threshold if (present(smooth)) smooth_=smooth if (tod%myid == 0) write(*,*) '| --> Sampling calibration, mode = ', trim(mode) @@ -739,7 +742,8 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr allocate(mask_lowres(ext(1):ext(2), tod%ndet)) do j = 1, tod%ndet if (.not. tod%scans(i)%d(j)%accept) cycle - call tod%downsample_tod(sd%mask(:,j), ext, mask_lowres(:,j), threshold=0.9) + call tod%downsample_tod(sd%mask(:,j), ext, mask_lowres(:,j), threshold=threshold) + !if (size(sd%mask(:,j)) > 0) write(*,*) "fsky", sum(sd%mask(:,j))/size(sd%mask(:,j)), sum(mask_lowres(:,j))/size(mask_lowres(:,j)) if (trim(mode) == 'abscal') then if (trim(tod%abscal_comps) == 'orbital') then call tod%downsample_tod(sd%s_orb(:,j), ext, s_invsqrtN(:,j)) diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index ee5ba80d2..56da6dbf1 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -100,13 +100,15 @@ module subroutine calculate_gain_mean_std_per_scan(tod, scan_id, s_invsqrtN, mas tod%scans(scan_id)%d(j)%gain = 0.d0 tod%scans(scan_id)%d(j)%dgain = 0.d0 else - if (present(mask_lowres)) then - tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j) * mask_lowres(:,j)) - tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2 * mask_lowres(:,j)) - else - tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j)) - tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2) - end if +!!$ if (present(mask_lowres)) then +!!$ tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j) * mask_lowres(:,j)) +!!$ tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2 * mask_lowres(:,j)) +!!$ else +!!$ tod%scans(scan_id)%d(j)%dgain = sum(s_invsqrtN(:,j) * residual(:,j)) +!!$ tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_invsqrtN(:,j) ** 2) +!!$ end if + tod%scans(scan_id)%d(j)%dgain = sum(r_fill(:) * s_tot(:,j) * mask(:,j)) / tod%scans(scan_id)%d(j)%N_psd%sigma0**2 + tod%scans(scan_id)%d(j)%gain_invsigma = sum(s_tot(:,j) * s_tot(:,j) * mask(:,j)) / tod%scans(scan_id)%d(j)%N_psd%sigma0**2 if (tod%scans(scan_id)%d(j)%gain_invsigma < 0.d0) then write(*,*) 'Warning: Not positive definite invN = ', tod%scanid(scan_id), j, tod%scans(scan_id)%d(j)%gain_invsigma end if @@ -126,23 +128,28 @@ module subroutine calculate_gain_mean_std_per_scan(tod, scan_id, s_invsqrtN, mas if (.false.) then call int2string(tod%scanid(scan_id), itext) !write(*,*) 'gain'//itext//' = ', tod%gain0(0) + tod%gain0(1), tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(1)%gain_invsigma - open(58,file='gain_delta_'//itext//'.dat') - do i = ext(1), ext(2) - write(58,*) i, residual(i,1) - end do - write(58,*) - write(58,*) - do i = 1, size(s_invsqrtN,1) - write(58,*) i, s_invsqrtN(i,1) - end do - write(58,*) - do i = 1, size(s_tot,1) - write(58,*) i, tod_arr(i, 1) - (tod%gain0(0) + tod%gain0(1)) * s_tot(i,1) - end do - write(58,*) - do i = 1, size(s_tot,1) - write(58,*) i, tod_arr(i, 1) + open(58,file='gain_delta_'//itext//'.dat', recl=1024) + write(58,*) "#", tod%scans(scan_id)%ntod, size(tod_arr), tod%gain0(0), tod%gain0(1), tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(1)%gain_invsigma + do i = 1, size(tod_arr) + write(58,*) i, r_fill(i), tod_arr(i,1), s_tot(i,1), mask(i,1) end do + +!!$ do i = ext(1), ext(2) +!!$ write(58,*) i, residual(i,1) +!!$ end do +!!$ write(58,*) +!!$ write(58,*) +!!$ do i = 1, size(s_invsqrtN,1) +!!$ write(58,*) i, s_invsqrtN(i,1) +!!$ end do +!!$ write(58,*) +!!$ do i = 1, size(s_tot,1) +!!$ write(58,*) i, tod_arr(i, 1) - (tod%gain0(0) + tod%gain0(1)) * s_tot(i,1) +!!$ end do +!!$ write(58,*) +!!$ do i = 1, size(s_tot,1) +!!$ write(58,*) i, tod_arr(i, 1) +!!$ end do close(58) end if @@ -255,14 +262,14 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) tod%gain_alpha(j) = -1.d0 ! Physically motivated value tod%gain_fknee(j) = tod%gain_samprate ! makes sigma_0 = true standard devation per sample - !if (j == 1) then - ! open(58,file='gain_in.dat') - ! do k = 1, size(g,1) - ! if (g(k,j,2) > 0) then - ! write(58,*) k, g(k,j,1)/g(k,j,2), 1/sqrt(g(k,j,2)) - ! end if - ! end do - ! close(58) + if (j == 1) then +!!$ open(58,file='gain_in.dat') +!!$ do k = 1, size(g,1) +!!$ if (g(k,j,2) > 0) then +!!$ write(58,*) k, g(k,j,1)/g(k,j,2), 1/sqrt(g(k,j,2)) +!!$ end if +!!$ end do +!!$ close(58) !write(*,*) '| psd = ', tod%gain_sigma_0(j), tod%gain_alpha(j), tod%gain_fknee(j) ! open(68,file='g.unf', form='unformatted') @@ -273,7 +280,7 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) ! write(68) tod%gain_alpha(j) ! write(68) tod%gain_fknee(j) ! close(68) - !end if + end if sample_per_jump = .false. .and. (size(tod%jumplist(j, :)) > 2) if (sample_per_jump) then @@ -288,11 +295,12 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) call wiener_filtered_gain(g(tod%jumplist(j, k):, j, 1), g(tod%jumplist(j, k):, j, 2), & & tod%gain_samprate, tod%gain_sigma_0(j), tod%gain_alpha(j), tod%gain_fknee(j), trim(tod%operation)=='sample', handle) else - call wiener_filtered_gain(g(:, j, 1), g(:, j, 2), tod%gain_samprate, tod%gain_sigma_0(j), tod%gain_alpha(j), & + call wiener_filtered_gain(g(:, j, 1), g(:, j, 2), tod%gain_samprate, 1000*tod%gain_sigma_0(j), tod%gain_alpha(j), & & tod%gain_fknee(j), trim(tod%operation)=='sample', handle) end if - ! Force flat average to zero + ! Force flat average to zero + !write(*,*) 'disabling gain mean subtraction' mu = 0.d0 denom = 0.d0 do k = 1, nscan_tot @@ -307,15 +315,15 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) g(:,j,1) = g(:,j,1) - mu end where - !if (j == 1) then - ! open(58,file='gain_out.dat') - ! do k = 1, size(g,1) - ! if (g(k,j,2) > 0) then - ! write(58,*) k, g(k,j,1), 1/sqrt(g(k,j,2)) - ! end if - ! end do - ! close(58) - !end if + if (j == 1) then +!!$ open(58,file='gain_out.dat') +!!$ do k = 1, size(g,1) +!!$ if (g(k,j,2) > 0) then +!!$ write(58,*) k, g(k,j,1), 1/sqrt(g(k,j,2)) +!!$ end if +!!$ end do +!!$ close(58) + end if end do !!$ call mpi_finalize(ierr) !!$ stop diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index 7b9e5b1eb..1755b5d49 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -65,7 +65,7 @@ module function constructor_lfi(handle, cpar, id, id_abs, info, tod_type) result logical(lgt) :: pol_beam character(len=50) :: name character(len=6) :: itext - character(len=512) :: chainfile, path + character(len=2048) :: chainfile, path type(hdf_file) :: init_file real(dp), dimension(:), allocatable :: nus diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index f3bb8a399..9d97b9d3c 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -385,6 +385,7 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%sample_abs_bp = .false. self%zodiband = -1 self%sol_elong_range = [0., 180.] + self%sample_mono = .false. if (cpar%include_tod_zodi) then self%subtract_zodi = cpar%ds_tod_subtract_zodi(self%band) @@ -2939,7 +2940,312 @@ subroutine clear_zodi_cache(self, obs_time) end if end subroutine clear_zodi_cache - subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) + subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) + implicit none + class(comm_tod), intent(inout) :: self + integer(i4b), intent(in) :: scan, det + real(sp), dimension(:), intent(in) :: res + real(sp), dimension(2), intent(in) :: rms_range + real(sp), dimension(:), intent(inout) :: mask + integer(i4b), dimension(:), intent(inout) :: flag + + integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut + real(dp) :: rms0 + real(sp) :: var0, threshold, gain + logical(lgt), allocatable, dimension(:) :: cut + integer(i4b), allocatable, dimension(:,:) :: bad, buffer + real(sp), allocatable, dimension(:) :: mask_dyn, var_window + + if (sum(mask) == 0) return + + ntod = size(res) + ntot = count(iand(flag,self%flag0) .eq. 0) + nmax = 1000 + gain = self%scans(scan)%d(det)%gain + + ! Generate dynamic mask + allocate(mask_dyn(ntod)) + mask_dyn = 1.0 + + ! Solar-centric mask + ncut = 0 + if (allocated(self%mask_solar) .and. self%use_solar_point) then + do i = 1, ntod + if (mask(i) == 0.) cycle + if (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut+1 + end if + end do + end if + + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + +!!$ open(58, file='var0.dat') +!!$ do i = 1, ntod +!!$ if (mask(i) == 1.) write(58,*) i, res(i) +!!$ end do +!!$ close(58) + + ! Extreme outliers + threshold = 20. ! White noise sigma + ncut = 0 + do i = 1, ntod + if (mask(i) == 1. .and. abs(res(i)) > threshold) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms + allocate(cut(ntod)) + ncut = 0 +! open(58, file='var1.dat') + do iter = 1, 1 + ! Compute full-scan, masked rms0 + rms0 = 0.d0 + n = 0 + do i = 1, ntod + if (mask(i) == 1.) then + rms0 = rms0 + res(i)**2 + n = n + 1 + end if + end do + rms0 = sqrt(rms0/(n-1)) + !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 + + do i = 1, ntod + cut(i) = (mask(i) == 1. .and. (res(i) < rms_range(1)*rms0 .or. res(i) > rms_range(2)*rms0)) + !if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) + end do + + ! Apply RMS selection criterium + if (cut(1) .and. (.not. cut(2) .or. mask(2) == 0.)) then + mask_dyn(1) = 0. + mask(1) = 0. + flag(1) = huge(flag(1)) + ncut = ncut + 1 + end if + do i = 2, ntod-1 + if (cut(i) .and. (.not. cut(i-1) .or. mask(i-1) == 0.) .and. (.not. cut(i+1) .or. mask(i+1) == 0.)) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + if (cut(ntod) .and. (.not. cut(ntod-1) .or. mask(ntod-1) == 0.)) then + mask_dyn(ntod) = 0. + mask(ntod) = 0. + flag(ntod) = huge(flag(ntod)) + ncut = ncut + 1 + end if + end do + !close(58) + deallocate(cut) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically cosmic rays and other short glitches + allocate(var_window(ntod)) + window = 5; threshold = 3. + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + var0 = sqrt(var0) + ncut = 0 + !open(58, file='var2.dat') + do i = 1, ntod + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + !if (mask(k) == 1) then + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + !close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. + window = 50; threshold = 2.0 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 + !open(58, file='var3.dat') + do i = 1, ntod + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + !close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. + window = 500; threshold = 1.5 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 +! open(58, file='var3.dat') + do i = 1, ntod +! if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do +! close(58) + deallocate(var_window) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove isolated samples + ncut = 0 + if (mask(1) == 1. .and. mask(2) == 0.) then + mask_dyn(1) = 0. + mask(1) = 0. + flag(1) = huge(flag(1)) + ncut = ncut + 1 + end if + do i = 2, ntod-1 + if (mask(i-1) == 0. .and. mask(i) == 1. .and. mask(i+1) == 0.) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + if (mask(ntod) == 1. .and. mask(ntod-1) == 0.) then + mask_dyn(ntod) = 0. + mask(ntod) = 0. + flag(ntod) = huge(flag(ntod)) + ncut = ncut + 1 + end if +! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove consecutive chunks with many flagged samples + window = 2000; threshold = 0.30 + ncut = 0 +! open(58, file='var4.dat') + do i = 1, ntod +! write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 + j = max(i-window,1) + k = min(i+window,ntod) + if (count(flag(j:k) == huge(flag(1)))/real(k-j+1,sp) > threshold) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do +! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + ! Remove glitches in the high signal-to-noise regime + ! Must 1) be a masked pixel; 2) not already be flagged; 3) have a S/N > 10; 4) have a residual larger than some threshold times the expected signal +!!$ threshold = 0.50 +!!$ ncut = 0 +!!$ do i = 1, ntod +!!$ +!!$ if (mask(i) == 0. .and. iand(flag(i),self%flag0) .eq. 0 .and. abs(gain*s_sky(i)) > 10.d0 * self%scans(scan)%d(det)%N_psd%sigma0 .and. abs(res(i)) > threshold*abs(gain*s_sky(i))) then +!!$ mask_dyn(i) = 0. +!!$ mask(i) = 0. +!!$ flag(i) = huge(flag(i)) +!!$ ncut = ncut + 1 +!!$ end if +!!$ end do +!!$ write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, high S/N -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + + + !mask_dyn(1:330000) = 0. + !mask(1:330000) = 0. + !mask_dyn(1:550000) = 0. + !mask(1:550000) = 0. + !mask_dyn(575000:) = 0. + !mask(575000:) = 0. + !flag(1:550000) = huge(flag(1)) + !flag(575000:) = huge(flag(1)) + +!!$ open(58, file='var5.dat') +!!$ do i = 1, ntod +!!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) +!!$ end do +!!$ close(58) + + ! Compress and store dynamic mask + allocate(bad(2,nmax)) + bad = -1 + n = 0 + do i = 1, ntod + if (mask_dyn(i) == 0.) then + ! Start new range if not already active + if (bad(1,n+1) == -1) bad(1,n+1) = i + else + ! Close active range + if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then + bad(2,n+1) = i-1 + n = n+1 + end if + end if + + ! Increase array size if needed + if (n == nmax) then + nmax = 2*nmax + allocate(buffer(2,nmax)) + buffer = -1 + buffer(:,1:nmax/2) = bad + deallocate(bad) + allocate(bad(2,nmax)) + bad = buffer + deallocate(buffer) + end if + end do + + ! Close open range if needed at the end + if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then + bad(2,n+1) = ntod + n = n+1 + end if + + ! Store final array + if (n > 0) then + allocate(self%scans(scan)%d(det)%mask_dyn(2,n)) + self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(mask_dyn == 0),sp) / ntot, count(mask_dyn==0), ntot + end if + + deallocate(bad, mask_dyn) + end subroutine create_dynamic_mask + + subroutine create_dynamic_mask2(self, scan, det, res, rms_range, mask) implicit none class(comm_tod), intent(inout) :: self integer(i4b), intent(in) :: scan, det @@ -3043,6 +3349,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask) ! if (allocated(mask_solar)) deallocate(mask_solar) end subroutine + subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) implicit none class(comm_tod), intent(in) :: tod diff --git a/commander3/src/comm_zodi_comp_mod.f90 b/commander3/src/comm_zodi_comp_mod.f90 index 3131d3c0f..a1f042174 100644 --- a/commander3/src/comm_zodi_comp_mod.f90 +++ b/commander3/src/comm_zodi_comp_mod.f90 @@ -231,7 +231,8 @@ subroutine init_cloud_priors_and_scales(self, start_ind, prior, scale) scale(start_ind+1,:) = [1.d0, 0.03d0] prior(:,start_ind+2) = [-720.d0, 720.d0, 0.d0, -1.d0] ! Omega scale(start_ind+2,:) = [1.d0, 0.3d0] - prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 + !prior(:,start_ind+3) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! X_0 + prior(:,start_ind+3) = [-0.04d0, 0.04d0, 0.d0, -1.d0] ! ! X_0 scale(start_ind+3,:) = [1.d0, 1d-3] prior(:,start_ind+4) = [-0.02d0, 0.02d0, 0.d0, -1.d0] ! ! Y_0 scale(start_ind+4,:) = [1.d0, 0.8d-3] @@ -273,9 +274,11 @@ subroutine init_band_priors_and_scales(self, start_ind, prior, scale) scale(start_ind+6,:) = [1.d0, 0.14d0] prior(:,start_ind+7) = [0.8d0, 5.4d0, 4.14d0, -1.d0] ! delta_r scale(start_ind+7,:) = [1.d0, 0.005d0] - prior(:,start_ind+8) = [0.01d0, 1.5d0, 0.942d0, -1.d0] ! v + !prior(:,start_ind+8) = [0.01d0, 1.5d0, 0.942d0, -1.d0] ! v + prior(:,start_ind+8) = [0.01d0, 3.d0, 0.942d0, -1.d0] ! v scale(start_ind+8,:) = [1.d0, 0.1d0] - prior(:,start_ind+9) = [3.99999d0, 4.000001d0, 0.189d0, -1.d0] ! p + !prior(:,start_ind+9) = [3.99999d0, 4.000001d0, 0.189d0, -1.d0] ! p + prior(:,start_ind+9) = [2.d0, 6.d0, 0.189d0, -1.d0] ! p scale(start_ind+9,:) = [1.d0, 1d-6] end subroutine init_band_priors_and_scales diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index cab608ded..6288d19c4 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -755,7 +755,7 @@ subroutine comp_from_chain(self, cpar, params, comp_idx) type(hdf_file) :: file character(len=32), allocatable :: param_labels(:) - character(len=512) :: chainfile, group_name + character(len=2048) :: chainfile, group_name if (cpar%myid == cpar%root) then if (trim(cpar%zs_init_hdf(comp_idx)) == 'default') then @@ -939,7 +939,7 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) integer(i4b), dimension(:), intent(inout) :: stat integer(i4b) :: i, c, j, k, first, last, n_params, n, m, ind, em_global, al_global, c_to, c_from, band - character(len=128) :: tokens(100), comp_param(2), wire_from(2), wire_to(2), label, param_label_tokens(10), em_from(2), em_to(2) + character(len=128) :: tokens(100), comp_param(2), wire_from(2), wire_to(2), label, param_label_tokens(10), em_from(2), em_to(2), al_from(2), al_to(2) character(len=2048) :: str ! Default: Fix everything at input @@ -1100,6 +1100,26 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) c_to = zodi_model%get_par_ind(comp_str=wire_to(1), em_string=em_to(2)) stat(c_from) = c_to end if + else if (trim(wire_from(2)(1:2)) == 'al') then + call get_tokens(wire_from(2), '@', al_from, num=n) + call get_tokens(wire_to(2), '@', al_to, num=n) + if (n == 1) then + ! Attach all bands + do c = 1, numband + if (.not. active(c)) cycle + c_from = zodi_model%get_par_ind(comp_str=wire_from(1), al_band=c) + c_to = zodi_model%get_par_ind(comp_str=wire_to(1), al_band=c) + stat(c_from) = c_to + end do + else + ! Attach specified band + j = get_string_index(band_labels, al_from(2)) + k = get_string_index(band_labels, al_to(2)) + if (.not. active(j) .or. .not. active(k)) cycle + c_from = zodi_model%get_par_ind(comp_str=wire_from(1), al_string=al_from(2)) + c_to = zodi_model%get_par_ind(comp_str=wire_to(1), al_string=al_to(2)) + stat(c_from) = c_to + end if else write(*,*) 'Unsupported zodi wire = ', trim(tokens(i)) stop @@ -1635,7 +1655,7 @@ subroutine read_tod_zodi_params(cpar, model, tod) type(hdf_file) :: file real(dp) :: lambda, lambda_min, lambda_max real(dp), allocatable :: emissivity(:), albedo(:) - character(len=512) :: chainfile, emissivity_path, albedo_path, band_path, comp_path, tod_path, group_name + character(len=2048) :: chainfile, emissivity_path, albedo_path, band_path, comp_path, tod_path, group_name !allocate(tod%zodi_emissivity(tod%zodi_n_comps)) !allocate(tod%zodi_albedo(tod%zodi_n_comps)) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 2e869dc83..73c75ae9f 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -737,7 +737,7 @@ subroutine downsamp_invariant_structs(cpar) tod = data(i)%tod%scans(scan)%d(j)%tod end if call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static, pix_static=data(i)%tod%scans(scan)%d(j)%pix_sol) - tod = tod - s_static + tod = tod - data(i)%tod%scans(scan)%d(j)%gain * s_static do k = 1, data(i)%tod%scans(scan)%ntod mask(k) = procmask_zodi(pix(k, 1)) @@ -1068,7 +1068,7 @@ subroutine create_zodi_glitch_mask(cpar, handle) if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle ! Search for strong outliers - res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%downsamp_sky - data(i)%tod%scans(scan)%d(j)%downsamp_zodi + res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%gain * (data(i)%tod%scans(scan)%d(j)%downsamp_sky + data(i)%tod%scans(scan)%d(j)%downsamp_zodi) rms = sqrt(mean(real(res**2, dp))) data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask = abs(res) > 10. * real(rms, sp) frac = count(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask)/real(size(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask),dp) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 233f02c8f..00ec09ad5 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -382,7 +382,9 @@ program commander end select ! Sample stationary zodi components with 2D model - call sample_static_zodi_map(cpar, handle) + if (.false.) then + call sample_static_zodi_map(cpar, handle) + end if !call sample_static_zodi_amps(cpar, handle) !!$ if (mod(iter-2,10) == 0) then diff --git a/commander3/src/math_tools.f90 b/commander3/src/math_tools.f90 index d3ea49023..10d3ab4e7 100644 --- a/commander3/src/math_tools.f90 +++ b/commander3/src/math_tools.f90 @@ -33,6 +33,10 @@ module math_tools interface convert_fract2sigma module procedure convert_fract2sigma_sp, convert_fract2sigma_dp + end interface convert_fract2sigma + + interface compute_running_variance + module procedure compute_running_variance_sp, compute_running_variance_dp end interface contains @@ -1695,5 +1699,166 @@ function calc_linear_regression(x_arr, y_arr, n_lim) end function calc_linear_regression + subroutine compute_running_variance_sp(x, mask, window, variance, var_mean) + implicit none + real(sp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(sp), dimension(:), intent(out) :: variance + real(sp), intent(out), optional :: var_mean + + integer(i4b) :: i, j, k, l, n, m + real(sp) :: mu + !integer(i4b), allocatable, dimension(:) :: m + + n = size(x) + + do i = 1, n + j = max(i-window,1) + k = min(i+window,n) + variance(i) = 0. + mu = 0. + m = 0 + do l = j, k + if (mask(l) == 1.) then + mu = mu + x(l) + m = m + 1 + end if + end do + if (m < 3) then + variance(i) = 0. + else + mu = mu / m + do l = j, k + if (mask(l) == 1.) then + variance(i) = variance(i) + (x(l) - mu)**2 + end if + end do + variance(i) = variance(i) / (m-1) + end if + end do + +!!$ allocate(m(n)) +!!$ variance(1) = 0.d0 +!!$ m = 0 +!!$ do j = 1, window +!!$ if (mask(j) == 1.d0) then +!!$ variance(1) = variance(1) + x(j)**2 +!!$ m(1) = m(1) + 1 +!!$ end if +!!$ end do +!!$ +!!$ ! Compute running mean variance +!!$ do i = 2, n +!!$ variance(i) = variance(i-1) +!!$ m(i) = m(i-1) +!!$ k = i-window +!!$ if (k > 0) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) - x(k)**2 +!!$ m(i) = m(i) - 1 +!!$ end if +!!$ end if +!!$ k = i+window +!!$ if (k <= n) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) + x(k)**2 +!!$ m(i) = m(i) + 1 +!!$ end if +!!$ end if +!!$ end do +!!$ do i = 1, n +!!$ if (m(i) > 2) then +!!$ variance(i) = variance(i) / (m(i) - 1.d0) +!!$ else +!!$ variance(i) = 0.d0 +!!$ end if +!!$ end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0 .and. variance(i) > 0.) then + var_mean = var_mean + variance(i) + j = j+1 + !write(*,*) i, var_mean, j, var_mean/j + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + !deallocate(m) + + end subroutine compute_running_variance_sp + + + + subroutine compute_running_variance_dp(x, mask, window, variance, var_mean) + implicit none + real(dp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(dp), dimension(:), intent(out) :: variance + real(dp), intent(out), optional :: var_mean + + integer(i4b) :: i, j, k, n + integer(i4b), allocatable, dimension(:) :: m + + n = size(x) + + allocate(m(n)) + variance(1) = 0.d0 + m = 0 + do j = 1, window + if (mask(j) == 1.d0) then + variance(1) = variance(1) + x(j)**2 + m(1) = m(1) + 1 + end if + end do + + ! Compute running mean variance + do i = 2, n + variance(i) = variance(i-1) + m(i) = m(i-1) + k = i-window + if (k > 0) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) - x(k)**2 + m(i) = m(i) - 1 + end if + end if + k = i+window + if (k <= n) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) + x(k)**2 + m(i) = m(i) + 1 + end if + end if + end do + do i = 1, n + if (m(i) > 2) then + variance(i) = variance(i) / (m(i) - 1.d0) + else + variance(i) = 0.d0 + end if + end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0) then + var_mean = var_mean + variance(i) + j = j+1 + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + deallocate(m) + + end subroutine compute_running_variance_dp + end module math_tools From afe2ccd3618576122f9e2a7f117bedb427161cd0 Mon Sep 17 00:00:00 2001 From: Luca Zapelli Date: Thu, 20 Feb 2025 17:33:19 +0100 Subject: [PATCH 108/171] fixed sd/dd deallocation and d_calib init --- commander3/src/comm_tod_driver_mod.f90 | 22 +++++++++++++++------- commander3/src/comm_tod_hfi_mod.f90 | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index c80623ba3..b3209cc34 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -616,9 +616,16 @@ subroutine dealloc_scan_data(sd) sd%ntod = -1; sd%ndet = -1; sd%nhorn = -1 ! Deallocate data structures - deallocate(sd%tod, sd%n_corr, sd%s_sl, sd%s_sky) - deallocate(sd%s_orb, sd%s_tot, sd%mask) - deallocate(sd%pix, sd%psi, sd%flag) + if (allocated(sd%tod)) deallocate(sd%tod) + if (allocated(sd%n_corr)) deallocate(sd%n_corr) + if (allocated(sd%s_sl)) deallocate(sd%s_sl) + if (allocated(sd%s_sky)) deallocate(sd%s_sky) + if (allocated(sd%s_orb)) deallocate(sd%s_orb) + if (allocated(sd%s_tot)) deallocate(sd%s_tot) + if (allocated(sd%mask)) deallocate(sd%mask) + if (allocated(sd%pix)) deallocate(sd%pix) + if (allocated(sd%psi)) deallocate(sd%psi) + if (allocated(sd%flag)) deallocate(sd%flag) if (allocated(sd%s_sky_prop)) deallocate(sd%s_sky_prop) if (allocated(sd%s_bp_prop)) deallocate(sd%s_bp_prop) if (allocated(sd%s_bp)) deallocate(sd%s_bp) @@ -636,7 +643,7 @@ subroutine dealloc_scan_data(sd) if (allocated(sd%s_gain)) deallocate(sd%s_gain) if (allocated(sd%s_gainA)) deallocate(sd%s_gainA) if (allocated(sd%s_gainB)) deallocate(sd%s_gainB) - + if (allocated(sd%dark)) deallocate(sd%dark) end subroutine dealloc_scan_data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -649,9 +656,9 @@ subroutine dealloc_det_data(dd) class(comm_detdata), intent(inout) :: dd dd%nscan = -1 - deallocate(dd%scans) - deallocate(dd%ntod) - deallocate(dd%tod) + if (allocated(dd%scans)) deallocate(dd%scans) + if (allocated(dd%ntod)) deallocate(dd%ntod) + if (allocated(dd%tod)) deallocate(dd%tod) end subroutine dealloc_det_data @@ -1074,6 +1081,7 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) end do end do + call timer%stop(TOD_MAPBIN, tod%band) end subroutine compute_calibrated_data diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index cc3893153..7ea8ebd11 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -452,6 +452,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Compute calibrated TOD for mapmaking allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) + d_calib = 0.d0 call compute_calibrated_data(self, i, sd, d_calib) ! Bin TOD From 00116d17428804ab1adfe4ae2e7414fd71b609ed Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 21 Feb 2025 10:43:25 +0100 Subject: [PATCH 109/171] Reorganized --- .../dirbe/{metin => archive}/__init__.py | 0 .../_write_dirbe_instrumentfile_old.py | 0 .../{ => archive}/_write_filelists_old.py | 0 .../dirbe/{ => archive}/bin_dirbe_tods.py | 0 .../dirbe/{ => archive}/detect_planets.py | 0 .../todscripts/dirbe/archive/dirbe_utils.py | 319 +++++++++++ .../dirbe/{ => archive}/gustav/DIRBE_Calls.py | 0 .../{ => archive}/gustav/DIRBE_FITS2HDF5.py | 0 .../{ => archive}/gustav/DIRBE_Functions.py | 0 .../gustav/DIRBE_Plotting_and_Figures.py | 0 .../DIRBE_Unused_and_Unfinished_Functions.py | 0 .../dirbe/{ => archive}/gustav/run_dirbe.py | 0 .../dirbe/{ => archive}/make_dirbe_rimo.py | 0 .../dirbe/{ => archive}/res15_to_hpx.py | 0 .../todscripts/dirbe/{ => archive}/tods.fits | Bin .../{ => archive}/write_instrumentfile.py | 0 .../write_instrumentfile_delta.py | 0 .../dirbe/{ => archive}/write_tods.py | 0 .../dirbe/{ => archive}/write_tods_new.py | 0 .../todscripts/dirbe/{ => archive}/zodi.fits | Bin .../todscripts/dirbe/{ => archive}/zodi2.fits | Bin commander3/todscripts/dirbe/dirbe_utils.py | 409 ++++++++++---- .../todscripts/dirbe/metin/dirbe_utils.py | 522 ------------------ .../todscripts/dirbe/{metin => }/pointing.py | 0 .../todscripts/dirbe/{metin => }/read_data.py | 0 .../{metin => }/write_instrument_final.py | 0 .../dirbe/{metin => }/write_tods_final.py | 0 27 files changed, 625 insertions(+), 625 deletions(-) rename commander3/todscripts/dirbe/{metin => archive}/__init__.py (100%) rename commander3/todscripts/dirbe/{ => archive}/_write_dirbe_instrumentfile_old.py (100%) rename commander3/todscripts/dirbe/{ => archive}/_write_filelists_old.py (100%) rename commander3/todscripts/dirbe/{ => archive}/bin_dirbe_tods.py (100%) rename commander3/todscripts/dirbe/{ => archive}/detect_planets.py (100%) create mode 100644 commander3/todscripts/dirbe/archive/dirbe_utils.py rename commander3/todscripts/dirbe/{ => archive}/gustav/DIRBE_Calls.py (100%) rename commander3/todscripts/dirbe/{ => archive}/gustav/DIRBE_FITS2HDF5.py (100%) rename commander3/todscripts/dirbe/{ => archive}/gustav/DIRBE_Functions.py (100%) rename commander3/todscripts/dirbe/{ => archive}/gustav/DIRBE_Plotting_and_Figures.py (100%) rename commander3/todscripts/dirbe/{ => archive}/gustav/DIRBE_Unused_and_Unfinished_Functions.py (100%) rename commander3/todscripts/dirbe/{ => archive}/gustav/run_dirbe.py (100%) rename commander3/todscripts/dirbe/{ => archive}/make_dirbe_rimo.py (100%) rename commander3/todscripts/dirbe/{ => archive}/res15_to_hpx.py (100%) rename commander3/todscripts/dirbe/{ => archive}/tods.fits (100%) rename commander3/todscripts/dirbe/{ => archive}/write_instrumentfile.py (100%) rename commander3/todscripts/dirbe/{ => archive}/write_instrumentfile_delta.py (100%) rename commander3/todscripts/dirbe/{ => archive}/write_tods.py (100%) rename commander3/todscripts/dirbe/{ => archive}/write_tods_new.py (100%) rename commander3/todscripts/dirbe/{ => archive}/zodi.fits (100%) rename commander3/todscripts/dirbe/{ => archive}/zodi2.fits (100%) delete mode 100644 commander3/todscripts/dirbe/metin/dirbe_utils.py rename commander3/todscripts/dirbe/{metin => }/pointing.py (100%) rename commander3/todscripts/dirbe/{metin => }/read_data.py (100%) rename commander3/todscripts/dirbe/{metin => }/write_instrument_final.py (100%) rename commander3/todscripts/dirbe/{metin => }/write_tods_final.py (100%) diff --git a/commander3/todscripts/dirbe/metin/__init__.py b/commander3/todscripts/dirbe/archive/__init__.py similarity index 100% rename from commander3/todscripts/dirbe/metin/__init__.py rename to commander3/todscripts/dirbe/archive/__init__.py diff --git a/commander3/todscripts/dirbe/_write_dirbe_instrumentfile_old.py b/commander3/todscripts/dirbe/archive/_write_dirbe_instrumentfile_old.py similarity index 100% rename from commander3/todscripts/dirbe/_write_dirbe_instrumentfile_old.py rename to commander3/todscripts/dirbe/archive/_write_dirbe_instrumentfile_old.py diff --git a/commander3/todscripts/dirbe/_write_filelists_old.py b/commander3/todscripts/dirbe/archive/_write_filelists_old.py similarity index 100% rename from commander3/todscripts/dirbe/_write_filelists_old.py rename to commander3/todscripts/dirbe/archive/_write_filelists_old.py diff --git a/commander3/todscripts/dirbe/bin_dirbe_tods.py b/commander3/todscripts/dirbe/archive/bin_dirbe_tods.py similarity index 100% rename from commander3/todscripts/dirbe/bin_dirbe_tods.py rename to commander3/todscripts/dirbe/archive/bin_dirbe_tods.py diff --git a/commander3/todscripts/dirbe/detect_planets.py b/commander3/todscripts/dirbe/archive/detect_planets.py similarity index 100% rename from commander3/todscripts/dirbe/detect_planets.py rename to commander3/todscripts/dirbe/archive/detect_planets.py diff --git a/commander3/todscripts/dirbe/archive/dirbe_utils.py b/commander3/todscripts/dirbe/archive/dirbe_utils.py new file mode 100644 index 000000000..ebab5ee29 --- /dev/null +++ b/commander3/todscripts/dirbe/archive/dirbe_utils.py @@ -0,0 +1,319 @@ +from __future__ import annotations +from typing import Sequence + +from functools import cache + +from astropy.io import fits +import astropy.units as u +from astropy.time import Time, TimeDelta +from datetime import datetime +import numpy as np +from numpy.typing import NDArray +import re + +import healpy as hp +from astropy.coordinates import get_body, HeliocentricMeanEcliptic +from scipy import interpolate + + +DIRBE_SKYMAP_INFO = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/DIRBE_SKYMAP_INFO.FITS" +DIRBE_BANDPASSES = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/bandpass/DIRBE_SYSTEM_SPECTRAL_RESPONSE_TABLE.ASC" +DIRBE_BEAM = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/beams/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" +DIRBE_POS_PATH = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/position/" +DIRBE_POS_FILES = [ + "dmr_anc_spcl_89328_89356.txt", + "dmr_anc_89356_90021.txt", + "dmr_anc_90021_90051.txt", + "dmr_anc_90081_90111.txt", + "dmr_anc_90111_90141.txt", + "dmr_anc_90171_90206.txt", + "dmr_anc_90206_90236.txt", + "dmr_anc_90266_90296.txt", + "dmr_anc_90296_90326.txt", + "dmr_anc_90356_91021.txt", + "dmr_anc_90051_90081.txt", + "dmr_anc_90141_90171.txt", + "dmr_anc_90236_90266.txt", + "dmr_anc_90326_90356.txt", + ] + +BANDS = range(1,11) +DIRBE_START_DATE = Time(datetime(1989, 12, 11)) +DETECTOR_LABELS = ("A", "B", "C") +WAVELENGHTS = (1.25, 2.2, 3.5, 4.9, 12, 25, 60, 100, 140, 240) +DETECTORS = [ + "1A", + "1B", + "1C", + "2A", + "2B", + "2C", + "3A", + "3B", + "3C", + "4", + "5", + "6", + "7", + "8", + "9", + "10", +] + +BAND_TO_WAVELENGTH: dict[int, float] = { + 1: 1.25, + 2: 2.2, + 3: 3.5, + 4: 4.9, + 5: 12, + 6: 25, + 7: 60, + 8: 100, + 9: 140, + 10: 240, +} + +BODIES = { + "moon": 10, + "mercury": 1, + "venus": 2, + "mars": 2, + "jupiter": 2, + "saturn": 1, + "uranus": 1, + "neptune": 1, +} + + +def get_flag_sum(*flag_bits: int) -> int: + return sum([2**bit for bit in flag_bits]) + + +def pix_to_lonlat( + pixels: int | Sequence[int] | NDArray[np.integer], +) -> tuple[float, float] | NDArray[np.integer]: + """Returns the lon lat pairs for DIRBE QUADCUBE pixels indices.""" + + with fits.open(DIRBE_SKYMAP_INFO) as file: + latitudes = file[1].data["ELAT-CSC"][pixels] + longitudes = file[1].data["ELON-CSC"][pixels] + + if np.isscalar(pixels): + return latitudes, longitudes + + return np.column_stack((latitudes, longitudes)) + +def normalize_dirbe_bandpasses( + bandpasses: NDArray[np.floating], +) -> NDArray[np.floating]: + """Normalizes the dirbe_bandpasses so that the sum of the weights is 1.""" + + return bandpasses / np.expand_dims(bandpasses.sum(axis=1), axis=1) + +@cache +def get_dirbe_bandpass(normalized: bool = True) -> tuple[NDArray[np.floating], NDArray[np.floating]]: + """Returns the DIRBE bandpasses.""" + + wavelengths, *bandpasses = np.loadtxt(DIRBE_BANDPASSES, skiprows=15, unpack=True) + + wavelengths = np.asarray(wavelengths) + bandpasses = np.asarray(bandpasses) + + if normalized: + return wavelengths, normalize_dirbe_bandpasses(bandpasses) + + return wavelengths, bandpasses + +@cache +def get_dirbe_fwhm() -> dict[str, float]: + """Returns a dictionary mapping the DIRBE bands to FWHM in radians.""" + + ROWS_TO_SKIP = 19 + FWHM_COL = 4 + + fwhms: dict[str, float] = {} + with open(DIRBE_BEAM, "r") as file: + for line in file.readlines()[ROWS_TO_SKIP:]: + cols = line.split() + detector, band = re.match(r"(\d+)([A-C]?)", cols[0], re.I).groups() + band_label = f"{int(detector):02}_{band}" if band else f"{int(detector):02}_A" + if len(cols) > FWHM_COL: + fwhm = np.sqrt(float(cols[FWHM_COL])) * u.rad + fwhm_arcmin = fwhm.to(u.arcmin).value + fwhms[band_label] = np.round(fwhm_arcmin, 2) + + return fwhms + +@cache +def get_dirbe_beams() -> dict[str, NDArray[np.floating]]: + """ + Returns a dictionary mapping the DIRBE bands to beams. + NOTE: Currently only returns a sequence of 0's. + """ + NSIDE = 128 + LMAX = 3 * NSIDE + N_ALMS = LMAX**2 + 2*LMAX +1 + DEFAULT_BEAM = np.zeros((3, N_ALMS)) # Update this with actual beams + + beams: dict[str, NDArray[np.floating]] = {} + for detector in range(1,11): + if detector <= 3: + for band in DETECTOR_LABELS: + beams[f"{detector:02}_{band}"] = DEFAULT_BEAM + else: + beams[f"{detector:02}_A"] = DEFAULT_BEAM + + return beams + +@cache +def get_dirbe_sidelobes() -> dict[str, NDArray[np.floating]]: + """ + Returns a dictionary mapping the DIRBE bands to sidelobes. + NOTE: We dont have dirbe sidelobes so we just returns a sequence of 0's. + """ + NSIDE = 128 + LMAX = 3 * NSIDE + N_ALMS = LMAX**2 + 2*LMAX +1 + DEFAULT_SIDELOBES = np.zeros((3,N_ALMS)) # Update this with actual sidelobes + + sidelobes: dict[str, NDArray[np.floating]] = {} + for detector in range(1,11): + if detector <= 3: + for band in DETECTOR_LABELS: + sidelobes[f"{detector:02}_{band}"] = DEFAULT_SIDELOBES + else: + sidelobes[f"{detector:02}_A"] = DEFAULT_SIDELOBES + + return sidelobes + +@cache +def get_dmrfile_mjd_times(filename: str) -> NDArray[np.floating]: + """Duncans script dont really know what goes on here.""" + + data = np.loadtxt(DIRBE_POS_PATH + filename) + adt = data[:,:2] + i4max = 4.294967296e9 + t_adt = np.zeros_like(adt[:,0]) + ind = adt[:,0] >= 0 + t_adt[ind] = adt[ind,0] + i4max*adt[ind,1] + ind = adt[:,0] < 0 + t_adt[ind] = i4max + adt[ind,0] + i4max*adt[ind,1] + t_adt = t_adt*(100*u.ns) + t_adt_d = t_adt.to('day').value # in MJD + + return t_adt_d + +@cache +def get_dmrfile_positions(filename: str) -> NDArray[np.floating]: + return np.loadtxt(DIRBE_POS_PATH + filename, usecols=[5,6,7]) + +@cache +def dirbe_day_to_dmr_day(days: int) -> datetime: + """Returns the dmr_day from dirbe_day""" + + dirbe_date = DIRBE_START_DATE + TimeDelta(days - 1, format="jd") + + # datetime doesnt support leap seconds so we need to do some tricks + dirbe_date_iso = dirbe_date.to_value(format="iso",subfmt="date_hm") + + return datetime.strptime(dirbe_date_iso, "%Y-%m-%d %H:%M") + +@cache +def get_dmrfile_datetimes(filename: str) -> tuple[datetime, datetime]: + """Returns datetime objects for the start and stop days in the dmr files.""" + + regex_groups = re.search(r"(\d{2})(\d+)_(\d{2})(\d+)", filename).groups() + year_one, yday_one, year_two, yday_two = regex_groups + + start_date = datetime.strptime(f'19{year_one} {yday_one}', '%Y %j') + stop_date = datetime.strptime(f'19{year_two} {yday_two}', '%Y %j') + + return start_date, stop_date + +def get_sat_and_earth_pos( + day: int, dirbe_time: float +) -> tuple[NDArray[np.floating], NDArray[np.floating]]: + """dmr_cio_91206-91236.fits contains data from day 206 of 1991 to day 236 of 1991).""" + + dmr_day = dirbe_day_to_dmr_day(day) + + for file in DIRBE_POS_FILES: + start_date, stop_date = get_dmrfile_datetimes(file) + if start_date <= dmr_day <= stop_date: + dmr_file = file + break + else: + raise FileNotFoundError( + f"could not find file containing sat pos for {dmr_day=}" + ) + + dmr_times = get_dmrfile_mjd_times(dmr_file) + dmr_positions = get_dmrfile_positions(dmr_file) + + interpolator_sat_x = interpolate.interp1d( + dmr_times, dmr_positions[:, 0], fill_value="extrapolate" + ) + interpolator_sat_y = interpolate.interp1d( + dmr_times, dmr_positions[:, 1], fill_value="extrapolate" + ) + interpolator_sat_z = interpolate.interp1d( + dmr_times, dmr_positions[:, 2], fill_value="extrapolate" + ) + + pos_x = interpolator_sat_x(dirbe_time) + pos_y = interpolator_sat_y(dirbe_time) + pos_z = interpolator_sat_z(dirbe_time) + + celestial_sat_pos = u.Quantity([pos_x, pos_y, pos_z], u.m).to(u.AU).value + + rotator = hp.Rotator(coord=["C", "E"]) + geocentric_ecl_sat_pos = u.Quantity(rotator(celestial_sat_pos), u.AU).transpose() + + earth_pos = get_body("earth", Time(dirbe_time, format="mjd")).transform_to( + HeliocentricMeanEcliptic + ) + earth_pos = earth_pos.cartesian.xyz.to(u.AU).transpose() + + ecl_sat_pos = earth_pos + geocentric_ecl_sat_pos + + return ecl_sat_pos.value, earth_pos.value + +@cache +def get_bandpass(band: int) -> tuple[u.Quantity[u.micron], NDArray[np.float64]]: + bandpass_file = BANDPASS_PATH / f"DIRBE_{band:02}_bandpass.dat" + bandpass = np.loadtxt(bandpass_file, unpack=True) + + non_zero = np.nonzero(bandpass[1]) + bandpass = bandpass[:, non_zero[0]] + freqs, weights = bandpass + freqs *= u.micron + + return freqs, weights + + +@cache +def get_iras_factor(band: int) -> float: + freqs, weights = get_bandpass(band) + freq_ref = BAND_TO_WAVELENGTH[band] + freqs = freqs.to(u.Hz, u.spectral()) + freqs = np.flip(freqs) + weights = np.flip(weights) + weights /= np.trapz(weights, freqs.value) + return np.trapz( + weights * ((freq_ref * u.micron).to(u.Hz, u.spectral()).value / freqs.value), + freqs.value, + ) + + +def test_naming() -> None: + import h5py + with h5py.File("test.h5", "w") as file: + for detector in BANDS: + file.create_group(f"{detector:02}_{WAVELENGHTS[detector - 1]}um") + for band in DETECTOR_LABELS: + file.create_group(f"{detector:02}_{band}") + if detector > 3: + break + +if __name__ == "__main__": + ... \ No newline at end of file diff --git a/commander3/todscripts/dirbe/gustav/DIRBE_Calls.py b/commander3/todscripts/dirbe/archive/gustav/DIRBE_Calls.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/DIRBE_Calls.py rename to commander3/todscripts/dirbe/archive/gustav/DIRBE_Calls.py diff --git a/commander3/todscripts/dirbe/gustav/DIRBE_FITS2HDF5.py b/commander3/todscripts/dirbe/archive/gustav/DIRBE_FITS2HDF5.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/DIRBE_FITS2HDF5.py rename to commander3/todscripts/dirbe/archive/gustav/DIRBE_FITS2HDF5.py diff --git a/commander3/todscripts/dirbe/gustav/DIRBE_Functions.py b/commander3/todscripts/dirbe/archive/gustav/DIRBE_Functions.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/DIRBE_Functions.py rename to commander3/todscripts/dirbe/archive/gustav/DIRBE_Functions.py diff --git a/commander3/todscripts/dirbe/gustav/DIRBE_Plotting_and_Figures.py b/commander3/todscripts/dirbe/archive/gustav/DIRBE_Plotting_and_Figures.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/DIRBE_Plotting_and_Figures.py rename to commander3/todscripts/dirbe/archive/gustav/DIRBE_Plotting_and_Figures.py diff --git a/commander3/todscripts/dirbe/gustav/DIRBE_Unused_and_Unfinished_Functions.py b/commander3/todscripts/dirbe/archive/gustav/DIRBE_Unused_and_Unfinished_Functions.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/DIRBE_Unused_and_Unfinished_Functions.py rename to commander3/todscripts/dirbe/archive/gustav/DIRBE_Unused_and_Unfinished_Functions.py diff --git a/commander3/todscripts/dirbe/gustav/run_dirbe.py b/commander3/todscripts/dirbe/archive/gustav/run_dirbe.py similarity index 100% rename from commander3/todscripts/dirbe/gustav/run_dirbe.py rename to commander3/todscripts/dirbe/archive/gustav/run_dirbe.py diff --git a/commander3/todscripts/dirbe/make_dirbe_rimo.py b/commander3/todscripts/dirbe/archive/make_dirbe_rimo.py similarity index 100% rename from commander3/todscripts/dirbe/make_dirbe_rimo.py rename to commander3/todscripts/dirbe/archive/make_dirbe_rimo.py diff --git a/commander3/todscripts/dirbe/res15_to_hpx.py b/commander3/todscripts/dirbe/archive/res15_to_hpx.py similarity index 100% rename from commander3/todscripts/dirbe/res15_to_hpx.py rename to commander3/todscripts/dirbe/archive/res15_to_hpx.py diff --git a/commander3/todscripts/dirbe/tods.fits b/commander3/todscripts/dirbe/archive/tods.fits similarity index 100% rename from commander3/todscripts/dirbe/tods.fits rename to commander3/todscripts/dirbe/archive/tods.fits diff --git a/commander3/todscripts/dirbe/write_instrumentfile.py b/commander3/todscripts/dirbe/archive/write_instrumentfile.py similarity index 100% rename from commander3/todscripts/dirbe/write_instrumentfile.py rename to commander3/todscripts/dirbe/archive/write_instrumentfile.py diff --git a/commander3/todscripts/dirbe/write_instrumentfile_delta.py b/commander3/todscripts/dirbe/archive/write_instrumentfile_delta.py similarity index 100% rename from commander3/todscripts/dirbe/write_instrumentfile_delta.py rename to commander3/todscripts/dirbe/archive/write_instrumentfile_delta.py diff --git a/commander3/todscripts/dirbe/write_tods.py b/commander3/todscripts/dirbe/archive/write_tods.py similarity index 100% rename from commander3/todscripts/dirbe/write_tods.py rename to commander3/todscripts/dirbe/archive/write_tods.py diff --git a/commander3/todscripts/dirbe/write_tods_new.py b/commander3/todscripts/dirbe/archive/write_tods_new.py similarity index 100% rename from commander3/todscripts/dirbe/write_tods_new.py rename to commander3/todscripts/dirbe/archive/write_tods_new.py diff --git a/commander3/todscripts/dirbe/zodi.fits b/commander3/todscripts/dirbe/archive/zodi.fits similarity index 100% rename from commander3/todscripts/dirbe/zodi.fits rename to commander3/todscripts/dirbe/archive/zodi.fits diff --git a/commander3/todscripts/dirbe/zodi2.fits b/commander3/todscripts/dirbe/archive/zodi2.fits similarity index 100% rename from commander3/todscripts/dirbe/zodi2.fits rename to commander3/todscripts/dirbe/archive/zodi2.fits diff --git a/commander3/todscripts/dirbe/dirbe_utils.py b/commander3/todscripts/dirbe/dirbe_utils.py index ebab5ee29..3e230ae6c 100644 --- a/commander3/todscripts/dirbe/dirbe_utils.py +++ b/commander3/todscripts/dirbe/dirbe_utils.py @@ -1,4 +1,5 @@ from __future__ import annotations +from dataclasses import dataclass from typing import Sequence from functools import cache @@ -10,34 +11,42 @@ import numpy as np from numpy.typing import NDArray import re - +from scipy.interpolate import interp1d import healpy as hp -from astropy.coordinates import get_body, HeliocentricMeanEcliptic -from scipy import interpolate - +from astropy.coordinates import ( + solar_system_ephemeris, + get_body, + HeliocentricMeanEcliptic, +) +from astroquery.mpc import MPC DIRBE_SKYMAP_INFO = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/DIRBE_SKYMAP_INFO.FITS" DIRBE_BANDPASSES = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/bandpass/DIRBE_SYSTEM_SPECTRAL_RESPONSE_TABLE.ASC" -DIRBE_BEAM = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/beams/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" +DIRBE_BEAM = ( + "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/beams/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" +) DIRBE_POS_PATH = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/position/" +BEAM_FILE = "/mn/stornext/d16/cmbco/ola/dirbe/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" +BANDPASS_PATH = "/mn/stornext/d5/data/metins/dirbe/data/" + DIRBE_POS_FILES = [ - "dmr_anc_spcl_89328_89356.txt", - "dmr_anc_89356_90021.txt", - "dmr_anc_90021_90051.txt", - "dmr_anc_90081_90111.txt", - "dmr_anc_90111_90141.txt", - "dmr_anc_90171_90206.txt", - "dmr_anc_90206_90236.txt", - "dmr_anc_90266_90296.txt", - "dmr_anc_90296_90326.txt", - "dmr_anc_90356_91021.txt", - "dmr_anc_90051_90081.txt", - "dmr_anc_90141_90171.txt", - "dmr_anc_90236_90266.txt", - "dmr_anc_90326_90356.txt", - ] - -BANDS = range(1,11) + "dmr_anc_spcl_89328_89356.txt", + "dmr_anc_89356_90021.txt", + "dmr_anc_90021_90051.txt", + "dmr_anc_90081_90111.txt", + "dmr_anc_90111_90141.txt", + "dmr_anc_90171_90206.txt", + "dmr_anc_90206_90236.txt", + "dmr_anc_90266_90296.txt", + "dmr_anc_90296_90326.txt", + "dmr_anc_90356_91021.txt", + "dmr_anc_90051_90081.txt", + "dmr_anc_90141_90171.txt", + "dmr_anc_90236_90266.txt", + "dmr_anc_90326_90356.txt", +] + +BANDS = range(1, 11) DIRBE_START_DATE = Time(datetime(1989, 12, 11)) DETECTOR_LABELS = ("A", "B", "C") WAVELENGHTS = (1.25, 2.2, 3.5, 4.9, 12, 25, 60, 100, 140, 240) @@ -73,20 +82,153 @@ 10: 240, } -BODIES = { +ROWS_IN_BEAM_FILE_TO_SKIP = 19 + +PLANET_RADII = { "moon": 10, "mercury": 1, - "venus": 2, - "mars": 2, - "jupiter": 2, + "venus": 1, + "mars": 1, + "jupiter": 1.5, "saturn": 1, "uranus": 1, "neptune": 1, } +# Note that Ceres, Pallas, and Vesta were flagged in the original analysis, all +# other asteroids were discovered later on. All comets except C/1989 T1 were +# discovered by Lisse +COMET_RADII = { + '73P/Schwassmann–Wachmann 3':2, + 'C/1989 Q1':2, + 'C/1989 T1':2, + 'C/1989 X1':15, + 'C/1990 K1':5 + } +ASTEROID_RADII = { + '1 Ceres':1, + '2 Pallas':1, + '4 Vesta':1, + '15 Eunomia':1, + '31 Euphrosyne':1, + '41 Daphne':1, + '42 Isis':1, + '85 Io':1, + '185 Eunike':1, + '194 Prokne':1, + '372 Palma':1, + '405 Thia':1, + '511 Davida':1, + '704 Interamnia':1, + '747 Winchester':1, + '1021 Flammario':1, + } + +SIGMA_0 = { + 1: 0.1820848274487808, + 2: 0.1785923183102134, + 3: 0.12869298902093768, + 4: 0.09362580480386565, + 5: 0.14110078941487805, + 6: 0.19622963644711278, + 7: 0.358702745030365, + 8: 0.4273920139329039, + 9: 1.9890065503932703, + 10: 2.012305834012275, +} -def get_flag_sum(*flag_bits: int) -> int: - return sum([2**bit for bit in flag_bits]) + +def get_planet_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: + times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( + datetime + ) + astropy_times = Time(times, format="datetime", scale="utc") + interpolaters = {} + rotator = hp.Rotator(coord=["E", "G"]) + with solar_system_ephemeris.set("de432s"): + for body_name in PLANET_RADII: + interpolaters[body_name] = {} + body = get_body(body_name, astropy_times).transform_to( + "geocentricmeanecliptic" + ) + lon, lat = rotator(body.lon.value, body.lat.value, lonlat=True) + interpolaters[body_name]["lon"] = interp1d(astropy_times.mjd, lon) + interpolaters[body_name]["lat"] = interp1d(astropy_times.mjd, lat) + + return interpolaters + +def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: + times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( + datetime + ) + + astropy_times = Time(times, format="datetime", scale="utc") + interpolaters_comet = {} + interpolaters_asteroids = {} + rotator = hp.Rotator(coord=["C", "G"]) + with solar_system_ephemeris.set('de432s'): + for ci, c in enumerate(COMET_RADII): + interpolaters_comet[c] = {} + lons = [] + lats = [] + dists = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(c, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) + dist = eph['r'] + lons += lon.tolist() + lats += lat.tolist() + dists += dist.tolist() + lons = np.array(lons) + lats = np.array(lats) + dists = np.array(dists) + x, y, z = hp.dir2vec(lons, lats, lonlat=True) + + interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) + interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) + interpolaters_comet[c]['x'] = interp1d(astropy_times.mjd, x) + interpolaters_comet[c]['y'] = interp1d(astropy_times.mjd, y) + interpolaters_comet[c]['z'] = interp1d(astropy_times.mjd, z) + + for a in ASTEROID_RADII: + interpolaters_asteroids[a] = {} + lons = [] + lats = [] + for i in range(len(astropy_times)//1441+1): + astropy_times_i = astropy_times[i*1441:(i+1)*1441] + eph = MPC.get_ephemeris(a, start=astropy_times_i[0], + number=len(astropy_times_i), step='1h') + lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) + lons += lon.tolist() + lats += lat.tolist() + lons = np.array(lons) + lats = np.array(lats) + x, y, z = hp.dir2vec(lons, lats, lonlat=True) + interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) + interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) + interpolaters_asteroids[a]['x'] = interp1d(astropy_times.mjd, x) + interpolaters_asteroids[a]['y'] = interp1d(astropy_times.mjd, y) + interpolaters_asteroids[a]['z'] = interp1d(astropy_times.mjd, z) + return interpolaters_comet, interpolaters_asteroids + +@cache +def band_to_bit(band: int) -> int: + """Returns the bit corresponding to the band.""" + return { + 1: 0, + 2: 3, + 3: 6, + 4: 9, + 5: 10, + 6: 11, + 7: 12, + 8: 13, + 9: 14, + 10: 15, + }[band] def pix_to_lonlat( @@ -103,26 +245,6 @@ def pix_to_lonlat( return np.column_stack((latitudes, longitudes)) -def normalize_dirbe_bandpasses( - bandpasses: NDArray[np.floating], -) -> NDArray[np.floating]: - """Normalizes the dirbe_bandpasses so that the sum of the weights is 1.""" - - return bandpasses / np.expand_dims(bandpasses.sum(axis=1), axis=1) - -@cache -def get_dirbe_bandpass(normalized: bool = True) -> tuple[NDArray[np.floating], NDArray[np.floating]]: - """Returns the DIRBE bandpasses.""" - - wavelengths, *bandpasses = np.loadtxt(DIRBE_BANDPASSES, skiprows=15, unpack=True) - - wavelengths = np.asarray(wavelengths) - bandpasses = np.asarray(bandpasses) - - if normalized: - return wavelengths, normalize_dirbe_bandpasses(bandpasses) - - return wavelengths, bandpasses @cache def get_dirbe_fwhm() -> dict[str, float]: @@ -136,14 +258,17 @@ def get_dirbe_fwhm() -> dict[str, float]: for line in file.readlines()[ROWS_TO_SKIP:]: cols = line.split() detector, band = re.match(r"(\d+)([A-C]?)", cols[0], re.I).groups() - band_label = f"{int(detector):02}_{band}" if band else f"{int(detector):02}_A" - if len(cols) > FWHM_COL: + band_label = ( + f"{int(detector):02}_{band}" if band else f"{int(detector):02}_A" + ) + if len(cols) > FWHM_COL: fwhm = np.sqrt(float(cols[FWHM_COL])) * u.rad fwhm_arcmin = fwhm.to(u.arcmin).value fwhms[band_label] = np.round(fwhm_arcmin, 2) return fwhms + @cache def get_dirbe_beams() -> dict[str, NDArray[np.floating]]: """ @@ -152,11 +277,11 @@ def get_dirbe_beams() -> dict[str, NDArray[np.floating]]: """ NSIDE = 128 LMAX = 3 * NSIDE - N_ALMS = LMAX**2 + 2*LMAX +1 - DEFAULT_BEAM = np.zeros((3, N_ALMS)) # Update this with actual beams + N_ALMS = LMAX**2 + 2 * LMAX + 1 + DEFAULT_BEAM = np.zeros((3, N_ALMS)) # Update this with actual beams beams: dict[str, NDArray[np.floating]] = {} - for detector in range(1,11): + for detector in range(1, 11): if detector <= 3: for band in DETECTOR_LABELS: beams[f"{detector:02}_{band}"] = DEFAULT_BEAM @@ -165,6 +290,7 @@ def get_dirbe_beams() -> dict[str, NDArray[np.floating]]: return beams + @cache def get_dirbe_sidelobes() -> dict[str, NDArray[np.floating]]: """ @@ -173,11 +299,11 @@ def get_dirbe_sidelobes() -> dict[str, NDArray[np.floating]]: """ NSIDE = 128 LMAX = 3 * NSIDE - N_ALMS = LMAX**2 + 2*LMAX +1 - DEFAULT_SIDELOBES = np.zeros((3,N_ALMS)) # Update this with actual sidelobes + N_ALMS = LMAX**2 + 2 * LMAX + 1 + DEFAULT_SIDELOBES = np.zeros((3, N_ALMS)) # Update this with actual sidelobes sidelobes: dict[str, NDArray[np.floating]] = {} - for detector in range(1,11): + for detector in range(1, 11): if detector <= 3: for band in DETECTOR_LABELS: sidelobes[f"{detector:02}_{band}"] = DEFAULT_SIDELOBES @@ -186,26 +312,29 @@ def get_dirbe_sidelobes() -> dict[str, NDArray[np.floating]]: return sidelobes + @cache def get_dmrfile_mjd_times(filename: str) -> NDArray[np.floating]: """Duncans script dont really know what goes on here.""" data = np.loadtxt(DIRBE_POS_PATH + filename) - adt = data[:,:2] + adt = data[:, :2] i4max = 4.294967296e9 - t_adt = np.zeros_like(adt[:,0]) - ind = adt[:,0] >= 0 - t_adt[ind] = adt[ind,0] + i4max*adt[ind,1] - ind = adt[:,0] < 0 - t_adt[ind] = i4max + adt[ind,0] + i4max*adt[ind,1] - t_adt = t_adt*(100*u.ns) - t_adt_d = t_adt.to('day').value # in MJD + t_adt = np.zeros_like(adt[:, 0]) + ind = adt[:, 0] >= 0 + t_adt[ind] = adt[ind, 0] + i4max * adt[ind, 1] + ind = adt[:, 0] < 0 + t_adt[ind] = i4max + adt[ind, 0] + i4max * adt[ind, 1] + t_adt = t_adt * (100 * u.ns) + t_adt_d = t_adt.to("day").value # in MJD return t_adt_d + @cache def get_dmrfile_positions(filename: str) -> NDArray[np.floating]: - return np.loadtxt(DIRBE_POS_PATH + filename, usecols=[5,6,7]) + return np.loadtxt(DIRBE_POS_PATH + filename, usecols=[5, 6, 7]) + @cache def dirbe_day_to_dmr_day(days: int) -> datetime: @@ -214,10 +343,11 @@ def dirbe_day_to_dmr_day(days: int) -> datetime: dirbe_date = DIRBE_START_DATE + TimeDelta(days - 1, format="jd") # datetime doesnt support leap seconds so we need to do some tricks - dirbe_date_iso = dirbe_date.to_value(format="iso",subfmt="date_hm") + dirbe_date_iso = dirbe_date.to_value(format="iso", subfmt="date_hm") return datetime.strptime(dirbe_date_iso, "%Y-%m-%d %H:%M") + @cache def get_dmrfile_datetimes(filename: str) -> tuple[datetime, datetime]: """Returns datetime objects for the start and stop days in the dmr files.""" @@ -225,51 +355,114 @@ def get_dmrfile_datetimes(filename: str) -> tuple[datetime, datetime]: regex_groups = re.search(r"(\d{2})(\d+)_(\d{2})(\d+)", filename).groups() year_one, yday_one, year_two, yday_two = regex_groups - start_date = datetime.strptime(f'19{year_one} {yday_one}', '%Y %j') - stop_date = datetime.strptime(f'19{year_two} {yday_two}', '%Y %j') - + start_date = datetime.strptime(f"19{year_one} {yday_one}", "%Y %j") + stop_date = datetime.strptime(f"19{year_two} {yday_two}", "%Y %j") + return start_date, stop_date -def get_sat_and_earth_pos( - day: int, dirbe_time: float -) -> tuple[NDArray[np.floating], NDArray[np.floating]]: - """dmr_cio_91206-91236.fits contains data from day 206 of 1991 to day 236 of 1991).""" - dmr_day = dirbe_day_to_dmr_day(day) +def test_naming() -> None: + import h5py + + with h5py.File("test.h5", "w") as file: + for detector in BANDS: + file.create_group(f"{detector:02}_{WAVELENGHTS[detector - 1]}um") + for band in DETECTOR_LABELS: + file.create_group(f"{detector:02}_{band}") + if detector > 3: + break + + +@dataclass +class DetectorBeamData: + solid_angle: float + solid_angle_error: float + beam: dict[range, tuple[float, float]] + + +@cache +def get_beam_data() -> dict[str, DetectorBeamData]: + data: dict[str, DetectorBeamData] = {} + visited = set() + current_det_data = {} + with open(BEAM_FILE, "r") as f: + lines = iter(f.readlines()[ROWS_IN_BEAM_FILE_TO_SKIP:]) + while True: + try: + line = next(lines) + except StopIteration: + data[split[0]] = DetectorBeamData(**current_det_data) + break + split = line.split() + current_det = split[0] + if current_det not in visited: + visited.add(current_det) + current_det_data = { + "solid_angle": float(split[4]), + "solid_angle_error": float(split[5]), + "beam": {}, + } + if visited != set(): + data[split[0]] = DetectorBeamData(**current_det_data) + if current_det in visited: + start, stop = split[1].split("-") + if current_det in {"9", "10"}: + start, stop = "89345", "90260" + # Hack to invlude final 5 days fo data... + if stop == "90260": + stop = "90266" + current_det_data["beam"][range(int(start), int(stop))] = ( + u.Quantity(float(split[2]), u.arcmin).to_value(u.rad), + u.Quantity(float(split[3]), u.arcmin).to_value(u.rad), + ) + + return data + + +BEAM_DATA = get_beam_data() + + +def get_sat_and_earth_pos(yday: int, time: float) -> tuple[np.ndarray, np.ndarray]: + """dmr_cio_91206-91236.fits contains data from day 206 of 1991 to day 236 of 1991).""" - for file in DIRBE_POS_FILES: - start_date, stop_date = get_dmrfile_datetimes(file) - if start_date <= dmr_day <= stop_date: - dmr_file = file + ranges_times = [re.findall(r"\d+", file) for file in DIRBE_POS_FILES] + ranges = [range(*[int(time) for time in times]) for times in ranges_times] + for idx, r in enumerate(ranges): + if yday in r: + dmr_file = DIRBE_POS_FILES[idx] break else: - raise FileNotFoundError( - f"could not find file containing sat pos for {dmr_day=}" - ) + raise FileNotFoundError(f"could not find file containing sat pos for {yday=}") dmr_times = get_dmrfile_mjd_times(dmr_file) dmr_positions = get_dmrfile_positions(dmr_file) - interpolator_sat_x = interpolate.interp1d( - dmr_times, dmr_positions[:, 0], fill_value="extrapolate" + interpolator_sat_x = interp1d( + dmr_times, + dmr_positions[:, 0], + fill_value="extrapolate", ) - interpolator_sat_y = interpolate.interp1d( - dmr_times, dmr_positions[:, 1], fill_value="extrapolate" + interpolator_sat_y = interp1d( + dmr_times, + dmr_positions[:, 1], + fill_value="extrapolate", ) - interpolator_sat_z = interpolate.interp1d( - dmr_times, dmr_positions[:, 2], fill_value="extrapolate" + interpolator_sat_z = interp1d( + dmr_times, + dmr_positions[:, 2], + fill_value="extrapolate", ) - pos_x = interpolator_sat_x(dirbe_time) - pos_y = interpolator_sat_y(dirbe_time) - pos_z = interpolator_sat_z(dirbe_time) + pos_x = interpolator_sat_x(time) + pos_y = interpolator_sat_y(time) + pos_z = interpolator_sat_z(time) celestial_sat_pos = u.Quantity([pos_x, pos_y, pos_z], u.m).to(u.AU).value rotator = hp.Rotator(coord=["C", "E"]) geocentric_ecl_sat_pos = u.Quantity(rotator(celestial_sat_pos), u.AU).transpose() - earth_pos = get_body("earth", Time(dirbe_time, format="mjd")).transform_to( + earth_pos = get_body("earth", Time(time, format="mjd")).transform_to( HeliocentricMeanEcliptic ) earth_pos = earth_pos.cartesian.xyz.to(u.AU).transpose() @@ -278,9 +471,28 @@ def get_sat_and_earth_pos( return ecl_sat_pos.value, earth_pos.value + +@cache +def get_const_scalars(band: int) -> NDArray[np.floating]: + """Used in V14 -> and out""" + # SIGMA0 = u.Quantity( + # [2.4, 1.6, 0.9, 0.8, 0.9, 0.9, 0.9, 0.5, 32.8, 10.7], "nW/(m^2 sr)" + # ) + # SIGMA0 *= 20 + # SIGMA0 /= u.Quantity( + # [59.5, 22.4, 22.0, 8.19, 13.3, 4.13, 2.32, 0.974, 0.605, 0.495], "THz" + # ) + # SIGMA0 = SIGMA0.to_value("MJy/sr") + + TEMP_GAIN = 1 + TEMP_ALPHA = -1 + fknee = 1 / (10 * 60) + + return np.array([TEMP_GAIN, SIGMA_0[band], fknee, TEMP_ALPHA]).flatten() + @cache def get_bandpass(band: int) -> tuple[u.Quantity[u.micron], NDArray[np.float64]]: - bandpass_file = BANDPASS_PATH / f"DIRBE_{band:02}_bandpass.dat" + bandpass_file = BANDPASS_PATH + f"/DIRBE_{band:02}_bandpass.dat" bandpass = np.loadtxt(bandpass_file, unpack=True) non_zero = np.nonzero(bandpass[1]) @@ -305,15 +517,6 @@ def get_iras_factor(band: int) -> float: ) -def test_naming() -> None: - import h5py - with h5py.File("test.h5", "w") as file: - for detector in BANDS: - file.create_group(f"{detector:02}_{WAVELENGHTS[detector - 1]}um") - for band in DETECTOR_LABELS: - file.create_group(f"{detector:02}_{band}") - if detector > 3: - break - if __name__ == "__main__": - ... \ No newline at end of file + print([get_iras_factor(i) for i in range(1,11)]) + diff --git a/commander3/todscripts/dirbe/metin/dirbe_utils.py b/commander3/todscripts/dirbe/metin/dirbe_utils.py deleted file mode 100644 index 3e230ae6c..000000000 --- a/commander3/todscripts/dirbe/metin/dirbe_utils.py +++ /dev/null @@ -1,522 +0,0 @@ -from __future__ import annotations -from dataclasses import dataclass -from typing import Sequence - -from functools import cache - -from astropy.io import fits -import astropy.units as u -from astropy.time import Time, TimeDelta -from datetime import datetime -import numpy as np -from numpy.typing import NDArray -import re -from scipy.interpolate import interp1d -import healpy as hp -from astropy.coordinates import ( - solar_system_ephemeris, - get_body, - HeliocentricMeanEcliptic, -) -from astroquery.mpc import MPC - -DIRBE_SKYMAP_INFO = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/DIRBE_SKYMAP_INFO.FITS" -DIRBE_BANDPASSES = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/bandpass/DIRBE_SYSTEM_SPECTRAL_RESPONSE_TABLE.ASC" -DIRBE_BEAM = ( - "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/beams/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" -) -DIRBE_POS_PATH = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/position/" -BEAM_FILE = "/mn/stornext/d16/cmbco/ola/dirbe/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" -BANDPASS_PATH = "/mn/stornext/d5/data/metins/dirbe/data/" - -DIRBE_POS_FILES = [ - "dmr_anc_spcl_89328_89356.txt", - "dmr_anc_89356_90021.txt", - "dmr_anc_90021_90051.txt", - "dmr_anc_90081_90111.txt", - "dmr_anc_90111_90141.txt", - "dmr_anc_90171_90206.txt", - "dmr_anc_90206_90236.txt", - "dmr_anc_90266_90296.txt", - "dmr_anc_90296_90326.txt", - "dmr_anc_90356_91021.txt", - "dmr_anc_90051_90081.txt", - "dmr_anc_90141_90171.txt", - "dmr_anc_90236_90266.txt", - "dmr_anc_90326_90356.txt", -] - -BANDS = range(1, 11) -DIRBE_START_DATE = Time(datetime(1989, 12, 11)) -DETECTOR_LABELS = ("A", "B", "C") -WAVELENGHTS = (1.25, 2.2, 3.5, 4.9, 12, 25, 60, 100, 140, 240) -DETECTORS = [ - "1A", - "1B", - "1C", - "2A", - "2B", - "2C", - "3A", - "3B", - "3C", - "4", - "5", - "6", - "7", - "8", - "9", - "10", -] - -BAND_TO_WAVELENGTH: dict[int, float] = { - 1: 1.25, - 2: 2.2, - 3: 3.5, - 4: 4.9, - 5: 12, - 6: 25, - 7: 60, - 8: 100, - 9: 140, - 10: 240, -} - -ROWS_IN_BEAM_FILE_TO_SKIP = 19 - -PLANET_RADII = { - "moon": 10, - "mercury": 1, - "venus": 1, - "mars": 1, - "jupiter": 1.5, - "saturn": 1, - "uranus": 1, - "neptune": 1, -} - -# Note that Ceres, Pallas, and Vesta were flagged in the original analysis, all -# other asteroids were discovered later on. All comets except C/1989 T1 were -# discovered by Lisse -COMET_RADII = { - '73P/Schwassmann–Wachmann 3':2, - 'C/1989 Q1':2, - 'C/1989 T1':2, - 'C/1989 X1':15, - 'C/1990 K1':5 - } -ASTEROID_RADII = { - '1 Ceres':1, - '2 Pallas':1, - '4 Vesta':1, - '15 Eunomia':1, - '31 Euphrosyne':1, - '41 Daphne':1, - '42 Isis':1, - '85 Io':1, - '185 Eunike':1, - '194 Prokne':1, - '372 Palma':1, - '405 Thia':1, - '511 Davida':1, - '704 Interamnia':1, - '747 Winchester':1, - '1021 Flammario':1, - } - -SIGMA_0 = { - 1: 0.1820848274487808, - 2: 0.1785923183102134, - 3: 0.12869298902093768, - 4: 0.09362580480386565, - 5: 0.14110078941487805, - 6: 0.19622963644711278, - 7: 0.358702745030365, - 8: 0.4273920139329039, - 9: 1.9890065503932703, - 10: 2.012305834012275, -} - - -def get_planet_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: - times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( - datetime - ) - astropy_times = Time(times, format="datetime", scale="utc") - interpolaters = {} - rotator = hp.Rotator(coord=["E", "G"]) - with solar_system_ephemeris.set("de432s"): - for body_name in PLANET_RADII: - interpolaters[body_name] = {} - body = get_body(body_name, astropy_times).transform_to( - "geocentricmeanecliptic" - ) - lon, lat = rotator(body.lon.value, body.lat.value, lonlat=True) - interpolaters[body_name]["lon"] = interp1d(astropy_times.mjd, lon) - interpolaters[body_name]["lat"] = interp1d(astropy_times.mjd, lat) - - return interpolaters - -def get_smallbody_interps(time_delta: TimeDelta) -> dict[str, dict[str, interp1d]]: - times = np.arange(datetime(1989, 6, 1), datetime(1991, 1, 1), time_delta).astype( - datetime - ) - - astropy_times = Time(times, format="datetime", scale="utc") - interpolaters_comet = {} - interpolaters_asteroids = {} - rotator = hp.Rotator(coord=["C", "G"]) - with solar_system_ephemeris.set('de432s'): - for ci, c in enumerate(COMET_RADII): - interpolaters_comet[c] = {} - lons = [] - lats = [] - dists = [] - for i in range(len(astropy_times)//1441+1): - astropy_times_i = astropy_times[i*1441:(i+1)*1441] - eph = MPC.get_ephemeris(c, start=astropy_times_i[0], - number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) - dist = eph['r'] - lons += lon.tolist() - lats += lat.tolist() - dists += dist.tolist() - lons = np.array(lons) - lats = np.array(lats) - dists = np.array(dists) - x, y, z = hp.dir2vec(lons, lats, lonlat=True) - - interpolaters_comet[c]['lon'] = interp1d(astropy_times.mjd, lons) - interpolaters_comet[c]['lat'] = interp1d(astropy_times.mjd, lats) - interpolaters_comet[c]['dist'] = interp1d(astropy_times.mjd, dists) - interpolaters_comet[c]['x'] = interp1d(astropy_times.mjd, x) - interpolaters_comet[c]['y'] = interp1d(astropy_times.mjd, y) - interpolaters_comet[c]['z'] = interp1d(astropy_times.mjd, z) - - for a in ASTEROID_RADII: - interpolaters_asteroids[a] = {} - lons = [] - lats = [] - for i in range(len(astropy_times)//1441+1): - astropy_times_i = astropy_times[i*1441:(i+1)*1441] - eph = MPC.get_ephemeris(a, start=astropy_times_i[0], - number=len(astropy_times_i), step='1h') - lon, lat = rotator(eph['RA'].value, eph['Dec'].value, lonlat=True) - lons += lon.tolist() - lats += lat.tolist() - lons = np.array(lons) - lats = np.array(lats) - x, y, z = hp.dir2vec(lons, lats, lonlat=True) - interpolaters_asteroids[a]['lon'] = interp1d(astropy_times.mjd, lons) - interpolaters_asteroids[a]['lat'] = interp1d(astropy_times.mjd, lats) - interpolaters_asteroids[a]['x'] = interp1d(astropy_times.mjd, x) - interpolaters_asteroids[a]['y'] = interp1d(astropy_times.mjd, y) - interpolaters_asteroids[a]['z'] = interp1d(astropy_times.mjd, z) - return interpolaters_comet, interpolaters_asteroids - -@cache -def band_to_bit(band: int) -> int: - """Returns the bit corresponding to the band.""" - return { - 1: 0, - 2: 3, - 3: 6, - 4: 9, - 5: 10, - 6: 11, - 7: 12, - 8: 13, - 9: 14, - 10: 15, - }[band] - - -def pix_to_lonlat( - pixels: int | Sequence[int] | NDArray[np.integer], -) -> tuple[float, float] | NDArray[np.integer]: - """Returns the lon lat pairs for DIRBE QUADCUBE pixels indices.""" - - with fits.open(DIRBE_SKYMAP_INFO) as file: - latitudes = file[1].data["ELAT-CSC"][pixels] - longitudes = file[1].data["ELON-CSC"][pixels] - - if np.isscalar(pixels): - return latitudes, longitudes - - return np.column_stack((latitudes, longitudes)) - - -@cache -def get_dirbe_fwhm() -> dict[str, float]: - """Returns a dictionary mapping the DIRBE bands to FWHM in radians.""" - - ROWS_TO_SKIP = 19 - FWHM_COL = 4 - - fwhms: dict[str, float] = {} - with open(DIRBE_BEAM, "r") as file: - for line in file.readlines()[ROWS_TO_SKIP:]: - cols = line.split() - detector, band = re.match(r"(\d+)([A-C]?)", cols[0], re.I).groups() - band_label = ( - f"{int(detector):02}_{band}" if band else f"{int(detector):02}_A" - ) - if len(cols) > FWHM_COL: - fwhm = np.sqrt(float(cols[FWHM_COL])) * u.rad - fwhm_arcmin = fwhm.to(u.arcmin).value - fwhms[band_label] = np.round(fwhm_arcmin, 2) - - return fwhms - - -@cache -def get_dirbe_beams() -> dict[str, NDArray[np.floating]]: - """ - Returns a dictionary mapping the DIRBE bands to beams. - NOTE: Currently only returns a sequence of 0's. - """ - NSIDE = 128 - LMAX = 3 * NSIDE - N_ALMS = LMAX**2 + 2 * LMAX + 1 - DEFAULT_BEAM = np.zeros((3, N_ALMS)) # Update this with actual beams - - beams: dict[str, NDArray[np.floating]] = {} - for detector in range(1, 11): - if detector <= 3: - for band in DETECTOR_LABELS: - beams[f"{detector:02}_{band}"] = DEFAULT_BEAM - else: - beams[f"{detector:02}_A"] = DEFAULT_BEAM - - return beams - - -@cache -def get_dirbe_sidelobes() -> dict[str, NDArray[np.floating]]: - """ - Returns a dictionary mapping the DIRBE bands to sidelobes. - NOTE: We dont have dirbe sidelobes so we just returns a sequence of 0's. - """ - NSIDE = 128 - LMAX = 3 * NSIDE - N_ALMS = LMAX**2 + 2 * LMAX + 1 - DEFAULT_SIDELOBES = np.zeros((3, N_ALMS)) # Update this with actual sidelobes - - sidelobes: dict[str, NDArray[np.floating]] = {} - for detector in range(1, 11): - if detector <= 3: - for band in DETECTOR_LABELS: - sidelobes[f"{detector:02}_{band}"] = DEFAULT_SIDELOBES - else: - sidelobes[f"{detector:02}_A"] = DEFAULT_SIDELOBES - - return sidelobes - - -@cache -def get_dmrfile_mjd_times(filename: str) -> NDArray[np.floating]: - """Duncans script dont really know what goes on here.""" - - data = np.loadtxt(DIRBE_POS_PATH + filename) - adt = data[:, :2] - i4max = 4.294967296e9 - t_adt = np.zeros_like(adt[:, 0]) - ind = adt[:, 0] >= 0 - t_adt[ind] = adt[ind, 0] + i4max * adt[ind, 1] - ind = adt[:, 0] < 0 - t_adt[ind] = i4max + adt[ind, 0] + i4max * adt[ind, 1] - t_adt = t_adt * (100 * u.ns) - t_adt_d = t_adt.to("day").value # in MJD - - return t_adt_d - - -@cache -def get_dmrfile_positions(filename: str) -> NDArray[np.floating]: - return np.loadtxt(DIRBE_POS_PATH + filename, usecols=[5, 6, 7]) - - -@cache -def dirbe_day_to_dmr_day(days: int) -> datetime: - """Returns the dmr_day from dirbe_day""" - - dirbe_date = DIRBE_START_DATE + TimeDelta(days - 1, format="jd") - - # datetime doesnt support leap seconds so we need to do some tricks - dirbe_date_iso = dirbe_date.to_value(format="iso", subfmt="date_hm") - - return datetime.strptime(dirbe_date_iso, "%Y-%m-%d %H:%M") - - -@cache -def get_dmrfile_datetimes(filename: str) -> tuple[datetime, datetime]: - """Returns datetime objects for the start and stop days in the dmr files.""" - - regex_groups = re.search(r"(\d{2})(\d+)_(\d{2})(\d+)", filename).groups() - year_one, yday_one, year_two, yday_two = regex_groups - - start_date = datetime.strptime(f"19{year_one} {yday_one}", "%Y %j") - stop_date = datetime.strptime(f"19{year_two} {yday_two}", "%Y %j") - - return start_date, stop_date - - -def test_naming() -> None: - import h5py - - with h5py.File("test.h5", "w") as file: - for detector in BANDS: - file.create_group(f"{detector:02}_{WAVELENGHTS[detector - 1]}um") - for band in DETECTOR_LABELS: - file.create_group(f"{detector:02}_{band}") - if detector > 3: - break - - -@dataclass -class DetectorBeamData: - solid_angle: float - solid_angle_error: float - beam: dict[range, tuple[float, float]] - - -@cache -def get_beam_data() -> dict[str, DetectorBeamData]: - data: dict[str, DetectorBeamData] = {} - visited = set() - current_det_data = {} - with open(BEAM_FILE, "r") as f: - lines = iter(f.readlines()[ROWS_IN_BEAM_FILE_TO_SKIP:]) - while True: - try: - line = next(lines) - except StopIteration: - data[split[0]] = DetectorBeamData(**current_det_data) - break - split = line.split() - current_det = split[0] - if current_det not in visited: - visited.add(current_det) - current_det_data = { - "solid_angle": float(split[4]), - "solid_angle_error": float(split[5]), - "beam": {}, - } - if visited != set(): - data[split[0]] = DetectorBeamData(**current_det_data) - if current_det in visited: - start, stop = split[1].split("-") - if current_det in {"9", "10"}: - start, stop = "89345", "90260" - # Hack to invlude final 5 days fo data... - if stop == "90260": - stop = "90266" - current_det_data["beam"][range(int(start), int(stop))] = ( - u.Quantity(float(split[2]), u.arcmin).to_value(u.rad), - u.Quantity(float(split[3]), u.arcmin).to_value(u.rad), - ) - - return data - - -BEAM_DATA = get_beam_data() - - -def get_sat_and_earth_pos(yday: int, time: float) -> tuple[np.ndarray, np.ndarray]: - """dmr_cio_91206-91236.fits contains data from day 206 of 1991 to day 236 of 1991).""" - - ranges_times = [re.findall(r"\d+", file) for file in DIRBE_POS_FILES] - ranges = [range(*[int(time) for time in times]) for times in ranges_times] - for idx, r in enumerate(ranges): - if yday in r: - dmr_file = DIRBE_POS_FILES[idx] - break - else: - raise FileNotFoundError(f"could not find file containing sat pos for {yday=}") - - dmr_times = get_dmrfile_mjd_times(dmr_file) - dmr_positions = get_dmrfile_positions(dmr_file) - - interpolator_sat_x = interp1d( - dmr_times, - dmr_positions[:, 0], - fill_value="extrapolate", - ) - interpolator_sat_y = interp1d( - dmr_times, - dmr_positions[:, 1], - fill_value="extrapolate", - ) - interpolator_sat_z = interp1d( - dmr_times, - dmr_positions[:, 2], - fill_value="extrapolate", - ) - - pos_x = interpolator_sat_x(time) - pos_y = interpolator_sat_y(time) - pos_z = interpolator_sat_z(time) - - celestial_sat_pos = u.Quantity([pos_x, pos_y, pos_z], u.m).to(u.AU).value - - rotator = hp.Rotator(coord=["C", "E"]) - geocentric_ecl_sat_pos = u.Quantity(rotator(celestial_sat_pos), u.AU).transpose() - - earth_pos = get_body("earth", Time(time, format="mjd")).transform_to( - HeliocentricMeanEcliptic - ) - earth_pos = earth_pos.cartesian.xyz.to(u.AU).transpose() - - ecl_sat_pos = earth_pos + geocentric_ecl_sat_pos - - return ecl_sat_pos.value, earth_pos.value - - -@cache -def get_const_scalars(band: int) -> NDArray[np.floating]: - """Used in V14 -> and out""" - # SIGMA0 = u.Quantity( - # [2.4, 1.6, 0.9, 0.8, 0.9, 0.9, 0.9, 0.5, 32.8, 10.7], "nW/(m^2 sr)" - # ) - # SIGMA0 *= 20 - # SIGMA0 /= u.Quantity( - # [59.5, 22.4, 22.0, 8.19, 13.3, 4.13, 2.32, 0.974, 0.605, 0.495], "THz" - # ) - # SIGMA0 = SIGMA0.to_value("MJy/sr") - - TEMP_GAIN = 1 - TEMP_ALPHA = -1 - fknee = 1 / (10 * 60) - - return np.array([TEMP_GAIN, SIGMA_0[band], fknee, TEMP_ALPHA]).flatten() - -@cache -def get_bandpass(band: int) -> tuple[u.Quantity[u.micron], NDArray[np.float64]]: - bandpass_file = BANDPASS_PATH + f"/DIRBE_{band:02}_bandpass.dat" - bandpass = np.loadtxt(bandpass_file, unpack=True) - - non_zero = np.nonzero(bandpass[1]) - bandpass = bandpass[:, non_zero[0]] - freqs, weights = bandpass - freqs *= u.micron - - return freqs, weights - - -@cache -def get_iras_factor(band: int) -> float: - freqs, weights = get_bandpass(band) - freq_ref = BAND_TO_WAVELENGTH[band] - freqs = freqs.to(u.Hz, u.spectral()) - freqs = np.flip(freqs) - weights = np.flip(weights) - weights /= np.trapz(weights, freqs.value) - return np.trapz( - weights * ((freq_ref * u.micron).to(u.Hz, u.spectral()).value / freqs.value), - freqs.value, - ) - - -if __name__ == "__main__": - print([get_iras_factor(i) for i in range(1,11)]) - diff --git a/commander3/todscripts/dirbe/metin/pointing.py b/commander3/todscripts/dirbe/pointing.py similarity index 100% rename from commander3/todscripts/dirbe/metin/pointing.py rename to commander3/todscripts/dirbe/pointing.py diff --git a/commander3/todscripts/dirbe/metin/read_data.py b/commander3/todscripts/dirbe/read_data.py similarity index 100% rename from commander3/todscripts/dirbe/metin/read_data.py rename to commander3/todscripts/dirbe/read_data.py diff --git a/commander3/todscripts/dirbe/metin/write_instrument_final.py b/commander3/todscripts/dirbe/write_instrument_final.py similarity index 100% rename from commander3/todscripts/dirbe/metin/write_instrument_final.py rename to commander3/todscripts/dirbe/write_instrument_final.py diff --git a/commander3/todscripts/dirbe/metin/write_tods_final.py b/commander3/todscripts/dirbe/write_tods_final.py similarity index 100% rename from commander3/todscripts/dirbe/metin/write_tods_final.py rename to commander3/todscripts/dirbe/write_tods_final.py From b63130b2be0518793a4bf40a054f5d98f54dfd80 Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 21 Feb 2025 10:53:54 +0100 Subject: [PATCH 110/171] Updated paths --- commander3/todscripts/dirbe/dirbe_utils.py | 2 +- commander3/todscripts/dirbe/write_instrument_final.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commander3/todscripts/dirbe/dirbe_utils.py b/commander3/todscripts/dirbe/dirbe_utils.py index 3e230ae6c..b4ce11204 100644 --- a/commander3/todscripts/dirbe/dirbe_utils.py +++ b/commander3/todscripts/dirbe/dirbe_utils.py @@ -27,7 +27,7 @@ ) DIRBE_POS_PATH = "/mn/stornext/d16/cmbco/ola/dirbe/auxdata/position/" BEAM_FILE = "/mn/stornext/d16/cmbco/ola/dirbe/DIRBE_BEAM_CHARACTERISTICS_P3B.ASC" -BANDPASS_PATH = "/mn/stornext/d5/data/metins/dirbe/data/" +BANDPASS_PATH = "/mn/stornext/d23/cmbco/cg/dirbe/data/" DIRBE_POS_FILES = [ "dmr_anc_spcl_89328_89356.txt", diff --git a/commander3/todscripts/dirbe/write_instrument_final.py b/commander3/todscripts/dirbe/write_instrument_final.py index 02115cd07..d0ee47904 100644 --- a/commander3/todscripts/dirbe/write_instrument_final.py +++ b/commander3/todscripts/dirbe/write_instrument_final.py @@ -6,13 +6,13 @@ if TYPE_CHECKING: from ....python.commander_tools.tod_tools.commander_instrument import commander_instrument -sys.path.insert(0, "/mn/stornext/d16/cmbco/bp/metins/Commander/commander3/python") +sys.path.insert(0, "../../python") from commander_tools.tod_tools.commander_instrument import commander_instrument from numpy.typing import NDArray import astropy.units as u import dirbe_utils -TEMP_OUTPUT_PATH = "/mn/stornext/d5/data/metins/dirbe/data" +TEMP_OUTPUT_PATH = "/mn/stornext/d5/data/duncanwa/DIRBE/data" NSIDE = 128 # temporary values that needs to be updated From 907d48aafb2daaaf0a145891f43435dd0cb4382e Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 21 Feb 2025 11:48:27 +0100 Subject: [PATCH 111/171] Added moon position to common field --- commander3/todscripts/dirbe/dirbe_utils.py | 9 +++++++++ commander3/todscripts/dirbe/write_tods_final.py | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/commander3/todscripts/dirbe/dirbe_utils.py b/commander3/todscripts/dirbe/dirbe_utils.py index b4ce11204..cfaeef915 100644 --- a/commander3/todscripts/dirbe/dirbe_utils.py +++ b/commander3/todscripts/dirbe/dirbe_utils.py @@ -471,6 +471,15 @@ def get_sat_and_earth_pos(yday: int, time: float) -> tuple[np.ndarray, np.ndarra return ecl_sat_pos.value, earth_pos.value +def get_moon_pos(yday: int, time: float) -> tuple[np.ndarray, np.ndarray]: + """dmr_cio_91206-91236.fits contains data from day 206 of 1991 to day 236 of 1991).""" + + moon_pos = get_body("moon", Time(time, format="mjd")).transform_to( + HeliocentricMeanEcliptic + ) + moon_pos = moon_pos.cartesian.xyz.to(u.AU).transpose() + + return moon_pos.value @cache def get_const_scalars(band: int) -> NDArray[np.floating]: diff --git a/commander3/todscripts/dirbe/write_tods_final.py b/commander3/todscripts/dirbe/write_tods_final.py index ce2039bad..6decb0374 100644 --- a/commander3/todscripts/dirbe/write_tods_final.py +++ b/commander3/todscripts/dirbe/write_tods_final.py @@ -37,7 +37,7 @@ from cosmoglobe.tod_tools import TODLoader # Path objects -DIRBE_DATA_PATH = Path("/mn/stornext/d5//data/duncanwa/DIRBE/hdf_files/") +DIRBE_DATA_PATH = Path("/mn/stornext/d5/data/duncanwa/DIRBE/hdf_files/") BANDPASS_PATH = Path("/mn/stornext/d5/data/metins/dirbe/data/") CIO_PATH = Path("/mn/stornext/d16/cmbco/ola/dirbe/cio") @@ -49,6 +49,7 @@ YDAYS = np.concatenate([np.arange(89345, 89366), np.arange(90001, 90265)]) START_TIME = Time("1981-01-01", format="isot", scale="utc") +# For debugging purposes, reduce N_CIO_FILES # CIO constants N_CIO_FILES = 285 BAD_DATA_SENTINEL = -16375 @@ -56,6 +57,8 @@ SAMP_RATE = 1 / 8 SAMP_RATE_DAYS = SAMP_RATE / (24 * 3600) +N_MOON_INTERP = 11 + BEAM_DATA = dirbe_utils.get_beam_data() FLAG_BITS: dict[str, int] = { @@ -114,6 +117,7 @@ class YdayData: sat_pos_stop: np.ndarray earth_pos_start: np.ndarray earth_pos_stop: np.ndarray + moon_positions: np.ndarray @dataclass @@ -128,6 +132,7 @@ class CIO: sat_pos_stop: list[np.ndarray] earth_pos_start: list[np.ndarray] earth_pos_stop: list[np.ndarray] + moon_positions: list[np.ndarray] def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: @@ -143,6 +148,7 @@ def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: sat_pos_stop=[yday.sat_pos_stop for yday in yday_data], earth_pos_start=[yday.earth_pos_start for yday in yday_data], earth_pos_stop=[yday.earth_pos_stop for yday in yday_data], + moon_positions=[yday.moon_positions for yday in yday_data], ) for band in dirbe_utils.BANDS } @@ -196,6 +202,7 @@ def get_yday_cio_data( time = (START_TIME + TimeDelta(time, format="sec", scale="tai")).mjd sat_pos_start, earth_pos_start= dirbe_utils.get_sat_and_earth_pos(yday, time[0]) sat_pos_stop, earth_pos_stop = dirbe_utils.get_sat_and_earth_pos(yday, time[-1]) + moon_positions = dirbe_utils.get_moon_pos(yday, np.linspace(time[0], time[-1], N_MOON_INTERP)) # Gap filling # Get indexes where time difference is larger than 2 sampling rates and split time array @@ -433,6 +440,7 @@ def get_yday_cio_data( sat_pos_stop=sat_pos_stop, earth_pos_start=earth_pos_start, earth_pos_stop=earth_pos_stop, + moon_positions=moon_positions, ) @@ -527,6 +535,8 @@ def write_band( comm_tod.add_field(pid_common_group + "/earthpos", cio.earth_pos_start[pid]) comm_tod.add_field(pid_common_group + "/earthpos_end", cio.earth_pos_stop[pid]) + comm_tod.add_field(pid_common_group + "/moonpos_arr", cio.moon_positions[pid]) + comm_tod.add_attribute(pid_common_group + "/satpos", "index", "X, Y, Z") comm_tod.add_attribute( pid_common_group + "/satpos", "coords", "heliocentric-ecliptic" @@ -627,7 +637,7 @@ def main() -> None: start_time = time.perf_counter() color_corr = False - version = 21 + version = 22 print(f"{'Writing DIRBE h5 files':=^50}") print(f"{version=}, {nside_out=}") From b70e05297ee68ad0fc8b62c936b4f13bcf9a69f9 Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 21 Feb 2025 11:50:59 +0100 Subject: [PATCH 112/171] Added moon position readin --- commander3/src/comm_tod_mod.f90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 1fc427d68..904a23070 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -86,6 +86,7 @@ module comm_tod_mod real(dp) :: x1_obs(3) ! Observatory position (x,y,z) for end of chunk real(dp) :: x0_earth(3) ! Observatory position (x,y,z) for start of chunk real(dp) :: x1_earth(3) ! Observatory position (x,y,z) for end of chunk + real(dp) :: xarr_moon(11,3) ! 11 moon positions (x,y,z) for chunk type(huffcode) :: hkey ! Huffman decompression key type(huffcode) :: todkey ! Huffman decompression key @@ -1004,6 +1005,7 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio call read_hdf(file, slabel // "/common/earthpos", self%x0_earth, opt=.true.) call read_hdf(file, slabel // "/common/earthpos_end", self%x1_earth, opt=.true.) + call read_hdf(file, slabel // "/common/moonpos_arr", self%xarr_moon, opt=.true.) ! Read detector scans allocate(self%d(ndet), buffer_sp(n)) From 838ca2a83ce904cc557d83c5b894a102fcfc75bc Mon Sep 17 00:00:00 2001 From: Duncan Date: Fri, 21 Feb 2025 11:52:24 +0100 Subject: [PATCH 113/171] Edited comment --- commander3/src/comm_tod_mod.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 904a23070..c3503cec1 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -86,7 +86,8 @@ module comm_tod_mod real(dp) :: x1_obs(3) ! Observatory position (x,y,z) for end of chunk real(dp) :: x0_earth(3) ! Observatory position (x,y,z) for start of chunk real(dp) :: x1_earth(3) ! Observatory position (x,y,z) for end of chunk - real(dp) :: xarr_moon(11,3) ! 11 moon positions (x,y,z) for chunk + real(dp) :: xarr_moon(11,3) ! 11 evenly spaced moon positions (x,y,z) + ! including first and last point type(huffcode) :: hkey ! Huffman decompression key type(huffcode) :: todkey ! Huffman decompression key From e32ea04fa957c3ecf9ecb8f4ecba638508e441c1 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 24 Feb 2025 14:58:05 +0100 Subject: [PATCH 114/171] Moonpos update --- commander3/src/comm_tod_mod.f90 | 24 +++++++++++++++---- .../todscripts/dirbe/write_tods_final.py | 22 +++++++++++++++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index c3503cec1..4d519e4b8 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -84,10 +84,14 @@ module comm_tod_mod real(dp) :: t1(3) ! MJD, OBT, SCET for end of chunk real(dp) :: x0_obs(3) ! Observatory position (x,y,z) for start of chunk real(dp) :: x1_obs(3) ! Observatory position (x,y,z) for end of chunk - real(dp) :: x0_earth(3) ! Observatory position (x,y,z) for start of chunk - real(dp) :: x1_earth(3) ! Observatory position (x,y,z) for end of chunk - real(dp) :: xarr_moon(11,3) ! 11 evenly spaced moon positions (x,y,z) - ! including first and last point + real(dp) :: x0_earth(3) ! Earth position (x,y,z) for start of chunk + real(dp) :: x1_earth(3) ! Earth position (x,y,z) for end of chunk + + real(dp), allocatable, dimension(:,:) :: xarr_moon ! Moon positions + real(dp), allocatable, dimension(:,:) :: xarr_earth ! Earth positions + real(dp), allocatable, dimension(:,:) :: xarr_obs ! Observatory positions + real(dp), allocatable, dimension(:) :: time_arr ! Observatory positions + integer(i4b) :: n_interp ! Number of points used to interpolate type(huffcode) :: hkey ! Huffman decompression key type(huffcode) :: todkey ! Huffman decompression key @@ -1006,7 +1010,17 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio call read_hdf(file, slabel // "/common/earthpos", self%x0_earth, opt=.true.) call read_hdf(file, slabel // "/common/earthpos_end", self%x1_earth, opt=.true.) - call read_hdf(file, slabel // "/common/moonpos_arr", self%xarr_moon, opt=.true.) + if (hdf_group_exists(file, slabel // "/common/time_len")) then + ! This specifically creates an array of length n_interp for the use of calculating accurate positions for avoiding the moon. + ! Can be generalized, but for now assumes that each location has the same time array. + call read_hdf(file, slabel // "/" // "common/time_len", self%n_interp, opt=.true.) + allocate(self%xarr_moon(self%n_interp,3), self%xarr_obs(self%n_interp,3), self%xarr_earth(self%n_interp, 3)) + allocate(self%time_arr(self%n_interp)) + call read_hdf(file, slabel // "/common/time_arr", self%time_arr) + call read_hdf(file, slabel // "/common/moonpos_arr", self%xarr_moon) + call read_hdf(file, slabel // "/common/earthpos_arr", self%xarr_obs) + call read_hdf(file, slabel // "/common/satpos_arr", self%xarr_earth) + end if ! Read detector scans allocate(self%d(ndet), buffer_sp(n)) diff --git a/commander3/todscripts/dirbe/write_tods_final.py b/commander3/todscripts/dirbe/write_tods_final.py index 6decb0374..bfff30b10 100644 --- a/commander3/todscripts/dirbe/write_tods_final.py +++ b/commander3/todscripts/dirbe/write_tods_final.py @@ -57,7 +57,7 @@ SAMP_RATE = 1 / 8 SAMP_RATE_DAYS = SAMP_RATE / (24 * 3600) -N_MOON_INTERP = 11 +N_MOON_INTERP = 8640 BEAM_DATA = dirbe_utils.get_beam_data() @@ -118,6 +118,9 @@ class YdayData: earth_pos_start: np.ndarray earth_pos_stop: np.ndarray moon_positions: np.ndarray + earth_positions: np.ndarray + sat_positions: np.ndarray + time_arr: np.ndarray @dataclass @@ -133,6 +136,9 @@ class CIO: earth_pos_start: list[np.ndarray] earth_pos_stop: list[np.ndarray] moon_positions: list[np.ndarray] + earth_positions: list[np.ndarray] + sat_positions: list[np.ndarray] + time_arr: list[np.ndarray] def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: @@ -149,6 +155,9 @@ def get_cios(yday_data: list[YdayData]) -> dict[str, CIO]: earth_pos_start=[yday.earth_pos_start for yday in yday_data], earth_pos_stop=[yday.earth_pos_stop for yday in yday_data], moon_positions=[yday.moon_positions for yday in yday_data], + earth_positions=[yday.earth_positions for yday in yday_data], + sat_positions=[yday.sat_positions for yday in yday_data], + time_arr=[yday.time_arr for yday in yday_data], ) for band in dirbe_utils.BANDS } @@ -200,9 +209,11 @@ def get_yday_cio_data( # Convert time to MJD time = (START_TIME + TimeDelta(time, format="sec", scale="tai")).mjd + time_arr = np.linspace(time[0], time[-1], N_MOON_INTERP) sat_pos_start, earth_pos_start= dirbe_utils.get_sat_and_earth_pos(yday, time[0]) sat_pos_stop, earth_pos_stop = dirbe_utils.get_sat_and_earth_pos(yday, time[-1]) - moon_positions = dirbe_utils.get_moon_pos(yday, np.linspace(time[0], time[-1], N_MOON_INTERP)) + sat_positions, earth_positions = dirbe_utils.get_sat_and_earth_pos(yday, time_arr) + moon_positions = dirbe_utils.get_moon_pos(yday, time_arr) # Gap filling # Get indexes where time difference is larger than 2 sampling rates and split time array @@ -440,7 +451,10 @@ def get_yday_cio_data( sat_pos_stop=sat_pos_stop, earth_pos_start=earth_pos_start, earth_pos_stop=earth_pos_stop, + sat_positions=sat_positions, + earth_positions=earth_positions, moon_positions=moon_positions, + time_arr=time_arr ) @@ -536,6 +550,10 @@ def write_band( comm_tod.add_field(pid_common_group + "/earthpos_end", cio.earth_pos_stop[pid]) comm_tod.add_field(pid_common_group + "/moonpos_arr", cio.moon_positions[pid]) + comm_tod.add_field(pid_common_group + "/satpos_arr", cio.sat_positions[pid]) + comm_tod.add_field(pid_common_group + "/earthpos_arr", cio.earth_positions[pid]) + comm_tod.add_field(pid_common_group + "/time_arr", cio.time_arr[pid]) + comm_tod.add_field(pid_common_group + "/time_len", len(cio.time_arr[pid])) comm_tod.add_attribute(pid_common_group + "/satpos", "index", "X, Y, Z") comm_tod.add_attribute( From 7c46e3edb1906760cb13ea469af0663a3b7ff8a8 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 24 Feb 2025 16:44:47 +0100 Subject: [PATCH 115/171] Started implementing moon and earth mapping --- cmake/projects/commander3.cmake | 1 + commander3/src/Makefile | 4 +- commander3/src/comm_data_mod.f90 | 58 ++- commander3/src/comm_defs.f90 | 6 + commander3/src/comm_output_mod.f90 | 8 + commander3/src/comm_param_mod.f90 | 24 +- commander3/src/comm_tod_dirbe_mod.f90 | 17 +- commander3/src/comm_tod_driver_mod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 534 ++++++++++++++++--------- commander3/src/comm_zodi_mod.f90 | 41 +- commander3/src/comm_zodi_samp_mod.f90 | 110 +++-- commander3/src/commander.f90 | 9 +- 12 files changed, 560 insertions(+), 254 deletions(-) diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 79188261f..ace41804c 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -59,6 +59,7 @@ set(sources # TOD processing modules ${COMMANDER3_SOURCE_DIR}/comm_tod_noise_psd_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_mod.f90 + ${COMMANDER3_SOURCE_DIR}/comm_tod_pixhist_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_driver_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_mapmaking_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_tod_lfi_mod.f90 diff --git a/commander3/src/Makefile b/commander3/src/Makefile index d29ffedae..c5f665d5a 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -93,6 +93,7 @@ F90SOURCES=hashtbl.f90 \ comm_f_int_0d_mod.f90 \ comm_f_int_2d_mod.f90 \ comm_fft_mod.f90 \ + comm_tod_pixhist_mod.f90 \ comm_tod_noise_psd_mod.f90 \ comm_tod_mod.f90 \ comm_tod_mapmaking_mod.f90 \ @@ -197,6 +198,7 @@ comm_tod_simulations_mod.o : comm_hdf_mod.o comm_fft_mod.o comm_shared_arr_mod. comm_tod_noise_psd_mod.o : comm_utils.o comm_tod_jump_mod.o : comm_utils.o comm_tod_orbdipole_mod.o : comm_map_mod.o +comm_tod_pixhist_mod.o : comm_tod_mod.o comm_tod_driver_mod.o comm_tod_mod.o : comm_fft_mod.o comm_huffman_mod.o comm_conviqt_mod.o comm_tod_orbdipole_mod.o comm_tod_noise_psd_mod.o comm_shared_arr_mod.o comm_tod_pointing_mod.o : comm_tod_mod.o comm_tod_noise_mod.o : comm_tod_mod.o invsamp_mod.o @@ -219,7 +221,7 @@ comm_tod_lfi_mod.o : comm_tod_driver_mod.o comm_tod_adc_mod.o comm_tod_spider_mod.o : comm_tod_driver_mod.o comm_tod_spider_smod.o : comm_tod_spider_mod.o comm_tod_wmap_mod.o : comm_tod_driver_mod.o -comm_tod_dirbe_mod.o : comm_tod_driver_mod.o +comm_tod_dirbe_mod.o : comm_tod_driver_mod.o comm_tod_pixhist_mod.o comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_tod_inst_mod.o : comm_tod_lb_mod.o comm_tod_lfi_mod.o comm_tod_spider_mod.o comm_tod_wmap_mod.o comm_tod_dirbe_mod.o comm_tod_hfi_mod.o #comm_tod_quiet_mod.o diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 05ad1f1a0..16e1e7ca7 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -673,7 +673,7 @@ subroutine get_mapfile(cpar, band, mapfile) integer(i4b), intent(in) :: band character(len=*), intent(out) :: mapfile - integer(i4b) :: i, n, unit + integer(i4b) :: i, j, n, unit character(len=512) :: filename filename = trim(adjustl(cpar%ds_mapfile(band))) @@ -698,6 +698,7 @@ subroutine initialize_inter_tod_params(cpar) type(comm_params), intent(in) :: cpar integer(i4b) :: i, j + real(sp) :: elon character(len=512) :: model ! Initialize solar centric maps @@ -725,6 +726,61 @@ subroutine initialize_inter_tod_params(cpar) end if end do + ! Initialize Moon centric maps + do i = 1, numband + if (trim(data(i)%tod_type) == 'none') cycle + data(i)%tod%map_moon_allocated = .false. + model = cpar%ds_tod_moon_model(data(i)%tod%band) + if (trim(model) == 'none') cycle + if (model(1:1) == '>') then + do j = 1, numband + if (trim(data(j)%label) == trim(model(2:))) then + data(i)%tod%map_moon => data(j)%tod%map_moon + exit + end if + end do + cycle + else + data(i)%tod%map_moon_allocated = .true. + allocate(data(i)%tod%map_moon(0:data(i)%info%npix-1,1)) + if (trim(cpar%ds_tod_moon_init(data(i)%tod%band)) == 'none') then + data(i)%tod%map_moon = 0.d0 + else + call read_map(cpar%ds_tod_moon_init(data(i)%tod%band), data(i)%tod%map_moon) + end if + end if + end do + + ! Initialize Earth elongation profiles + do i = 1, numband + if (trim(data(i)%tod_type) == 'none') cycle + data(i)%tod%map_earth_allocated = .false. + model = cpar%ds_tod_earth_model(data(i)%tod%band) + if (trim(model) == 'none') cycle + if (model(1:1) == '>') then + do j = 1, numband + if (trim(data(j)%label) == trim(model(2:))) then + data(i)%tod%map_earth => data(j)%tod%map_earth + exit + end if + end do + cycle + else + data(i)%tod%map_earth_allocated = .true. + allocate(data(i)%tod%map_earth(1:NBIN_EARTH_ELON)) + if (trim(cpar%ds_tod_earth_init(data(i)%tod%band)) == 'none') then + data(i)%tod%map_earth = 0.d0 + else + open(58,file=trim(cpar%ds_tod_earth_init(data(i)%tod%band))) + do j = 1, NBIN_EARTH_ELON + read(58,*) elon, data(i)%tod%map_earth(j) + end do + close(58) + end if + end if + end do + + end subroutine initialize_inter_tod_params diff --git a/commander3/src/comm_defs.f90 b/commander3/src/comm_defs.f90 index 755f2a162..f821fd315 100644 --- a/commander3/src/comm_defs.f90 +++ b/commander3/src/comm_defs.f90 @@ -40,5 +40,11 @@ module comm_defs !************************************************** integer(i4b), parameter :: GAIN = 1 integer(i4b), parameter :: NOISEAMP = 2 + + !************************************************** + ! Constants + !************************************************** + + integer(i4b), parameter :: NBIN_EARTH_ELON = 180 end module comm_defs diff --git a/commander3/src/comm_output_mod.f90 b/commander3/src/comm_output_mod.f90 index 3b57d08ac..f6e1728a9 100644 --- a/commander3/src/comm_output_mod.f90 +++ b/commander3/src/comm_output_mod.f90 @@ -453,6 +453,14 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) do i = 1, numband if (trim(data(i)%tod_type) == 'none') cycle if (data(i)%tod%map_solar_allocated) call write_map2(trim(cpar%outdir) // '/tod_'//trim(data(i)%label)//'_solar_c'//ctext//'_k' // itext // '.fits', data(i)%tod%map_solar) + if (data(i)%tod%map_moon_allocated) call write_map2(trim(cpar%outdir) // '/tod_'//trim(data(i)%label)//'_moon_c'//ctext//'_k' // itext // '.fits', data(i)%tod%map_moon) + if (data(i)%tod%map_earth_allocated) then + open(58,file=trim(cpar%outdir) // '/tod_'//trim(data(i)%label)//'_earth_c'//ctext//'_k' // itext // '.dat') + do j = 1, NBIN_EARTH_ELON + write(58,*) real(j+0.5,sp)*180./NBIN_EARTH_ELON, data(i)%tod%map_earth(j) + end do + close(58) + end if end do end if end if diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 15db50771..efbf94365 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -85,7 +85,8 @@ module comm_param_mod integer(i4b) :: output_4D_map_nth_iter, output_aux_maps logical(lgt) :: include_tod_zodi, sample_zodi, incl_zodi_solar_comp integer(i4b) :: zodi_solar_nside - character(len=2048) :: zodi_solar_initmap, zodi_static_bands + logical(lgt) :: sample_solar_maps, sample_moon_maps, sample_earth_maps + character(len=2048) :: zodi_solar_initmap, zodi_moon_initmap, zodi_earth_initmap, zodi_static_bands real(dp), allocatable, dimension(:) :: fwhm_smooth real(dp), allocatable, dimension(:) :: fwhm_postproc_smooth integer(i4b), allocatable, dimension(:) :: lmax_smooth @@ -181,6 +182,10 @@ module comm_param_mod character(len=2048), allocatable, dimension(:) :: ds_tod_solar_mask character(len=2048), allocatable, dimension(:) :: ds_tod_solar_model character(len=2048), allocatable, dimension(:) :: ds_tod_solar_init + character(len=2048), allocatable, dimension(:) :: ds_tod_moon_model + character(len=2048), allocatable, dimension(:) :: ds_tod_moon_init + character(len=2048), allocatable, dimension(:) :: ds_tod_earth_model + character(len=2048), allocatable, dimension(:) :: ds_tod_earth_init ! Component parameters character(len=2048) :: cs_inst_parfile @@ -526,7 +531,10 @@ subroutine read_global_params_hash(htbl, cpar) call get_parameter_hashtable(htbl, 'TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER', par_int=cpar%output_aux_maps) call get_parameter_hashtable(htbl, 'TOD_INCLUDE_ZODI', par_lgt=cpar%include_TOD_zodi) if (cpar%include_TOD_zodi) then - call get_parameter_hashtable(htbl, 'SAMPLE_ZODI', par_lgt=cpar%sample_zodi) + call get_parameter_hashtable(htbl, 'SAMPLE_ZODI', par_lgt=cpar%sample_zodi) + call get_parameter_hashtable(htbl, 'SAMPLE_SOLAR_MAPS', par_lgt=cpar%sample_solar_maps) + call get_parameter_hashtable(htbl, 'SAMPLE_MOON_MAPS', par_lgt=cpar%sample_moon_maps) + call get_parameter_hashtable(htbl, 'SAMPLE_EARTH_MAPS', par_lgt=cpar%sample_earth_maps) call get_parameter_hashtable(htbl, 'ZODI_USE_SOLAR_CENTRIC_COMP', par_lgt=cpar%incl_zodi_solar_comp) if (cpar%incl_zodi_solar_comp) then call get_parameter_hashtable(htbl, 'ZODI_STATIC_COMP_NSIDE', par_int=cpar%zodi_solar_nside) @@ -607,6 +615,8 @@ subroutine read_data_params_hash(htbl, cpar) allocate(cpar%ds_tod_instfile(n), cpar%ds_tod_dets(n), cpar%ds_tod_scanrange(n,2)) allocate(cpar%ds_tod_tot_numscan(n), cpar%ds_tod_flag(n), cpar%ds_tod_abscal(n), cpar%ds_tod_halfring(n), cpar%ds_tod_subtract_zodi(n), cpar%ds_tod_freq(n)) allocate(cpar%ds_tod_solar_model(n), cpar%ds_tod_solar_mask(n), cpar%ds_tod_solar_init(n)) + allocate(cpar%ds_tod_moon_model(n), cpar%ds_tod_moon_init(n)) + allocate(cpar%ds_tod_earth_model(n), cpar%ds_tod_earth_init(n)) cpar%ds_nside = 0 ! Zodi mod currently uses cpar nsides to cache some stuff. Setting to 0 to filter unique nsides do i = 1, n @@ -684,6 +694,14 @@ subroutine read_data_params_hash(htbl, cpar) & par_string=cpar%ds_tod_solar_mask(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_SOLAR_CENTRIC_INITMAP'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_solar_init(i), path=.true.) + call get_parameter_hashtable(htbl, 'BAND_TOD_MOON_CENTRIC_MODEL'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_moon_model(i)) + call get_parameter_hashtable(htbl, 'BAND_TOD_MOON_CENTRIC_INITMAP'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_moon_init(i), path=.true.) + call get_parameter_hashtable(htbl, 'BAND_TOD_EARTH_CENTRIC_MODEL'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_earth_model(i)) + call get_parameter_hashtable(htbl, 'BAND_TOD_EARTH_CENTRIC_INITMAP'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_earth_init(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_FILELIST'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_filelist(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_JUMPLIST'//itext, len_itext=len_itext, & @@ -3529,6 +3547,8 @@ subroutine validate_params(cpar) call validate_file(trim(cpar%ds_tod_procmask2(i)), 'BAND_TOD_SMALL_PROCMASK'//itext) ! Procmask2 call validate_file(trim(cpar%ds_tod_solar_mask(i)), 'BAND_TOD_SOLAR_CENTRIC_MASK'//itext) ! Solar centric/sidelobe mask call validate_file(trim(cpar%ds_tod_solar_init(i)), 'BAND_TOD_SOLAR_CENTRIC_INITMAP'//itext) ! Initial solar centric map + call validate_file(trim(cpar%ds_tod_moon_init(i)), 'BAND_TOD_MOON_CENTRIC_INITMAP'//itext) ! Initial moon centric map + call validate_file(trim(cpar%ds_tod_earth_init(i)), 'BAND_TOD_EARTH_CENTRIC_INITMAP'//itext) ! Initial Earth centric map call validate_file(trim(cpar%ds_tod_filelist(i)), 'BAND_TOD_FILELIST'//itext) ! Filelist if (trim(cpar%ds_tod_jumplist(i)) /= 'none') then call validate_file(trim(cpar%ds_tod_jumplist(i)), 'BAND_TOD_JUMPLIST'//itext) ! Jumplist diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 17334ffaa..f879c2ecd 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -115,6 +115,8 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) c%correct_orb = .false. c%orb_4pi_beam = .false. c%sample_zodi = cpar%sample_zodi .and. c%subtract_zodi ! Sample zodi parameters + c%use_moon_point = .true. + c%use_earth_elon = .true. c%symm_flags = .false. ! c%chisq_threshold = 100000000000.d0 !20.d0 ! 9.d0 c%chisq_threshold = 50000. @@ -249,7 +251,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, type(map_ptr), dimension(1:,1:), intent(inout), optional :: map_gain ! (ndet,1) real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps, tod_start_idx, n_tod_tot, n_comps_to_fit - logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr, apply_dynamic_mask + logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, sample_gain, output_scanlist, sample_zodi, use_k98_samp_groups, output_zodi_comps, sample_ncorr, only_solar_mask type(comm_binmap) :: binmap type(comm_scandata) :: sd character(len=4) :: ctext, myid_text @@ -298,11 +300,11 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, if (trim(self%freq(1:2)) == '05' .or. trim(self%freq(1:2)) == '06' .or. & & trim(self%freq(1:2)) == '07' .or. trim(self%freq(1:2)) == '08' .or. & & trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then - sample_gain = .true. - apply_dynamic_mask = .true. + sample_gain = iter > 1 + only_solar_mask = .false. else - sample_gain = .false. - apply_dynamic_mask = .false. + sample_gain = iter > 1 + only_solar_mask = .true. end if !sample_gain = .false. @@ -328,7 +330,6 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call distribute_sky_maps(self, map_in, 1.e0, map_sky) ! uK to K allocate(m_gain(nmaps,self%nobs,0:self%ndet,1)) call distribute_sky_maps(self, map_gain, 1.e0, m_gain) ! uK to K - allocate(m_buf(0:npix-1,nmaps), procmask(0:npix-1), procmask2(0:npix-1)) call self%procmask%bcast_fullsky_map(m_buf); procmask = m_buf(:,1) call self%procmask2%bcast_fullsky_map(m_buf); procmask2 = m_buf(:,1) @@ -388,11 +389,11 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) ! Create dynamic mask - if (self%first_call .and. apply_dynamic_mask) then + if (self%first_call) then do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & - & [-5.,5.], sd%mask(:,j), sd%flag(:,j)) + & [-5.,5.], sd%mask(:,j), sd%flag(:,j), only_solar_mask) end do call sd%dealloc if (.not. any(self%scans(i)%d%accept)) cycle diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 690d34993..b63a29c9a 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -254,7 +254,7 @@ subroutine init_scan_data_singlehorn(self, tod, scan, map_sky, map_gain, procmas !!$ & emissivity=tod%zodi_emissivity, & !!$ & albedo=tod%zodi_albedo & !!$ &) - call get_s_tot_zodi(zodi_model, tod, j, scan, self%s_zodi(:, j), pix_dynamic=self%pix(:,j,:), pix_static=tod%scans(scan)%d(j)%pix_sol, s_scat=self%s_zodi_scat(:,:,j), s_therm=self%s_zodi_therm(:,:,j)) + call get_s_tot_zodi(zodi_model, tod, j, scan, self%s_zodi(:, j), pix_dynamic=self%pix(:,j,:), s_scat=self%s_zodi_scat(:,:,j), s_therm=self%s_zodi_therm(:,:,j)) !!$ if (tod%myid == 0) then !!$ open(58,file='zodi.dat') !!$ do k = 1, size(self%s_zodi(:,j)) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 9d97b9d3c..aa55f9307 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -51,7 +51,8 @@ module comm_tod_mod integer(i4b), allocatable, dimension(:,:) :: jumpflag_range ! Beginning and end tod index of regions where jumps occur real(dp), allocatable, dimension(:) :: baseline ! Polynomial coefficients for baseline function integer(i4b), allocatable, dimension(:,:) :: pix_sol ! Discretized pointing in solar centric coordinates, for zodi and sidelobe mapping - integer(i4b), allocatable, dimension(:,:) :: psi_sol ! Discretized polarization angle in solar centric coordinates, for zodi and sidelobe mapping + integer(i4b), allocatable, dimension(:,:) :: pix_moon ! Discretized pointing in Moon centric coordinates, for zodi and sidelobe mapping + real(sp), allocatable, dimension(:,:) :: earth_elon ! Earth elongation, for sidelobe mapping and masking ! Zodi sampling structures (downsampled and precomputed quantities. only allocated if zodi sampling is true) logical(lgt), allocatable, dimension(:) :: zodi_glitch_mask @@ -164,6 +165,8 @@ module comm_tod_mod logical(lgt) :: sample_zodi ! Sample zodi model parameters (defined in the parameter file) logical(lgt) :: output_zodi_comps ! Output zodi components logical(lgt) :: use_solar_point ! Compute solar centric pointing, for zodi or sidelobe mapping + logical(lgt) :: use_moon_point ! Compute Moon centric pointing, for zodi or sidelobe mapping + logical(lgt) :: use_earth_elon ! Compute Earth elongation real(sp) :: sol_elong_range(2) ! Acceptable solar elongation range logical(lgt) :: correct_sl ! Subtract sidelobes logical(lgt) :: correct_orb ! Subtract CMB dipole @@ -193,7 +196,11 @@ module comm_tod_mod !class(comm_map), pointer :: mask_solar => null() ! Solar centric/sidelobe mask real(dp), allocatable, dimension(:,:) :: mask_solar ! Solar centric/sidelobe mask logical(lgt) :: map_solar_allocated + logical(lgt) :: map_moon_allocated + logical(lgt) :: map_earth_allocated real(dp), pointer, dimension(:,:) :: map_solar ! Full-sky solar centric/sidelobe model + real(dp), pointer, dimension(:,:) :: map_moon ! Full-sky Moon centric/sidelobe model + real(dp), pointer, dimension(:) :: map_earth ! Earth elongation centric/sidelobe model ! class(comm_map), pointer :: map_solar => null() ! Solar centric/sidelobe model class(comm_mapinfo), pointer :: info => null() ! Map definition class(comm_mapinfo), pointer :: slinfo => null() ! Sidelobe map info @@ -393,6 +400,8 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%sample_zodi = cpar%sample_zodi .and. self%subtract_zodi end if self%use_solar_point = self%subtract_zodi + self%use_moon_point = .false. + self%use_earth_elon = .false. if (trim(self%tod_type)=='SPIDER') then self%orbital = .false. @@ -534,28 +543,33 @@ subroutine precompute_lookups(self) real(dp) :: f_fill, f_fill_lim(3), theta, phi integer(i4b) :: i, j, k, l, ierr - integer(i4b), allocatable, dimension(:) :: pix + integer(i4b), allocatable, dimension(:) :: pix, psi ! Construct observed pixel array allocate(self%pix2ind(0:12*self%nside**2-1)) self%pix2ind = -2 do i = 1, self%nscan - allocate(pix(self%scans(i)%ntod)) + allocate(pix(self%scans(i)%ntod), psi(self%scans(i)%ntod)) if (self%nhorn == 2) then - if (self%use_solar_point) allocate(self%scans(i)%d(1)%pix_sol(self%scans(i)%ntod,self%nhorn), self%scans(i)%d(1)%psi_sol(self%scans(i)%ntod,self%nhorn)) + if (self%use_solar_point) allocate(self%scans(i)%d(1)%pix_sol(self%scans(i)%ntod,self%nhorn)) + if (self%use_moon_point) allocate(self%scans(i)%d(1)%pix_moon(self%scans(i)%ntod,self%nhorn)) + if (self%use_earth_elon) allocate(self%scans(i)%d(1)%earth_elon(self%scans(i)%ntod,self%nhorn)) do l = 1, self%nhorn call huffman_decode2_int(self%scans(i)%hkey, self%scans(i)%d(1)%pix(l)%p, pix) self%pix2ind(pix(1)) = -1 do k = 2, self%scans(i)%ntod self%pix2ind(pix(k)) = -1 end do - if (self%use_solar_point) then - call compute_solar_centered_pointing(self, i, j, pix, 0*pix, self%scans(i)%d(j)%pix_sol(:,l), self%scans(i)%d(j)%psi_sol(:,l)) + if (self%use_solar_point) call compute_solar_centered_pointing(self, i, 1, pix, self%scans(i)%d(1)%pix_sol(:,l)) + if (self%use_moon_point) then + call huffman_decode2_int(self%scans(i)%hkey, self%scans(i)%d(1)%psi(l)%p, psi) + call compute_moon_centered_pointing(self, i, 1, pix, psi, self%scans(i)%d(1)%pix_moon(:,l)) end if + if (self%use_earth_elon) call compute_earth_elongation(self, i, 1, pix, self%scans(i)%d(1)%earth_elon(:,l)) end do else do j = 1, self%ndet - if (self%use_solar_point) allocate(self%scans(i)%d(j)%pix_sol(self%scans(i)%ntod,self%nhorn), self%scans(i)%d(j)%psi_sol(self%scans(i)%ntod,self%nhorn)) + if (self%use_solar_point) allocate(self%scans(i)%d(j)%pix_sol(self%scans(i)%ntod,self%nhorn)) do l = 1, self%nhorn call huffman_decode(self%scans(i)%hkey, self%scans(i)%d(j)%pix(l)%p, pix) self%pix2ind(pix(1)) = -1 @@ -567,9 +581,12 @@ subroutine precompute_lookups(self) end if self%pix2ind(pix(k)) = -1 end do - if (self%use_solar_point) then - call compute_solar_centered_pointing(self, i, j, pix, 0*pix, self%scans(i)%d(j)%pix_sol(:,l), self%scans(i)%d(j)%psi_sol(:,l)) + if (self%use_solar_point) call compute_solar_centered_pointing(self, i, j, pix, self%scans(i)%d(j)%pix_sol(:,l)) + if (self%use_moon_point) then + call huffman_decode2_int(self%scans(i)%hkey, self%scans(i)%d(j)%psi(l)%p, psi) + call compute_moon_centered_pointing(self, i, j, pix, psi, self%scans(i)%d(j)%pix_moon(:,l)) end if + if (self%use_earth_elon) call compute_earth_elongation(self, i, j, pix, self%scans(i)%d(j)%earth_elon(:,l)) end do end do end if @@ -1632,7 +1649,21 @@ subroutine initHDF(self, chainfile, iter, map, rms) else write(*,*) 'Solar map field not in existing chain, keeping default' end if - end if + end if + if (self%map_moon_allocated == .true.) then + if (hdf_group_exists(chainfile, trim(adjustl(path))//'map_moon')) then + call read_hdf(chainfile, trim(adjustl(path))//'map_moon', self%map_moon) + else + write(*,*) 'Moon map field not in existing chain, keeping default' + end if + end if + if (self%map_earth_allocated == .true.) then + if (hdf_group_exists(chainfile, trim(adjustl(path))//'map_earth')) then + call read_hdf(chainfile, trim(adjustl(path))//'map_earth', self%map_earth) + else + write(*,*) 'Earth map field not in existing chain, keeping default' + end if + end if end if @@ -2528,12 +2559,12 @@ subroutine decompress_tod(self, scan, det, tod) end subroutine decompress_tod - subroutine compute_solar_centered_pointing(tod, scan, det, pix, psi, pix_sol, psi_sol) + subroutine compute_solar_centered_pointing(tod, scan, det, pix, pix_sol) implicit none class(comm_tod), intent(in) :: tod integer(i4b), intent(in) :: scan, det - integer(i4b), dimension(:),intent(in) :: pix, psi - integer(i4b), dimension(:),intent(out) :: pix_sol, psi_sol + integer(i4b), dimension(:),intent(in) :: pix + integer(i4b), dimension(:),intent(out) :: pix_sol integer(i4b) :: i, j real(dp) :: alpha, lat, lon, vec(3), vec0(3), M_sun(3,3), x_sun(3), theta_sun, phi_sun, M_ecl2gal(3,3) @@ -2553,10 +2584,70 @@ subroutine compute_solar_centered_pointing(tod, scan, det, pix, psi, pix_sol, ps vec0 = matmul(M_sun, vec0) ! Solar-centered coordinates call vec2pix_ring(tod%nside, vec0, pix_sol(j)) end do - psi_sol = 0 ! Not computed yet end subroutine compute_solar_centered_pointing + subroutine compute_moon_centered_pointing(tod, scan, det, pix, psi, pix_moon) + implicit none + class(comm_tod), intent(in) :: tod + integer(i4b), intent(in) :: scan, det + integer(i4b), dimension(:),intent(in) :: pix, psi + integer(i4b), dimension(:),intent(out) :: pix_moon + + integer(i4b) :: i, j + real(dp) :: psi0 + real(dp) :: x_moon(3), x_obs(3), x_obs2moon(3), theta0, phi0, alpha, vec(3), vec0(3), M(3,3), M_ecl2gal(3,3) + + call ecl_to_gal_rot_mat(M_ecl2gal) + + do j = 1, tod%scans(scan)%ntod + alpha = real(j-1,dp) / real(tod%scans(scan)%ntod-1,dp) + x_obs = (1.d0-alpha) * tod%scans(scan)%x0_obs + alpha * tod%scans(scan)%x1_obs ! Observatory position at time t in heliocentric/Ecliptic coordinates + alpha = 0.d0 + !x_moon = (1.d0-alpha) * tod%scans(scan)%x0_moon + alpha * tod%scans(scan)%x1_moon ! Moon position at time t in heliocentric/Ecliptic coordinates + + x_obs2moon = x_moon - x_obs ! Earth position relative to observatory in Ecliptic coordinates + x_obs2moon = x_obs2moon / sqrt(sum(x_obs2moon**2)) ! Unit vector + x_obs2moon = matmul(M_ecl2gal, x_obs2moon) ! Moon position in Galactic coordinates + + ! Compute pointing in Moon centered coordinates + psi0 = psi(j) * 2.d0*pi/4096.d0 ! Fix this + call pix2ang_ring(tod%nside, pix(j), theta0, phi0) ! Galactic coordinates + call compute_euler_matrix_zyz(-psi0, -theta0, -phi0, M) + vec = matmul(M, x_obs2moon) + call vec2pix_ring(tod%nside, vec, pix_moon(j)) + end do + + end subroutine compute_moon_centered_pointing + + subroutine compute_earth_elongation(tod, scan, det, pix, earth_elon) + implicit none + class(comm_tod), intent(in) :: tod + integer(i4b), intent(in) :: scan, det + integer(i4b), dimension(:),intent(in) :: pix + real(sp), dimension(:),intent(out) :: earth_elon + + integer(i4b) :: i, j + real(dp) :: x_obs2earth(3), x_obs(3), x_earth(3), alpha, lat, lon, vec(3), vec0(3), M_sun(3,3), x_sun(3), theta_sun, phi_sun, M_ecl2gal(3,3) + + call ecl_to_gal_rot_mat(M_ecl2gal) + do j = 1, tod%scans(scan)%ntod + alpha = real(j-1,dp) / real(tod%scans(scan)%ntod-1,dp) + x_obs = (1.d0-alpha) * tod%scans(scan)%x0_obs + alpha * tod%scans(scan)%x1_obs ! Observatory position at time t in heliocentric/Ecliptic coordinates + alpha = 0.d0 + x_earth = (1.d0-alpha) * tod%scans(scan)%x0_earth + alpha * tod%scans(scan)%x1_earth ! Earth position at time t in heliocentric/Ecliptic coordinates + + x_obs2earth = x_earth - x_obs ! Earth position relative to observatory in Ecliptic coordinates + x_obs2earth = x_obs2earth / sqrt(sum(x_obs2earth**2)) ! Unit vector + + call pix2vec_ring(tod%nside, pix(j), vec0) ! Satellite pointing in Galactic coordinates + vec0 = matmul(transpose(M_ecl2gal), vec0) ! Satellite pointing in Ecliptic coordinates + + earth_elon(j) = acos(max(min(sum(vec0 * x_obs2earth),1.d0),-1.d0)) + end do + + end subroutine compute_earth_elongation + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Subroutine to save time-ordered-data chunk @@ -2940,7 +3031,7 @@ subroutine clear_zodi_cache(self, obs_time) end if end subroutine clear_zodi_cache - subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) + subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only_solar_mask) implicit none class(comm_tod), intent(inout) :: self integer(i4b), intent(in) :: scan, det @@ -2948,226 +3039,243 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) real(sp), dimension(2), intent(in) :: rms_range real(sp), dimension(:), intent(inout) :: mask integer(i4b), dimension(:), intent(inout) :: flag + logical(lgt), intent(in) :: only_solar_mask integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut real(dp) :: rms0 real(sp) :: var0, threshold, gain + logical(lgt), dimension(8) :: apply_cut logical(lgt), allocatable, dimension(:) :: cut integer(i4b), allocatable, dimension(:,:) :: bad, buffer real(sp), allocatable, dimension(:) :: mask_dyn, var_window if (sum(mask) == 0) return + + apply_cut(1) = .true. ! Extreme outliers + apply_cut(2) = .true. ! Single sample outliers + apply_cut(3) = .true. ! Excess variance in windows of 5 samples + apply_cut(4) = .true. ! Excess variance in windows of 50 samples + apply_cut(5) = .true. ! Excess variance in windows of 500 samples + apply_cut(6) = .true. ! Isolated samples + apply_cut(7) = .true. ! Long chunks with many masked samples + apply_cut(8) = .true. ! Solar mask + if (only_solar_mask) apply_cut(1:7) = .false. + ntod = size(res) ntot = count(iand(flag,self%flag0) .eq. 0) nmax = 1000 gain = self%scans(scan)%d(det)%gain + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flagging -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod + ! Generate dynamic mask allocate(mask_dyn(ntod)) mask_dyn = 1.0 - ! Solar-centric mask - ncut = 0 - if (allocated(self%mask_solar) .and. self%use_solar_point) then +!!$ open(58, file='var0.dat') +!!$ do i = 1, ntod +!!$ if (mask(i) == 1.) write(58,*) i, res(i) +!!$ end do +!!$ close(58) + + if (apply_cut(1)) then + ! Extreme outliers + threshold = 20. ! White noise sigma + ncut = 0 do i = 1, ntod - if (mask(i) == 0.) cycle - if (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) then + if (mask(i) == 1. .and. abs(res(i)) > threshold) then mask_dyn(i) = 0. mask(i) = 0. flag(i) = huge(flag(i)) - ncut = ncut+1 + ncut = ncut + 1 end if end do + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms + if (apply_cut(2)) then + allocate(cut(ntod)) + ncut = 0 + ! open(58, file='var1.dat') + do iter = 1, 1 + ! Compute full-scan, masked rms0 + rms0 = 0.d0 + n = 0 + do i = 1, ntod + if (mask(i) == 1.) then + rms0 = rms0 + res(i)**2 + n = n + 1 + end if + end do + rms0 = sqrt(rms0/(n-1)) + !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 + + do i = 1, ntod + cut(i) = (mask(i) == 1. .and. (res(i) < rms_range(1)*rms0 .or. res(i) > rms_range(2)*rms0)) + !if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) + end do + + ! Apply RMS selection criterium + if (cut(1) .and. (.not. cut(2) .or. mask(2) == 0.)) then + mask_dyn(1) = 0. + mask(1) = 0. + flag(1) = huge(flag(1)) + ncut = ncut + 1 + end if + do i = 2, ntod-1 + if (cut(i) .and. (.not. cut(i-1) .or. mask(i-1) == 0.) .and. (.not. cut(i+1) .or. mask(i+1) == 0.)) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut + 1 + end if + end do + if (cut(ntod) .and. (.not. cut(ntod-1) .or. mask(ntod-1) == 0.)) then + mask_dyn(ntod) = 0. + mask(ntod) = 0. + flag(ntod) = huge(flag(ntod)) + ncut = ncut + 1 + end if + end do + !close(58) + deallocate(cut) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + end if -!!$ open(58, file='var0.dat') -!!$ do i = 1, ntod -!!$ if (mask(i) == 1.) write(58,*) i, res(i) -!!$ end do -!!$ close(58) - - ! Extreme outliers - threshold = 20. ! White noise sigma - ncut = 0 - do i = 1, ntod - if (mask(i) == 1. .and. abs(res(i)) > threshold) then - mask_dyn(i) = 0. - mask(i) = 0. - flag(i) = huge(flag(i)) - ncut = ncut + 1 - end if - end do - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut + if (apply_cut(3)) then + ! Look for excess variance excess in small windows; typically cosmic rays and other short glitches + allocate(var_window(ntod)) + window = 5; threshold = 3. + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + var0 = sqrt(var0) + ncut = 0 + !open(58, file='var2.dat') + do i = 1, ntod + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + !if (mask(k) == 1) then + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + !close(58) + deallocate(var_window) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + end if - ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms - allocate(cut(ntod)) - ncut = 0 -! open(58, file='var1.dat') - do iter = 1, 1 - ! Compute full-scan, masked rms0 - rms0 = 0.d0 - n = 0 + if (apply_cut(4)) then + ! Look for excess variance excess in intermediate windows + allocate(var_window(ntod)) + window = 50; threshold = 2.0 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 + !open(58, file='var3.dat') do i = 1, ntod - if (mask(i) == 1.) then - rms0 = rms0 + res(i)**2 - n = n + 1 + !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do end if end do - rms0 = sqrt(rms0/(n-1)) - !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 + !close(58) + deallocate(var_window) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + end if + if (apply_cut(5)) then + ! Look for excess variance excess in large windows + allocate(var_window(ntod)) + window = 500; threshold = 1.5 + call compute_running_variance(res, mask, window, var_window, var_mean=var0) + var_window = sqrt(var_window) + ncut = 0 + ! open(58, file='var3.dat') do i = 1, ntod - cut(i) = (mask(i) == 1. .and. (res(i) < rms_range(1)*rms0 .or. res(i) > rms_range(2)*rms0)) - !if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) + ! if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1. .and. var_window(i) > threshold*var0) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + !if (mask(k) == 1) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if end do - - ! Apply RMS selection criterium - if (cut(1) .and. (.not. cut(2) .or. mask(2) == 0.)) then + ! close(58) + deallocate(var_window) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + end if + + if (apply_cut(6)) then + ! Remove isolated samples + ncut = 0 + if (mask(1) == 1. .and. mask(2) == 0.) then mask_dyn(1) = 0. mask(1) = 0. flag(1) = huge(flag(1)) ncut = ncut + 1 end if do i = 2, ntod-1 - if (cut(i) .and. (.not. cut(i-1) .or. mask(i-1) == 0.) .and. (.not. cut(i+1) .or. mask(i+1) == 0.)) then + if (mask(i-1) == 0. .and. mask(i) == 1. .and. mask(i+1) == 0.) then mask_dyn(i) = 0. mask(i) = 0. flag(i) = huge(flag(i)) ncut = ncut + 1 end if end do - if (cut(ntod) .and. (.not. cut(ntod-1) .or. mask(ntod-1) == 0.)) then + if (mask(ntod) == 1. .and. mask(ntod-1) == 0.) then mask_dyn(ntod) = 0. mask(ntod) = 0. flag(ntod) = huge(flag(ntod)) ncut = ncut + 1 end if - end do - !close(58) - deallocate(cut) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut - - ! Look for excess variance excess in small windows; typically cosmic rays and other short glitches - allocate(var_window(ntod)) - window = 5; threshold = 3. - call compute_running_variance(res, mask, window, var_window, var_mean=var0) - var_window = sqrt(var_window) - var0 = sqrt(var0) - ncut = 0 - !open(58, file='var2.dat') - do i = 1, ntod - !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 - if (mask(i) == 1. .and. var_window(i) > threshold*var0) then - do k = max(i-window,1), min(i+window,ntod) - !if (mask(k) == 1) then - if (iand(flag(k),self%flag0) .eq. 0) then - mask_dyn(k) = 0. - mask(k) = 0. - flag(k) = huge(flag(k)) - ncut = ncut + 1 - end if - end do - end if - end do - !close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut - - ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. - window = 50; threshold = 2.0 - call compute_running_variance(res, mask, window, var_window, var_mean=var0) - var_window = sqrt(var_window) - ncut = 0 - !open(58, file='var3.dat') - do i = 1, ntod - !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) - if (mask(i) == 1. .and. var_window(i) > threshold*var0) then - do k = max(i-window,1), min(i+window,ntod) - if (iand(flag(k),self%flag0) .eq. 0) then - !if (mask(k) == 1) then - mask_dyn(k) = 0. - mask(k) = 0. - flag(k) = huge(flag(k)) - ncut = ncut + 1 - end if - end do - end if - end do - !close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut - - ! Look for excess variance excess in small windows; typically detector instability, cosmic ray showers etc. - window = 500; threshold = 1.5 - call compute_running_variance(res, mask, window, var_window, var_mean=var0) - var_window = sqrt(var_window) - ncut = 0 -! open(58, file='var3.dat') - do i = 1, ntod -! if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) - if (mask(i) == 1. .and. var_window(i) > threshold*var0) then - do k = max(i-window,1), min(i+window,ntod) - if (iand(flag(k),self%flag0) .eq. 0) then - !if (mask(k) == 1) then - mask_dyn(k) = 0. - mask(k) = 0. - flag(k) = huge(flag(k)) - ncut = ncut + 1 - end if - end do - end if - end do -! close(58) - deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut - - ! Remove isolated samples - ncut = 0 - if (mask(1) == 1. .and. mask(2) == 0.) then - mask_dyn(1) = 0. - mask(1) = 0. - flag(1) = huge(flag(1)) - ncut = ncut + 1 + ! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if - do i = 2, ntod-1 - if (mask(i-1) == 0. .and. mask(i) == 1. .and. mask(i+1) == 0.) then - mask_dyn(i) = 0. - mask(i) = 0. - flag(i) = huge(flag(i)) - ncut = ncut + 1 - end if - end do - if (mask(ntod) == 1. .and. mask(ntod-1) == 0.) then - mask_dyn(ntod) = 0. - mask(ntod) = 0. - flag(ntod) = huge(flag(ntod)) - ncut = ncut + 1 + + if (apply_cut(7)) then + ! Remove consecutive chunks with many flagged samples + window = 2000; threshold = 0.30 + ncut = 0 + ! open(58, file='var4.dat') + do i = 1, ntod + ! write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 + j = max(i-window,1) + k = min(i+window,ntod) + if (count(flag(j:k) == huge(flag(1)))/real(k-j+1,sp) > threshold) then + do k = max(i-window,1), min(i+window,ntod) + if (iand(flag(k),self%flag0) .eq. 0) then + mask_dyn(k) = 0. + mask(k) = 0. + flag(k) = huge(flag(k)) + ncut = ncut + 1 + end if + end do + end if + end do + ! close(58) + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if -! close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut - - ! Remove consecutive chunks with many flagged samples - window = 2000; threshold = 0.30 - ncut = 0 -! open(58, file='var4.dat') - do i = 1, ntod -! write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 - j = max(i-window,1) - k = min(i+window,ntod) - if (count(flag(j:k) == huge(flag(1)))/real(k-j+1,sp) > threshold) then - do k = max(i-window,1), min(i+window,ntod) - if (iand(flag(k),self%flag0) .eq. 0) then - mask_dyn(k) = 0. - mask(k) = 0. - flag(k) = huge(flag(k)) - ncut = ncut + 1 - end if - end do - end if - end do -! close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut ! Remove glitches in the high signal-to-noise regime ! Must 1) be a masked pixel; 2) not already be flagged; 3) have a S/N > 10; 4) have a residual larger than some threshold times the expected signal @@ -3182,7 +3290,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) !!$ ncut = ncut + 1 !!$ end if !!$ end do -!!$ write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, high S/N -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntot, ncut +!!$ write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, high S/N -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut !mask_dyn(1:330000) = 0. @@ -3199,7 +3307,24 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) !!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) !!$ end do !!$ close(58) - + + ! Solar-centric mask + if (apply_cut(8)) then + ncut = 0 + if (allocated(self%mask_solar) .and. self%use_solar_point) then + do i = 1, ntod + if (iand(flag(i),self%flag0) .ne. 0) cycle + if (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut+1 + end if + end do + end if + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + end if + ! Compress and store dynamic mask allocate(bad(2,nmax)) bad = -1 @@ -3239,7 +3364,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag) if (n > 0) then allocate(self%scans(scan)%d(det)%mask_dyn(2,n)) self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(mask_dyn == 0),sp) / ntot, count(mask_dyn==0), ntot + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(iand(flag,self%flag0) .ne. 0),sp) / ntod, count(iand(flag,self%flag0) .ne. 0), ntod end if deallocate(bad, mask_dyn) @@ -3394,7 +3519,7 @@ subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) end subroutine distribute_sky_maps - subroutine get_s_static(self, band, point, s) + subroutine get_s_static(self, band, s, point_solar, point_moon, earth_elon) ! Evaluates the solar centric TOD ! ! Parameters: @@ -3406,19 +3531,40 @@ subroutine get_s_static(self, band, point, s) implicit none class(comm_tod), intent(in) :: self integer(i4b), intent(in) :: band - integer(i4b), dimension(:), intent(in) :: point real(sp), dimension(:), intent(out) :: s + integer(i4b), dimension(:), intent(in), optional :: point_solar + integer(i4b), dimension(:), intent(in), optional :: point_moon + real(sp), dimension(:), intent(in), optional :: earth_elon + + real(sp) :: elon + integer(i4b) :: i, bin - integer(i4b) :: i + ! Initialize to zero + s = 0. - if (.not. associated(self%map_solar)) then - s = 0.d0 - return + ! Solar contribution + if (present(point_solar) .and. associated(self%map_solar)) then + do i = 1, size(s) + s(i) = s(i) + self%map_solar(point_solar(i),1) + end do + end if + + ! Moon contribution + if (present(point_moon) .and. associated(self%map_moon)) then + do i = 1, size(s) + s(i) = s(i) + self%map_moon(point_moon(i),1) + end do + end if + + ! Earth contribution + if (present(earth_elon) .and. associated(self%map_earth)) then + write(*,*) 'Solar elongation correction not yet implemented' + !do i = 1, size(s) + ! elon = 0. + ! bin = 1 + ! s(i) = s(i) + self%map_earth(bin) + !end do end if - - do i = 1, size(s) - s(i) = self%map_solar(point(i),1) - end do end subroutine get_s_static diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 6288d19c4..c4b29b797 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -1711,14 +1711,15 @@ subroutine read_tod_zodi_params(cpar, model, tod) end subroutine read_tod_zodi_params - subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, pix_static, s_therm, s_scat) + subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, s_therm, s_scat, exclude_static) implicit none class(ZodiModel), intent(in) :: zodi_model class(comm_tod), intent(inout) :: tod integer(i4b), intent(in) :: det, scan real(sp), dimension(:), intent(out) :: s - integer(i4b), dimension(:,:), intent(in), optional :: pix_dynamic, pix_static + integer(i4b), dimension(:,:), intent(in), optional :: pix_dynamic real(sp), dimension(:,:), intent(out), optional :: s_therm, s_scat + character(len=*), intent(in), optional :: exclude_static integer(i4b) :: i, j, h, ntod, nhorn, ncomp, band real(sp) :: w @@ -1749,21 +1750,45 @@ subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, pix_static deallocate(s_scat_, s_therm_, s_zodi) end if - ! Add static zodi component by Healpix map lookup - if (present(pix_static) .and. associated(tod%map_solar)) then - nhorn = size(pix_static,2) - do h = 1, nhorn + ! Add solar component by Healpix map lookup + if (trim(exclude_static) /= 'solar') then + do h = 1, tod%nhorn do i = 1, ntod - j = pix_static(i,h) + j = tod%scans(scan)%d(det)%pix_sol(i,h) if (tod%map_solar(j,1) > -1.d30) then w = 1.d0; if (h > 1) w = -1.d0 - !s(i) = s(i) + w * zodi_model%amp_static(band) * zodi_model%map_static(j,1) s(i) = s(i) + w * tod%map_solar(j,1) end if end do end do end if + ! Add Moon component by Healpix map lookup + if (trim(exclude_static) /= 'moon') then + do h = 1, tod%nhorn + do i = 1, ntod + j = tod%scans(scan)%d(det)%pix_moon(i,h) + if (tod%map_moon(j,1) > -1.d30) then + w = 1.d0; if (h > 1) w = -1.d0 + s(i) = s(i) + w * tod%map_moon(j,1) + end if + end do + end do + end if + + ! Add Earth component by Healpix map lookup + if (trim(exclude_static) /= 'earth') then + do h = 1, tod%nhorn + do i = 1, ntod + j = tod%scans(scan)%d(det)%earth_elon(i,h) + if (tod%map_earth(j) > -1.d30) then + w = 1.d0; if (h > 1) w = -1.d0 + s(i) = s(i) + w * tod%map_earth(j) + end if + end do + end do + end if + end subroutine get_s_tot_zodi subroutine get_zodi_emissivity_albedo(zodi, band, emissivity, albedo) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 73c75ae9f..7e14655ce 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -736,7 +736,7 @@ subroutine downsamp_invariant_structs(cpar) else tod = data(i)%tod%scans(scan)%d(j)%tod end if - call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static, pix_static=data(i)%tod%scans(scan)%d(j)%pix_sol) + call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static) tod = tod - data(i)%tod%scans(scan)%d(j)%gain * s_static do k = 1, data(i)%tod%scans(scan)%ntod @@ -2338,10 +2338,11 @@ subroutine params_to_model(zodi, x, samp_group) end subroutine params_to_model - subroutine sample_static_zodi_map(cpar, handle) + subroutine sample_static_zodi_map(cpar, handle, map_id) implicit none type(comm_params), intent(inout) :: cpar - type(planck_rng), intent(inout) :: handle + type(planck_rng), intent(inout) :: handle + character(len=*), intent(in) :: map_id integer(i4b) :: band, i, j, k, ndet, scan, nscan, npix, nmaps, p, ierr, ntod, nhorn, npix_band, ncomp, nactive real(dp) :: res, w, vec(3), elon, amp @@ -2361,7 +2362,16 @@ subroutine sample_static_zodi_map(cpar, handle) logical(lgt), allocatable, dimension(:) :: active if (cpar%myid == 0) then - write(*,*) ' Sampling solar centric model maps' + if (trim(map_id) == 'solar') then + write(*,*) ' Sampling solar centric model maps' + else if (trim(map_id) == 'moon') then + write(*,*) ' Sampling Moon centric model maps' + else if (trim(map_id) == 'earth') then + write(*,*) ' Sampling Earth centric model maps' + else + write(*,*) ' Unknown static map type = ', trim(map_id) + stop + end if end if ncomp = zodi_model%n_comps @@ -2369,19 +2379,35 @@ subroutine sample_static_zodi_map(cpar, handle) do band = 1, numband if (trim(data(band)%tod_type) == 'none') cycle - model = cpar%ds_tod_solar_model(data(band)%tod%band) + if (trim(map_id) == 'solar') then + model = cpar%ds_tod_solar_model(data(band)%tod%band) + else if (trim(map_id) == 'moon') then + model = cpar%ds_tod_moon_model(data(band)%tod%band) + else if (trim(map_id) == 'earth') then + model = cpar%ds_tod_earth_model(data(band)%tod%band) + end if if (trim(model) == 'none') cycle if (model(1:1) == '>') then do i = 1, numband if (trim(data(i)%label) == trim(model(2:))) then - data(band)%tod%map_solar => data(i)%tod%map_solar + if (trim(map_id) == 'solar') then + data(band)%tod%map_solar => data(i)%tod%map_solar + else if (trim(map_id) == 'moon') then + data(band)%tod%map_moon => data(i)%tod%map_moon + else if (trim(map_id) == 'earth') then + data(band)%tod%map_earth => data(i)%tod%map_earth + end if exit end if end do cycle end if - - npix = 12*data(band)%info%nside**2 + + if (trim(map_id) == 'earth') then + npix = NBIN_EARTH_ELON + else + npix = 12*data(band)%info%nside**2 + end if ! Allocate temporary map structures allocate(A(0:npix-1), b(0:npix-1)) @@ -2433,8 +2459,6 @@ subroutine sample_static_zodi_map(cpar, handle) ! Get data and pointing allocate(pix(ntod, nhorn), psi(ntod, nhorn), flag(ntod), tod(ntod), mask(ntod)) - !allocate(flag(ntod), tod(ntod), mask(ntod)) - !call data(i)%tod%decompress_pointing_and_flags(scan, j, flag=flag) if (data(i)%tod%compressed_tod) then call data(i)%tod%decompress_tod(scan, j, tod) else @@ -2446,7 +2470,6 @@ subroutine sample_static_zodi_map(cpar, handle) do k = 1, data(i)%tod%scans(scan)%ntod mask(k) = procmask(pix(k, 1)) if (iand(flag(k), data(i)%tod%flag0) .ne. 0) mask(k) = 0. - !vec(:, k) = data(i)%tod%ind2vec(:, data(i)%tod%pix2ind(pix(k, 1))) end do where (mask > 0.5) mask = 1. @@ -2454,25 +2477,27 @@ subroutine sample_static_zodi_map(cpar, handle) mask = 0. end where - ! Compute non-stationary zodi TOD - call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_zodi, pix_dynamic=pix) - - !call get_zodi_emission(tod=data(i)%tod, pix=pix(:,1), scan=scan, & - ! & det=j, s_zodi_scat=s_scat, s_zodi_therm=s_therm, model=zodi_model) - !call get_s_zodi(s_therm=s_therm, s_scat=s_scat, s_zodi=s_zodi, emissivity=em, albedo=al) + ! Compute non-stationary zodi TOD; exclude current static component + call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_zodi, pix_dynamic=pix, exclude_static=map_id) ! Add residual to mapmaking equation in solar centric coordinates w = 1.d0/data(i)%tod%scans(scan)%d(j)%N_psd%sigma0**2 amp = 1.d0 !zodi_model%amp_static(i) do k = 1, ntod if (mask(k) == 0) cycle - p = data(i)%tod%scans(scan)%d(j)%pix_sol(k,1) - - call pix2vec_ring(data(i)%tod%nside, p, vec) - elon = acos(min(max(vec(1),-1.d0),1.d0)) * 180.d0/pi + if (trim(map_id) == 'solar') then + p = data(i)%tod%scans(scan)%d(j)%pix_sol(k,1) + else if (trim(map_id) == 'moon') then + p = data(i)%tod%scans(scan)%d(j)%pix_moon(k,1) + else if (trim(map_id) == 'earth') then + p = data(i)%tod%scans(scan)%d(j)%earth_elon(k,1) + end if + + !call pix2vec_ring(data(i)%tod%nside, p, vec) + !elon = acos(min(max(vec(1),-1.d0),1.d0)) * 180.d0/pi s_sky(k) = map_sky(1, data(i)%tod%pix2ind(pix(k, 1)), j, 1) ! zodi is only temperature (for now) - res = tod(k) - (s_zodi(k)+s_sky(k)) + res = tod(k) / data(i)%tod%scans(scan)%d(j)%gain - (s_zodi(k)+s_sky(k)) A(p) = A(p) + w * amp * amp b(p) = b(p) + w * amp * res end do @@ -2488,20 +2513,37 @@ subroutine sample_static_zodi_map(cpar, handle) call mpi_allreduce(MPI_IN_PLACE, b, size(b), MPI_DOUBLE_PRECISION, MPI_SUM, cpar%comm_chain, ierr) ! Solve for best-fit map - if (.not. associated(data(band)%tod%map_solar)) then - allocate(data(band)%tod%map_solar(0:12*data(band)%info%nside**2-1,1)) + if (trim(map_id) == 'solar' .and. .not. associated(data(band)%tod%map_solar)) allocate(data(band)%tod%map_solar(0:12*data(band)%info%nside**2-1,1)) + if (trim(map_id) == 'moon' .and. .not. associated(data(band)%tod%map_moon)) allocate(data(band)%tod%map_moon(0:12*data(band)%info%nside**2-1,1)) + if (trim(map_id) == 'earth' .and. .not. associated(data(band)%tod%map_earth)) allocate(data(band)%tod%map_earth(NBIN_EARTH_ELON)) + + if (trim(map_id) == 'solar') then + where (A > 0.d0) + data(band)%tod%map_solar(:,1) = b/A + elsewhere + data(band)%tod%map_solar(:,1) = -1.6375d30 + end where + end if + + if (trim(map_id) == 'moon') then + where (A > 0.d0) + data(band)%tod%map_moon(:,1) = b/A + elsewhere + data(band)%tod%map_moon(:,1) = -1.6375d30 + end where end if - where (A > 0.d0) - !zodi_model%map_static(:,1) = b/A - data(band)%tod%map_solar(:,1) = b/A - elsewhere - !zodi_model%map_static(:,1) = -1.6375d30 - data(band)%tod%map_solar(:,1) = -1.6375d30 - end where - - if (cpar%myid_chain == 0) then - call write_map2('static_'//trim(data(band)%label)//'.fits', real(data(band)%tod%map_solar,dp)) + + if (trim(map_id) == 'earth') then + where (A > 0.d0) + data(band)%tod%map_earth = b/A + elsewhere + data(band)%tod%map_earth = -1.6375d30 + end where end if + +!!$ if (cpar%myid_chain == 0) then +!!$ call write_map2('static_'//trim(data(band)%label)//'.fits', real(data(band)%tod%map_solar,dp)) +!!$ end if ! Clean up deallocate(A, b, active) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 00ec09ad5..049dc27d8 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -381,11 +381,10 @@ program commander end do end select - ! Sample stationary zodi components with 2D model - if (.false.) then - call sample_static_zodi_map(cpar, handle) - end if - !call sample_static_zodi_amps(cpar, handle) + ! Sample stationary components + if (cpar%sample_solar_maps) call sample_static_zodi_map(cpar, handle, 'solar') + if (cpar%sample_moon_maps) call sample_static_zodi_map(cpar, handle, 'moon') + if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') !!$ if (mod(iter-2,10) == 0) then !!$ call zodi_model%params_to_model([& From 52cd3fbf6a0b348f62fc7ccb21ef1264aa2cef6b Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 24 Feb 2025 20:43:33 +0100 Subject: [PATCH 116/171] merge --- commander3/config/config.ita_internal | 4 +- commander3/src/comm_param_mod.f90 | 12 +- commander3/src/comm_tod_mod.f90 | 151 ++++++++------------------ commander3/src/comm_zodi_mod.f90 | 2 +- 4 files changed, 56 insertions(+), 113 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index 0a76cd9d7..eb9ef14dd 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -49,10 +49,10 @@ export MPCC := mpiicc # =========== Compiler Optimizations ============= #main -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. +export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index efbf94365..1dfac0139 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -183,8 +183,10 @@ module comm_param_mod character(len=2048), allocatable, dimension(:) :: ds_tod_solar_model character(len=2048), allocatable, dimension(:) :: ds_tod_solar_init character(len=2048), allocatable, dimension(:) :: ds_tod_moon_model + character(len=2048), allocatable, dimension(:) :: ds_tod_moon_mask character(len=2048), allocatable, dimension(:) :: ds_tod_moon_init character(len=2048), allocatable, dimension(:) :: ds_tod_earth_model + character(len=2048), allocatable, dimension(:) :: ds_tod_earth_mask character(len=2048), allocatable, dimension(:) :: ds_tod_earth_init ! Component parameters @@ -615,8 +617,8 @@ subroutine read_data_params_hash(htbl, cpar) allocate(cpar%ds_tod_instfile(n), cpar%ds_tod_dets(n), cpar%ds_tod_scanrange(n,2)) allocate(cpar%ds_tod_tot_numscan(n), cpar%ds_tod_flag(n), cpar%ds_tod_abscal(n), cpar%ds_tod_halfring(n), cpar%ds_tod_subtract_zodi(n), cpar%ds_tod_freq(n)) allocate(cpar%ds_tod_solar_model(n), cpar%ds_tod_solar_mask(n), cpar%ds_tod_solar_init(n)) - allocate(cpar%ds_tod_moon_model(n), cpar%ds_tod_moon_init(n)) - allocate(cpar%ds_tod_earth_model(n), cpar%ds_tod_earth_init(n)) + allocate(cpar%ds_tod_moon_model(n), cpar%ds_tod_moon_mask(n), cpar%ds_tod_moon_init(n)) + allocate(cpar%ds_tod_earth_model(n), cpar%ds_tod_earth_mask(n), cpar%ds_tod_earth_init(n)) cpar%ds_nside = 0 ! Zodi mod currently uses cpar nsides to cache some stuff. Setting to 0 to filter unique nsides do i = 1, n @@ -696,10 +698,14 @@ subroutine read_data_params_hash(htbl, cpar) & par_string=cpar%ds_tod_solar_init(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_MOON_CENTRIC_MODEL'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_moon_model(i)) + call get_parameter_hashtable(htbl, 'BAND_TOD_MOON_CENTRIC_MASK'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_moon_mask(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_MOON_CENTRIC_INITMAP'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_moon_init(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_EARTH_CENTRIC_MODEL'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_earth_model(i)) + call get_parameter_hashtable(htbl, 'BAND_TOD_EARTH_CENTRIC_MASK'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_earth_mask(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_EARTH_CENTRIC_INITMAP'//itext, len_itext=len_itext, & & par_string=cpar%ds_tod_earth_init(i), path=.true.) call get_parameter_hashtable(htbl, 'BAND_TOD_FILELIST'//itext, len_itext=len_itext, & @@ -3548,7 +3554,9 @@ subroutine validate_params(cpar) call validate_file(trim(cpar%ds_tod_solar_mask(i)), 'BAND_TOD_SOLAR_CENTRIC_MASK'//itext) ! Solar centric/sidelobe mask call validate_file(trim(cpar%ds_tod_solar_init(i)), 'BAND_TOD_SOLAR_CENTRIC_INITMAP'//itext) ! Initial solar centric map call validate_file(trim(cpar%ds_tod_moon_init(i)), 'BAND_TOD_MOON_CENTRIC_INITMAP'//itext) ! Initial moon centric map + call validate_file(trim(cpar%ds_tod_moon_mask(i)), 'BAND_TOD_SOLAR_CENTRIC_MASK'//itext) ! Solar centric/sidelobe mask call validate_file(trim(cpar%ds_tod_earth_init(i)), 'BAND_TOD_EARTH_CENTRIC_INITMAP'//itext) ! Initial Earth centric map + call validate_file(trim(cpar%ds_tod_earth_mask(i)), 'BAND_TOD_SOLAR_CENTRIC_MASK'//itext) ! Solar centric/sidelobe mask call validate_file(trim(cpar%ds_tod_filelist(i)), 'BAND_TOD_FILELIST'//itext) ! Filelist if (trim(cpar%ds_tod_jumplist(i)) /= 'none') then call validate_file(trim(cpar%ds_tod_jumplist(i)), 'BAND_TOD_JUMPLIST'//itext) ! Jumplist diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index aa55f9307..33288886c 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -195,6 +195,8 @@ module comm_tod_mod class(comm_map), pointer :: procmask_zodi => null() ! Mask for sampling zodi !class(comm_map), pointer :: mask_solar => null() ! Solar centric/sidelobe mask real(dp), allocatable, dimension(:,:) :: mask_solar ! Solar centric/sidelobe mask + real(dp), allocatable, dimension(:,:) :: mask_moon ! Moon centric/sidelobe mask + real(dp), allocatable, dimension(:) :: mask_earth ! Earth centric/sidelobe mask; elongation only logical(lgt) :: map_solar_allocated logical(lgt) :: map_moon_allocated logical(lgt) :: map_earth_allocated @@ -353,6 +355,7 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) character(len=128), intent(in) :: tod_type integer(i4b) :: i, ndelta, ierr, unit + real(sp) :: elon character(len=512) :: datadir, solar_init self%id = id @@ -458,10 +461,21 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%procmask_zodi => comm_map(self%info, self%procmaskfzodi) end if if (trim(cpar%ds_tod_solar_mask(id_abs)) /= 'none') then - !self%mask_solar => comm_map(self%info, cpar%ds_tod_solar_mask(id_abs)) allocate(self%mask_solar(0:12*self%nside_param**2-1,1)) call read_map(cpar%ds_tod_solar_mask(id_abs), self%mask_solar) end if + if (trim(cpar%ds_tod_moon_mask(id_abs)) /= 'none') then + allocate(self%mask_moon(0:12*self%nside_param**2-1,1)) + call read_map(cpar%ds_tod_moon_mask(id_abs), self%mask_moon) + end if + if (trim(cpar%ds_tod_earth_mask(id_abs)) /= 'none') then + allocate(self%mask_earth(NBIN_EARTH_ELON)) + open(58,file=trim(cpar%ds_tod_earth_mask(id_abs))) + do i = 1, NBIN_EARTH_ELON + read(58,*) elon, self%mask_earth(i) + end do + close(58) + end if do i = 0, self%info%np-1 if (any(self%procmask%map(i,:) < 0.5d0)) then @@ -570,6 +584,8 @@ subroutine precompute_lookups(self) else do j = 1, self%ndet if (self%use_solar_point) allocate(self%scans(i)%d(j)%pix_sol(self%scans(i)%ntod,self%nhorn)) + if (self%use_moon_point) allocate(self%scans(i)%d(j)%pix_moon(self%scans(i)%ntod,self%nhorn)) + if (self%use_earth_elon) allocate(self%scans(i)%d(j)%earth_elon(self%scans(i)%ntod,self%nhorn)) do l = 1, self%nhorn call huffman_decode(self%scans(i)%hkey, self%scans(i)%d(j)%pix(l)%p, pix) self%pix2ind(pix(1)) = -1 @@ -590,7 +606,7 @@ subroutine precompute_lookups(self) end do end do end if - deallocate(pix) + deallocate(pix,psi) end do self%nobs = count(self%pix2ind == -1) allocate(self%ind2pix(self%nobs)) @@ -3041,7 +3057,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only integer(i4b), dimension(:), intent(inout) :: flag logical(lgt), intent(in) :: only_solar_mask - integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut + integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut, b_elon real(dp) :: rms0 real(sp) :: var0, threshold, gain logical(lgt), dimension(8) :: apply_cut @@ -3322,6 +3338,30 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end if end do end if + if (allocated(self%mask_moon) .and. self%use_moon_point) then + do i = 1, ntod + if (iand(flag(i),self%flag0) .ne. 0) cycle + if (self%mask_moon(self%scans(scan)%d(det)%pix_moon(i,1),1) < 0.5) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut+1 + end if + end do + end if + if (allocated(self%mask_earth) .and. self%use_earth_elon) then + do i = 1, ntod + if (iand(flag(i),self%flag0) .ne. 0) cycle + b_elon = max(min(int(self%scans(scan)%d(det)%earth_elon(i,1)/(pi/NBIN_EARTH_ELON)),NBIN_EARTH_ELON),1) + if (self%mask_earth(b_elon) < 0.5) then + mask_dyn(i) = 0. + mask(i) = 0. + flag(i) = huge(flag(i)) + ncut = ncut+1 + end if + end do + end if + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3370,111 +3410,6 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only deallocate(bad, mask_dyn) end subroutine create_dynamic_mask - subroutine create_dynamic_mask2(self, scan, det, res, rms_range, mask) - implicit none - class(comm_tod), intent(inout) :: self - integer(i4b), intent(in) :: scan, det - real(sp), dimension(:), intent(in) :: res - real(sp), dimension(2), intent(in) :: rms_range - real(sp), dimension(:), intent(inout) :: mask - - logical(lgt) :: cut - integer(i4b) :: i, j, k, n, ntod, nmax - real(dp) :: box_width, rms, vec(3), elon - integer(i4b), allocatable, dimension(:,:) :: bad, buffer - !real(dp), allocatable, dimension(:,:) :: mask_solar - - ntod = size(res) - nmax = 1000 - - ! Compute rms - rms = 0.d0 - n = 0 - do i = 1, ntod - if (mask(i) /= 1.) cycle - rms = rms + res(i)**2 - n = n + 1 - end do - rms = sqrt(rms/(n-1)) - -! write(*,*) 'a' - ! Get full-sky mask -! if (associated(self%mask_solar)) then -! allocate(mask_solar(0:12*self%nside**2-1,1)) -! call self%mask_solar%bcast_fullsky_map(mask_solar) -! end if - - -! write(*,*) 'b' - ! Look for strong outliers and masked samples, save bad ranges - allocate(bad(2,nmax)) - bad = -1 - n = 0 - do i = 1, ntod - - ! Apply RMS selection criterium - if (mask(i) == 1) then - cut = res(i) < rms_range(1)*rms .or. res(i) > rms_range(2)*rms - else - cut = .false. - end if - - ! Apply solar mask selection criterium -! call pix2vec_ring(self%nside, self%scans(scan)%d(det)%pix_sol(i,1), vec) -! elon = acos(min(max(vec(1),-1.d0),1.d0)) * 180.d0/pi ! The Sun is at (1,0,0) - ! cut = cut .or. elon < self%sol_elong_range(1) .or. elon > self%sol_elong_range(2) - if (allocated(self%mask_solar) .and. self%use_solar_point) then - cut = cut .or. (self%mask_solar(self%scans(scan)%d(det)%pix_sol(i,1),1) < 0.5) - end if - - if (cut) then - ! Start new range if not already active - if (bad(1,n+1) == -1) bad(1,n+1) = i - mask(i) = 0. - else - ! Close active range - if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then - bad(2,n+1) = i-1 - n = n+1 - end if - end if - - ! Increase array size if needed - if (n == nmax) then - nmax = 2*nmax - allocate(buffer(2,nmax)) - buffer = -1 - buffer(:,1:nmax/2) = bad - deallocate(bad) - allocate(bad(2,nmax)) - bad = buffer - deallocate(buffer) - end if - end do - - ! Close open range if needed at the end - if (bad(1,n+1) /= -1 .and. bad(2,n+1) == -1) then - bad(2,n+1) = ntod - n = n+1 - end if - - ! Store final array - if (n > 0) then - allocate(self%scans(scan)%d(det)%mask_dyn(2,n)) - self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) -!!$ do i = 1, n -!!$ write(*,*) i, bad(:,i) -!!$ end do - !write(*,fmt='(a,i6,a,i6,i4)') ' Removing ', n, ' ranges in dynamic mask for scan, det', self%scanid(scan), det - end if - - -! write(*,*) 'c' - deallocate(bad) -! if (allocated(mask_solar)) deallocate(mask_solar) - end subroutine - - subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) implicit none class(comm_tod), intent(in) :: tod diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index c4b29b797..ea23551a9 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -1780,7 +1780,7 @@ subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, s_therm, s if (trim(exclude_static) /= 'earth') then do h = 1, tod%nhorn do i = 1, ntod - j = tod%scans(scan)%d(det)%earth_elon(i,h) + j = max(min(int(tod%scans(scan)%d(det)%earth_elon(i,h)/(pi/NBIN_EARTH_ELON)),NBIN_EARTH_ELON),1) if (tod%map_earth(j) > -1.d30) then w = 1.d0; if (h > 1) w = -1.d0 s(i) = s(i) + w * tod%map_earth(j) From 838317ae92d1428bd9036200950890af84914c4d Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 25 Feb 2025 14:38:22 +0100 Subject: [PATCH 117/171] Added missing parameters to continuous integration --- commander3/parameter_files/param_continuous_integration.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commander3/parameter_files/param_continuous_integration.txt b/commander3/parameter_files/param_continuous_integration.txt index c1dcef0bd..de6724285 100644 --- a/commander3/parameter_files/param_continuous_integration.txt +++ b/commander3/parameter_files/param_continuous_integration.txt @@ -28,6 +28,11 @@ ENABLE_TOD_ANALYSIS = .true. TOD_INCLUDE_ZODI = .true. SAMPLE_ZODI = .false. +SAMPLE_SOLAR_MAPS = .true. +SAMPLE_MOON_MAPS = .true. +SAMPLE_EARTH_MAPS = .true. # Only as a function of elongation + + ############################################################## # Output options # ############################################################## From b77bc9370251bfadef347bc608eaf662b777a4d5 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 26 Feb 2025 17:01:41 +0100 Subject: [PATCH 118/171] merge --- commander3/config/config.ita_internal | 19 +++++++------------ commander3/src/comm_tod_hfi_mod.f90 | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index afa6a5b17..0a76cd9d7 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -38,10 +38,10 @@ export F90 := ifort # MPI Fortran 90 compiler. Default is "mpif90". -export MPF90 := mpiifort +export MPF90 := mpiifort #-fc=ifx # MPI Fortran 77 compiler. Default is "mpif77". -export MPF77 := mpiifort +export MPF77 := mpiifort #-fc=ifx # MPI C++ compiler. Default is "mpicxx". export MPCC := mpiicc @@ -49,15 +49,10 @@ export MPCC := mpiicc # =========== Compiler Optimizations ============= #main -# -#export F90FLAGS := -fpe0 -march=native -g -O2 -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -xHost -#export F90FLAGS := -g -O2 -traceback -#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -prof-gen=srcpos -prof-dir=/mn/stornext/u3/hke/xsan/commander3/BP9/prof -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -parallel -diag-disable=10448 +export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -# -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 +#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv @@ -71,7 +66,7 @@ export FFLAGS := -O2 export CFLAGS := -O3 # Extra flags used for linking -export LDFLAGS := -qopt-matmul -lm -qopenmp -cxxlib -parallel -qmkl #-prof-file prof.dat -prof-dir . -profile-functions -profile-loops=all +export LDFLAGS := -qopt-matmul -lm -qopenmp -cxxlib -qmkl -diag-disable=10448 #-prof-file prof.dat -prof-dir . -profile-functions -profile-loops=all # ============== Language Mixing ================= @@ -131,6 +126,6 @@ export HDF_LINK_CPP := -L$(LOCAL)/lib -lhdf5_cpp -lhdf5 export HDF_INCLUDE := -I$(LOCAL)/include/shared # =============== CAMB ============================ -export CAMB_LINK := -L$(LOCAL)/local/lib #-lcamb -export CAMB_INCLUDE := -I$(LOCAL)/mod +#export CAMB_LINK := -L$(LOCAL)/local/lib #-lcamb +#export CAMB_INCLUDE := -I$(LOCAL)/mod diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 52c6e0498..88e554347 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -332,7 +332,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Sample gain components in separate TOD loops; marginal with respect to n_corr call sample_calibration(self, 'abscal', handle, map_sky, procmask2, procmask2) !call sample_calibration(self, 'relcal', handle, map_sky, procmask, procmask2) - !call sample_calibration(self, 'deltaG', handle, map_sky, procmask, procmask2) + !call sample_calibration(self, 'deltaG', handle, map_sky, procmask2, procmask2) ! Prepare intermediate data structures call binmap%init(self, .true., sample_rel_bandpass) @@ -425,7 +425,12 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Compute calibrated TOD for mapmaking allocate(d_calib(self%output_n_maps,sd%ntod, sd%ndet)) call compute_calibrated_data(self, i, sd, d_calib) - + +!!$ open(58,file='res.dat') +!!$ do j = 1, sd%ntod +!!$ write(58,*) j, sd%tod(j,1), d_calib(2,j,1) +!!$ end do +!!$ close(58) ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) @@ -683,6 +688,12 @@ subroutine demodulate_tod(self, tod, scan) real(sp) :: sgn logical :: exists +!!$ open(58,file='tod_adc.dat') +!!$ do j = 1, self%ntod +!!$ write(58,*) j, self%tod(j,1) +!!$ end do +!!$ close(58) + do i = 1, tod%ndet if (.not. tod%scans(scan)%d(i)%accept) cycle sgn = tod%mod_phase(i,scan) From 09e7e6e0d68091f9bbe4e9ba1251aae3f62f9d31 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 26 Feb 2025 17:05:20 +0100 Subject: [PATCH 119/171] merge --- commander3/config/config.ita_internal | 8 -------- 1 file changed, 8 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index ce2447adc..0a76cd9d7 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -52,16 +52,8 @@ export MPCC := mpiicc export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -<<<<<<< HEAD #export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. -||||||| 4c9aa3de -# -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 - -======= -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. ->>>>>>> 056b0f5516ff48f812ec57283bbe0a3ba604dc27 #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv #export F90FLAGS := -check bounds -CB -check format -check pointers -check uninit -check output_conversion -assume byterecl -traceback -heap-arrays 16384 -fpe0 -O0 -g -traceback -assume byterecl -heap-arrays 16384 -qopenmp From e7c10ae5e311e65a31b37427936706cdb2668c27 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 27 Feb 2025 09:43:00 +0100 Subject: [PATCH 120/171] Added missing parameters --- .../parameter_files/param_continuous_integration.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/commander3/parameter_files/param_continuous_integration.txt b/commander3/parameter_files/param_continuous_integration.txt index de6724285..89d3e1c96 100644 --- a/commander3/parameter_files/param_continuous_integration.txt +++ b/commander3/parameter_files/param_continuous_integration.txt @@ -514,9 +514,15 @@ BAND_NOISEFILE&&& = DIRBE_10a_SIGMA_512_prod_v1.fits BAND_TOD_FILELIST&&& = filelist_DIRBE_10_nside512_V21.txt BAND_SAMP_GAIN&&& = .false. BAND_TOD_TYPE&&& = DIRBE -BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none -BAND_TOD_SOLAR_CENTRIC_MASK&&& = none -BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none #BAND_TOD_START_SCANID&&& = 8 31 #BAND_TOD_END_SCANID&&& = 285 BAND_TOD_START_SCANID&&& = 1 From 1f4accd2f530e256ee73939a715d8a8ba71303d4 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 27 Feb 2025 12:28:09 +0100 Subject: [PATCH 121/171] merge --- commander3/config/config.ita_internal | 4 +-- .../parameter_files/defaults/HFI_tod.defaults | 4 +++ .../defaults/bands/HFI/HFI_545_TOD.defaults | 15 +++++++++-- commander3/src/comm_bp_mod.f90 | 2 -- commander3/src/comm_data_mod.f90 | 7 +++--- commander3/src/comm_tod_hfi_mod.f90 | 25 ++++++++++++------- 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index 0a76cd9d7..eb9ef14dd 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -49,10 +49,10 @@ export MPCC := mpiicc # =========== Compiler Optimizations ============= #main -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. +export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/parameter_files/defaults/HFI_tod.defaults b/commander3/parameter_files/defaults/HFI_tod.defaults index 35a8ed57c..4f3bb065d 100644 --- a/commander3/parameter_files/defaults/HFI_tod.defaults +++ b/commander3/parameter_files/defaults/HFI_tod.defaults @@ -9,6 +9,10 @@ SAMPLE_SIGNAL_AMPLITUDES = .true. SAMPLE_SPECTRAL_INDICES = .true. SAMPLE_POWSPEC = .false. +SAMPLE_SOLAR_MAPS = .false. +SAMPLE_MOON_MAPS = .false +SAMPLE_EARTH_MAPS = .false. # Only as a function of elongation + ENABLE_TOD_ANALYSIS = .true. TOD_OUTPUT_4D_MAP_EVERY_NTH_ITER = -1 TOD_OUTPUT_AUXILIARY_MAPS_EVERY_NTH_ITER = 10 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index a4e5c647a..b6203994d 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -1,6 +1,7 @@ #HFI 545 GHz TOD default parameters -BAND_LABEL&&& = 545 +BAND_LABEL&&& = 545-1 +BAND_INSTRUMENT_LABEL&&& = 545-1 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .false. BAND_NSIDE&&& = 2048 @@ -42,10 +43,20 @@ BAND_TOD_END_SCANID&&& = 18300 #53724 BAND_TOD_TOT_NUMSCAN&&& = 18338 #53724 BAND_TOD_FLAG&&& = 0 BAND_TOD_ABSCAL_COMP&&& = full -BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 +BAND_TOD_DETECTOR_LIST&&& = 545-1 ,545-2,545-4 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_INIT_FROM_HDF&&& = default +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + #TODO: make these paths into real defaults in the Oslo legacy archive BAND_MAPFILE&&& = npipe6v20_545_map_K.fits BAND_NOISEFILE&&& = npipe6v20_545_wcov.fits diff --git a/commander3/src/comm_bp_mod.f90 b/commander3/src/comm_bp_mod.f90 index d214c8bed..6aa40285f 100644 --- a/commander3/src/comm_bp_mod.f90 +++ b/commander3/src/comm_bp_mod.f90 @@ -180,8 +180,6 @@ function constructor_bp(cpar, id, id_abs, detlabel, subdets) result(c) end do c%tau0 = c%tau0 / ndet else - print *, "got to nonzero threshold, aborting" - stop call read_bandpass_nonzero_threshold(cpar%ds_bpfile(id_abs), dets, ndet, & & c%threshold, & & c%n, c%nu0, c%tau0) diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 94292ac15..b013249a2 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -280,15 +280,14 @@ subroutine initialize_data_mod(cpar, handle) data(n)%pol_only = data(n)%N%pol_only call update_status(status, "data_N") - ! Initialize bandpass structures; 0 is full freq, j is detector + ! Initialize bandpass structures; 0 is full freq, j is detector allocate(data(n)%bp(0:data(n)%ndet)) - do j = 1, data(n)%ndet if (j==1) then - data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=trim(data(n)%tod%label(j))) + data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=trim(data(n)%tod%label(j))) else ! Check if bandpass already exists in detector list - call read_bandpass(trim(cpar%datadir) // '/' // cpar%ds_bpfile(i), & + call read_bandpass(trim(cpar%datadir) // '/' // trim(adjustl(cpar%ds_bpfile(i))), & & trim(data(n)%tod%label(j)), & & data(n)%bp(1)%p%threshold, & & n_dummy, & diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index 8a3021b16..ac685fe70 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -86,7 +86,7 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) character(len=128), intent(in) :: tod_type class(comm_HFI_tod), pointer :: c - integer(i4b) :: i, j, nside_beam, lmax_beam, nmaps_beam, ierr + integer(i4b) :: i, j, k, nside_beam, lmax_beam, nmaps_beam, ierr logical(lgt) :: pol_beam ! Allocate object @@ -98,11 +98,14 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%noise_psd_model = 'oof' allocate(c%xi_n_P_uni(c%n_xi,2)) allocate(c%xi_n_P_rms(c%n_xi)) - + allocate(c%xi_n_nu_fit(c%n_xi,2)) + ! just so that it actually runs c%xi_n_P_uni(2,:) = [0.010d0, 0.45d0] ! fknee c%xi_n_P_uni(3,:) = [-2.5d0, -0.4d0] ! alpha - !c%xi_n_nu_fit = [0.d0, 1.225d0] ! I took it from freq=30 for LFI, so not true + do k = 1, c%n_xi + c%xi_n_nu_fit(k,:) = [0.d0, 3*1.225d0] ! Placeholder + end do c%xi_n_P_rms = [-1.d0, 0.1d0, 0.2d0] ! [sigma0, fknee, alpha]; sigma0 is not used @@ -114,7 +117,7 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Initialize instrument-specific parameters c%samprate_lowres = 1.d0 ! Lowres samprate in Hz c%nhorn = 1 - c%compressed_tod = .true. + c%compressed_tod = .false. c%correct_sl = .false. c%correct_orb = .true. c%orb_4pi_beam = .false. @@ -149,7 +152,8 @@ function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) !allocate(c%slconv(c%ndet), c%orb_dp) allocate(c%orb_dp) - c%orb_dp => comm_orbdipole(c%mbeam) + !c%orb_dp => comm_orbdipole(c%mbeam) ! HKE: Removed mbeam for now due to crash; should be fixed + c%orb_dp => comm_orbdipole(comm=c%comm) ! Initialize all baseline corrections to zero do i = 1, c%nscan @@ -217,7 +221,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps - logical(lgt) :: select_data, sample_abs_bandpass, sample_rel_bandpass, output_scanlist + logical(lgt) :: select_data, sample_gain, sample_abs_bandpass, sample_rel_bandpass, output_scanlist type(comm_binmap) :: binmap type(comm_scandata) :: sd character(len=4) :: ctext, myid_text @@ -236,6 +240,7 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m ! Toggle optional operations sample_rel_bandpass = size(delta,3) > 1 ! Sample relative bandpasses if more than one proposal sky sample_abs_bandpass = .false. ! don't sample absolute bandpasses + sample_gain = .false. ! Don't sample gains until other effects are under better control select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration @@ -321,9 +326,11 @@ subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, delta, m end do ! Sample gain components in separate TOD loops; marginal with respect to n_corr - call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask2, procmask2) - !call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) - !call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) + if (sample_gain) then + call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask2, procmask2) + !call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) + !call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) + end if ! Prepare intermediate data structures From 985c5595f736aa944c3a18802443560f71e11d3d Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 27 Feb 2025 15:03:17 +0100 Subject: [PATCH 122/171] Added debug statements; need proper flags before continuing --- .../defaults/bands/HFI/HFI_545-1_TOD.defaults | 76 +++++++++++++++++++ commander3/src/comm_tod_driver_mod.f90 | 7 ++ commander3/src/comm_tod_hfi_smod.f90 | 23 ++++-- 3 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults new file mode 100644 index 000000000..765c28b93 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults @@ -0,0 +1,76 @@ +#HFI 545 GHz TOD default parameters +BAND_LABEL&&& = 545-1 +BAND_INSTRUMENT_LABEL&&& = 545-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 4000 +BAND_UNIT&&& = K_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 1 +BAND_MASKFILE&&& = fullsky +BAND_MASKFILE_CALIB&&& = mask_common_dx12_n2048_TQU.fits fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v19_545GHzx545GHz.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 545 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0.1 +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_LEVEL&&& = L1 + +BAND_TOD_TYPE&&& = HFI +BAND_TOD_BP_INIT_PROP&&& = none +BAND_TOD_HALFRING&&& = 0 +BAND_TOD_START_SCANID&&& = 700 # 3 +BAND_TOD_END_SCANID&&& = 18300 #53724 +BAND_TOD_TOT_NUMSCAN&&& = 18338 #53724 +BAND_TOD_FLAG&&& = 0 +BAND_TOD_ABSCAL_COMP&&& = full +BAND_TOD_DETECTOR_LIST&&& = 545-1 +BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. +BAND_TOD_INIT_FROM_HDF&&& = default +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +#TODO: make these paths into real defaults in the Oslo legacy archive +BAND_MAPFILE&&& = npipe6v20_545_map_K.fits +BAND_NOISEFILE&&& = npipe6v20_545_wcov.fits +BAND_REG_NOISEFILE&&& = npipe6v20_545_wcov.fits +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_545_wcov.fits +BAND_NOISE_RMS&&&_SMOOTH02 = npipe6v20_545_wcov.fits +BAND_NOISE_RMS&&&_SMOOTH03 = npipe6v20_545_wcov.fits +BAND_BANDPASSFILE&&& = HFI_instrument_v2.h5 + +BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits +BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_545-1_n2048_mask.fits +N_GIBBS_PER_TOD&&& = 1 +BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 +BAND_TOD_FILELIST&&& = filelist_545_Artem_full_pointing_DPC.txt #filelist_545_Artem_full.txt + diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 786502e57..704b6ac7d 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -167,6 +167,13 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, & sd%psi(:,j,:), sd%flag(:,j)) end do +!!$ open(58,file='decomp.dat', recl=1024) +!!$ do j = 1, sd%ntod +!!$ write(58,*) j, sd%pix(j,1,1), sd%flag(j,1) +!!$ end do +!!$ close(58) + + if(darkdata_) then do j=1, tod%ndark call tod%decompress_dark_data(scan, j, sd%dark(:,j)) diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index 702b68c87..a39b9db55 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -90,7 +90,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Initialize instrument-specific parameters c%samprate_lowres = 1.d0 ! Lowres samprate in Hz c%nhorn = 1 - c%compressed_tod = .false. + c%compressed_tod = .true. c%correct_sl = .false. if(c%freq(1:3) == '545' .or. c%freq(1:3) == '857') then !currently no sidelobe models c%correct_sl = .false. @@ -117,7 +117,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Read the actual TOD call c%read_tod(c%label) - + ! Initialize bandpass mean and proposal matrix !call c%initialize_bp_covar(trim(cpar%datadir)//'/'//cpar%ds_tod_bp_init(id_abs)) @@ -224,7 +224,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call int2string(iter, ctext) call update_status(status, "tod_start"//ctext) - + ! Toggle optional operations sample_rel_bandpass = size(delta,3) > 1 ! Sample relative bandpasses if more than one proposal sky sample_abs_bandpass = .false. ! don't sample absolute bandpasses @@ -298,6 +298,12 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (.not. any(self%scans(i)%d%accept)) cycle call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, skip_nonlin=.true., darkdata=.true.) +!!$ open(58,file='res.dat', recl=1024) +!!$ do j = 1, sd%ntod +!!$ write(58,*) j, sd%tod(j,1), sd%pix(j,1,1), sd%flag(j,1) +!!$ end do +!!$ close(58) + ! Subtract A/B detector crosstalk ! Not implemented yet @@ -327,6 +333,9 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call sd%dealloc end do +!!$ call mpi_finalize(ierr) +!!$ stop + ! Fit global timestream contaminants ! Subtract cosmic ray contribution @@ -397,7 +406,6 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Sample correlated noise !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) - sd%n_corr = 0.d0 ! Compute noise spectrum parameters @@ -420,10 +428,9 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d d_calib = 0.d0 call compute_calibrated_data(self, i, sd, d_calib) - -!!$ open(58,file='res.dat') +!!$ open(58,file='res.dat', recl=1024) !!$ do j = 1, sd%ntod -!!$ write(58,*) j, sd%tod(j,1), d_calib(2,j,1) +!!$ write(58,*) j, sd%tod(j,1), d_calib(2,j,1), sd%pix(j,1,1), sd%flag(j,1) !!$ end do !!$ close(58) @@ -627,7 +634,7 @@ module subroutine set_modulation_phase(self, tod, scan) end do if (n == 0) then - write(*,*) "Scan disabled in set_modulation_phase" + write(*,*) "Scan disabled in set_modulation_phase; no samples crossing the galactic plane (should not happen)" tod%scans(scan)%d(i)%accept = .false. else mu = mu/n From 7f9eb5bd331a7ba43d75ab87841d34dc3cbb85cb Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 27 Feb 2025 17:18:36 +0100 Subject: [PATCH 123/171] Moved scandata to comm_tod_mod; activated non-linear corrections for HFI --- commander3/src/comm_tod_dirbe_mod.f90 | 8 ++-- commander3/src/comm_tod_driver_mod.f90 | 51 ++-------------------- commander3/src/comm_tod_hfi_smod.f90 | 16 +++---- commander3/src/comm_tod_lb_mod.f90 | 8 ++-- commander3/src/comm_tod_lfi_smod.f90 | 13 +++--- commander3/src/comm_tod_mod.f90 | 57 ++++++++++++++++++++++++- commander3/src/comm_tod_pixhist_mod.f90 | 4 +- commander3/src/comm_tod_spider_smod.f90 | 10 ++--- commander3/src/comm_tod_wmap_mod.f90 | 10 ++--- 9 files changed, 94 insertions(+), 83 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 880d2d34f..49118de50 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -386,7 +386,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, ! Skip scan if no accepted data if (.not. any(self%scans(i)%d%accept)) cycle call wall_time(t1) - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) ! Create dynamic mask if (self%first_call) then @@ -395,9 +395,9 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & & [-5.,5.], sd%mask(:,j), sd%flag(:,j), only_solar_mask) end do - call sd%dealloc + call dealloc_scan_data(sd) if (.not. any(self%scans(i)%d%accept)) cycle - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) end if ! Sample correlated noise @@ -476,7 +476,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) deallocate(d_calib) end do diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 704b6ac7d..d0b25c625 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -27,51 +27,8 @@ module comm_tod_driver_mod contains procedure init_singlehorn => init_det_data_singlehorn procedure dealloc => dealloc_det_data - end type comm_detdata - ! Class for uncompressed data for a given scan - type :: comm_scandata - integer(i4b) :: ntod, ndet, nhorn, ndelta - real(sp), allocatable, dimension(:,:) :: tod ! Raw data - real(sp), allocatable, dimension(:,:) :: n_corr ! Correlated noise in V - real(sp), allocatable, dimension(:,:) :: s_sl ! Sidelobe correction - real(sp), allocatable, dimension(:,:) :: s_sky ! Stationary sky signal - real(sp), allocatable, dimension(:,:,:) :: s_sky_prop ! Stationary sky signal proposal for bandpass sampling - real(sp), allocatable, dimension(:,:) :: s_orb ! Orbital dipole - real(sp), allocatable, dimension(:,:) :: s_mono ! Detector monopole correction - real(sp), allocatable, dimension(:,:) :: s_calib ! Custom calibrator - real(sp), allocatable, dimension(:,:) :: s_calibA ! Custom calibrator - real(sp), allocatable, dimension(:,:) :: s_calibB ! Custom calibrator - real(sp), allocatable, dimension(:,:) :: s_bp ! Bandpass correction - real(sp), allocatable, dimension(:,:,:) :: s_bp_prop ! Bandpass correction proposal - real(sp), allocatable, dimension(:,:) :: s_zodi ! Zodiacal emission - real(sp), allocatable, dimension(:,:,:) :: s_zodi_scat ! Scattered sunlight contribution to zodi - real(sp), allocatable, dimension(:,:,:) :: s_zodi_therm ! Thermal zodiacal emission - real(sp), allocatable, dimension(:,:) :: s_inst ! Instrument-specific correction template - real(sp), allocatable, dimension(:,:) :: s_tot ! Total signal - real(sp), allocatable, dimension(:,:) :: s_gain ! Absolute calibrator - real(sp), allocatable, dimension(:,:) :: mask ! TOD mask (flags + main processing mask) - real(sp), allocatable, dimension(:,:) :: mask2 ! Small TOD mask, for bandpass sampling - real(sp), allocatable, dimension(:,:) :: mask_zodi ! Mask for sampling zodi - integer(i4b), allocatable, dimension(:,:,:) :: pix ! Discretized pointing - integer(i4b), allocatable, dimension(:,:,:) :: psi ! Discretized polarization angle - integer(i4b), allocatable, dimension(:,:) :: flag ! Quality flags - real(sp), allocatable, dimension(:,:) :: s_totA ! Total signal, horn A (differential only) - real(sp), allocatable, dimension(:,:) :: s_totB ! Total signal, horn B (differential only) - real(sp), allocatable, dimension(:,:) :: s_gainA ! Total signal, horn A (differential only) - real(sp), allocatable, dimension(:,:) :: s_gainB ! Total signal, horn B (differential only) - real(sp), allocatable, dimension(:,:) :: s_orbA ! Orbital signal, horn A (differential only) - real(sp), allocatable, dimension(:,:) :: s_orbB ! Orbital signal, horn B (differential only) - real(sp), allocatable, dimension(:,:) :: dark ! Dark bolometer signals - integer(i4b) :: band ! Band ID - contains - procedure :: init_singlehorn => init_scan_data_singlehorn - procedure :: init_differential => init_scan_data_differential - procedure :: dealloc => dealloc_scan_data - end type comm_scandata - - contains @@ -369,7 +326,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, end do ! Apply non-linearity corrections - !if (.not. skip_nonlin_) call tod%apply_nonlin_corr_inst(scan, sd) + if (.not. skip_nonlin_) call tod%apply_nonlin_corr_inst(scan, sd) !call update_status(status, "todinit_stot") @@ -783,9 +740,9 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr ![Debug] if (tod%myid == 0) write(*,*) '| --> Preparing data ' !on, mode = ', trim(mode) ! Prepare data if (tod%nhorn == 1) then - call sd%init_singlehorn(tod, i, map_sky, map_gain, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, map_gain, procmask, procmask2) else - call sd%init_differential(tod, i, map_sky, map_gain, procmask, procmask2, polang=polang) + call init_scan_data_differential(sd, tod, i, map_sky, map_gain, procmask, procmask2, polang=polang) end if ![Debug] if (tod%myid == 0) write(*,*) '| --> Setup filtered calibration signal'! m(mode) @@ -919,7 +876,7 @@ subroutine sample_baseline(tod, handle, map_sky, map_gain, procmask, procmask2) ! Prepare data if (tod%nhorn == 1) then - call sd%init_singlehorn(tod, i, map_sky, map_gain, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, map_gain, procmask, procmask2) else call init_scan_data_differential(sd, tod, i, map_sky, map_gain, procmask, procmask2) end if diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index a39b9db55..ddce9cf1b 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -98,6 +98,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%correct_sl = .true. end if c%correct_orb = .true. + c%apply_inst_corr = .true. c%orb_4pi_beam = .false. c%symm_flags = .false. c%chisq_threshold = 1000.d0 !20.d0 ! 9.d0 @@ -330,7 +331,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) end do !!$ call mpi_finalize(ierr) @@ -350,7 +351,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call self%cray(j)%p%fit_cray_amplitudes(sd%tod(j,:), sd%s_inst(j, :)) - call sd%dealloc + call dealloc_scan_data(sd) end do call dd%dealloc @@ -396,11 +397,11 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if ! Sample correlated noise @@ -448,7 +449,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) deallocate(d_calib) end do @@ -634,7 +635,7 @@ module subroutine set_modulation_phase(self, tod, scan) end do if (n == 0) then - write(*,*) "Scan disabled in set_modulation_phase; no samples crossing the galactic plane (should not happen)" + write(*,*) "set_modulation_phase: no samples crossing the galactic plane. Scan disabled = ", tod%scanid(scan) tod%scans(scan)%d(i)%accept = .false. else mu = mu/n @@ -672,7 +673,6 @@ module subroutine demodulate_tod(self, tod, scan) integer(i4b) :: i, j real(sp) :: sgn - logical :: exists !!$ open(58,file='tod_adc.dat') !!$ do j = 1, self%ntod diff --git a/commander3/src/comm_tod_lb_mod.f90 b/commander3/src/comm_tod_lb_mod.f90 index 72de77277..09a2f08da 100644 --- a/commander3/src/comm_tod_lb_mod.f90 +++ b/commander3/src/comm_tod_lb_mod.f90 @@ -328,11 +328,11 @@ subroutine process_LB_tod(self, chaindir, chain, iter, handle, map_in, delta, ma ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) @@ -378,7 +378,7 @@ subroutine process_LB_tod(self, chaindir, chain, iter, handle, map_in, delta, ma end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) deallocate(s_buf, d_calib) end do diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index 5fad3102b..c90100e4b 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -795,11 +795,11 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if ! Make simulations, or draw correlated noise @@ -867,9 +867,8 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) call timer%start(TOD_ALLOC, self%band) - call sd%dealloc deallocate(d_calib) call timer%stop(TOD_ALLOC, self%band) @@ -1637,7 +1636,7 @@ module subroutine sample_1Hz_spikes(tod, handle, map_sky, m_gain, procmask, proc ! Prepare data tod%apply_inst_corr = .false. ! Disable 1Hz correction for just this call - call sd%init_singlehorn(tod, i, map_sky, m_gain, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, m_gain, procmask, procmask2) tod%apply_inst_corr = .true. ! Enable 1Hz correction again call timer%start(TOD_1HZ, tod%band) @@ -1694,7 +1693,7 @@ module subroutine sample_1Hz_spikes(tod, handle, map_sky, m_gain, procmask, proc !!$ end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) deallocate(res) call timer%stop(TOD_1HZ, tod%band) end do diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 3267ea159..9818952aa 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -31,7 +31,7 @@ module comm_tod_mod implicit none private - public comm_tod, comm_scan, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer, distribute_sky_maps + public comm_tod, comm_scan, comm_scandata, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer, distribute_sky_maps ! Structure for individual detectors type :: comm_detscan @@ -277,6 +277,7 @@ module comm_tod_mod procedure(process_tod), deferred :: process_tod procedure :: construct_sl_template procedure :: construct_corrtemp_inst + procedure :: apply_nonlin_corr_inst procedure :: construct_dipole_template procedure :: construct_dipole_template_diff procedure :: output_scan_list @@ -321,6 +322,44 @@ end subroutine process_tod type tod_pointer class(comm_tod), pointer :: p => null() end type tod_pointer + + ! Class for uncompressed data for a given scan + type :: comm_scandata + integer(i4b) :: ntod, ndet, nhorn, ndelta + real(sp), allocatable, dimension(:,:) :: tod ! Raw data + real(sp), allocatable, dimension(:,:) :: n_corr ! Correlated noise in V + real(sp), allocatable, dimension(:,:) :: s_sl ! Sidelobe correction + real(sp), allocatable, dimension(:,:) :: s_sky ! Stationary sky signal + real(sp), allocatable, dimension(:,:,:) :: s_sky_prop ! Stationary sky signal proposal for bandpass sampling + real(sp), allocatable, dimension(:,:) :: s_orb ! Orbital dipole + real(sp), allocatable, dimension(:,:) :: s_mono ! Detector monopole correction + real(sp), allocatable, dimension(:,:) :: s_calib ! Custom calibrator + real(sp), allocatable, dimension(:,:) :: s_calibA ! Custom calibrator + real(sp), allocatable, dimension(:,:) :: s_calibB ! Custom calibrator + real(sp), allocatable, dimension(:,:) :: s_bp ! Bandpass correction + real(sp), allocatable, dimension(:,:,:) :: s_bp_prop ! Bandpass correction proposal + real(sp), allocatable, dimension(:,:) :: s_zodi ! Zodiacal emission + real(sp), allocatable, dimension(:,:,:) :: s_zodi_scat ! Scattered sunlight contribution to zodi + real(sp), allocatable, dimension(:,:,:) :: s_zodi_therm ! Thermal zodiacal emission + real(sp), allocatable, dimension(:,:) :: s_inst ! Instrument-specific correction template + real(sp), allocatable, dimension(:,:) :: s_tot ! Total signal + real(sp), allocatable, dimension(:,:) :: s_gain ! Absolute calibrator + real(sp), allocatable, dimension(:,:) :: mask ! TOD mask (flags + main processing mask) + real(sp), allocatable, dimension(:,:) :: mask2 ! Small TOD mask, for bandpass sampling + real(sp), allocatable, dimension(:,:) :: mask_zodi ! Mask for sampling zodi + integer(i4b), allocatable, dimension(:,:,:) :: pix ! Discretized pointing + integer(i4b), allocatable, dimension(:,:,:) :: psi ! Discretized polarization angle + integer(i4b), allocatable, dimension(:,:) :: flag ! Quality flags + real(sp), allocatable, dimension(:,:) :: s_totA ! Total signal, horn A (differential only) + real(sp), allocatable, dimension(:,:) :: s_totB ! Total signal, horn B (differential only) + real(sp), allocatable, dimension(:,:) :: s_gainA ! Total signal, horn A (differential only) + real(sp), allocatable, dimension(:,:) :: s_gainB ! Total signal, horn B (differential only) + real(sp), allocatable, dimension(:,:) :: s_orbA ! Orbital signal, horn A (differential only) + real(sp), allocatable, dimension(:,:) :: s_orbB ! Orbital signal, horn B (differential only) + real(sp), allocatable, dimension(:,:) :: dark ! Dark bolometer signals + integer(i4b) :: band ! Band ID + end type comm_scandata + contains @@ -2007,6 +2046,22 @@ subroutine construct_corrtemp_inst(self, scan, pix, psi, s) end subroutine construct_corrtemp_inst + subroutine apply_nonlin_corr_inst(self, scan, sd) + ! Apply an instrument-specific non_linear corrections + ! + ! Arguments: + ! ---------- + ! self: comm_tod object + ! + implicit none + class(comm_tod), intent(in) :: self + integer(i4b), intent(in) :: scan + class(comm_scandata), intent(inout) :: sd + + return + + end subroutine apply_nonlin_corr_inst + subroutine construct_dipole_template(self, scan, pix, psi, s_dip) ! construct a CMB dipole template in the time domain diff --git a/commander3/src/comm_tod_pixhist_mod.f90 b/commander3/src/comm_tod_pixhist_mod.f90 index 1ddbf8b93..9bf8d08ef 100644 --- a/commander3/src/comm_tod_pixhist_mod.f90 +++ b/commander3/src/comm_tod_pixhist_mod.f90 @@ -34,7 +34,7 @@ subroutine compute_min_max_nhit_per_pix(tod, map_sky, map_gain, procmask, procma if (.not. any(tod%scans(i)%d%accept)) cycle ! Prepare data - call sd%init_singlehorn(tod, i, map_sky, map_gain, procmask, procmask2) + call init_scan_data_singlehorn(sd, tod, i, map_sky, map_gain, procmask, procmask2) ! Find min, max and nhits do j = 1, tod%ndet @@ -51,7 +51,7 @@ subroutine compute_min_max_nhit_per_pix(tod, map_sky, map_gain, procmask, procma end do ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) end do end subroutine compute_min_max_nhit_per_pix diff --git a/commander3/src/comm_tod_spider_smod.f90 b/commander3/src/comm_tod_spider_smod.f90 index cc63187a6..704cd5109 100644 --- a/commander3/src/comm_tod_spider_smod.f90 +++ b/commander3/src/comm_tod_spider_smod.f90 @@ -380,18 +380,18 @@ module subroutine process_SPIDER_tod(self, chaindir, chain, iter, handle, map_in ! Prepare data if (sample_rel_bandpass) then ! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else - call sd%init_singlehorn(self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if allocate(s_buf(sd%ntod,sd%ndet)) ! Calling Simulation Routine if (self%enable_tod_simulations) then call simulate_tod(self, i, sd%s_tot, sd%n_corr, handle) - call sd%dealloc + call dealloc_scan_data(sd) cycle end if @@ -660,7 +660,7 @@ module subroutine process_SPIDER_tod(self, chaindir, chain, iter, handle, map_in end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) deallocate(s_buf, d_calib) deallocate(s_jump, jumps, tod_gapfill, jump_calib, test_array) diff --git a/commander3/src/comm_tod_wmap_mod.f90 b/commander3/src/comm_tod_wmap_mod.f90 index ce78d7704..17979d53b 100644 --- a/commander3/src/comm_tod_wmap_mod.f90 +++ b/commander3/src/comm_tod_wmap_mod.f90 @@ -541,11 +541,11 @@ subroutine process_WMAP_tod(self, chaindir, chain, iter, handle, map_in, delta, call update_status(status, "baseline") do i = 1, self%nscan if (.not. any(self%scans(i)%d%accept)) cycle - call sd%init_differential(self, i, map_sky, m_gain, procmask, procmask2) + call init_scan_data_differential(sd, self, i, map_sky, m_gain, procmask, procmask2) call timer%start(TOD_BASELINE, self%band) call sample_baseline_WMAP(self, i, sd%tod, sd%s_tot, sd%mask, handle) call timer%stop(TOD_BASELINE, self%band) - call sd%dealloc + call dealloc_scan_data(sd) end do self%apply_inst_corr = .true. @@ -610,11 +610,11 @@ subroutine process_WMAP_tod(self, chaindir, chain, iter, handle, map_in, delta, & real(self%spinaxis(i,:),sp) end if if (select_data) then - call sd%init_differential(self, i, map_sky, m_gain, procmask, procmask2, & + call init_scan_data_differential(sd, self, i, map_sky, m_gain, procmask, procmask2, & & init_s_bp=bp_corr) n_tot = n_tot + sd%ntod/1000 n_flag = n_flag + sd%ntod/1000 - call sd%dealloc + call dealloc_scan_data(sd) end if cycle end if @@ -738,7 +738,7 @@ subroutine process_WMAP_tod(self, chaindir, chain, iter, handle, map_in, delta, end if ! Clean up - call sd%dealloc + call dealloc_scan_data(sd) call timer%start(TOD_ALLOC, self%band) deallocate(s_buf, d_calib) call timer%stop(TOD_ALLOC, self%band) From 02165b26c8b8b7dfd83f2484e1c8ab8da3c8deae Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 27 Feb 2025 18:37:26 +0100 Subject: [PATCH 124/171] Enabled gain sampling in HFI --- .../defaults/bands/HFI/HFI_545-1_TOD.defaults | 5 +++++ .../defaults/components/cmb/cmb_relquad.defaults | 2 +- commander3/src/comm_tod_hfi_smod.f90 | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults index 765c28b93..7c911e804 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults @@ -74,3 +74,8 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 BAND_TOD_FILELIST&&& = filelist_545_Artem_full_pointing_DPC.txt #filelist_545_Artem_full.txt +BAND_TOD_ZODI_SUBTRACTION&&& = .false. +BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01_n512.fits +BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 +BAND_TOD_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults index f339a4f2c..7741f651c 100644 --- a/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults +++ b/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults @@ -10,5 +10,5 @@ COMP_CG_SAMPLE_GROUP&& = 0 COMP_PRIOR_GAUSS_MEAN&& = 1.d0 COMP_PRIOR_GAUSS_RMS&& = 0.d0 COMP_DEFAULT_AMPLITUDE&& = 1.d0 -COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def.txt +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def_v2.txt COMP_INIT_FROM_HDF&& = none diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index ddce9cf1b..0f481575a 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -229,7 +229,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Toggle optional operations sample_rel_bandpass = size(delta,3) > 1 ! Sample relative bandpasses if more than one proposal sky sample_abs_bandpass = .false. ! don't sample absolute bandpasses - sample_gain = .false. ! Don't sample gains until other effects are under better control + sample_gain = .true. ! Don't sample gains until other effects are under better control select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration @@ -265,9 +265,6 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call map_in(1,1)%p%writeFITS(trim(self%outdir) // "/input_sky_model_"//trim(self%label(1))//".fits") !call self%procmask%writeFITS("mask.fits") -! call mpi_finalize(ierr) -! stop - ! Precompute far sidelobe Conviqt structures if (self%correct_sl) then if (self%myid == 0) write(*,*) 'Precomputing sidelobe convolved sky' From 3049845f9437ab6cfe6abb62baee8e9f4182ab3f Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 3 Mar 2025 11:15:37 +0100 Subject: [PATCH 125/171] Added white noise PSD class, tuned HFI flagging, enabled Ncorr sampling in HFI mod, added fallback in Ncorr sampler for cases it fails --- commander3/src/comm_tod_driver_mod.f90 | 11 +- commander3/src/comm_tod_hfi_mod.f90 | 2 +- commander3/src/comm_tod_hfi_smod.f90 | 108 ++++++--- commander3/src/comm_tod_mod.f90 | 113 +++++---- commander3/src/comm_tod_noise_mod.f90 | 102 ++++++-- commander3/src/comm_tod_noise_psd_mod.f90 | 281 +++++++++++++++++----- commander3/src/comm_utils.f90 | 207 +++++++++++++++- commander3/src/math_tools.f90 | 164 ------------- 8 files changed, 635 insertions(+), 353 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index d0b25c625..fc39cd4e3 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -744,7 +744,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr else call init_scan_data_differential(sd, tod, i, map_sky, map_gain, procmask, procmask2, polang=polang) end if - + ![Debug] if (tod%myid == 0) write(*,*) '| --> Setup filtered calibration signal'! m(mode) ! Set up filtered calibration signal, conditional contribution and mask call timer%start(timer_id, tod%band) @@ -782,7 +782,8 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr call tod%downsample_tod(s_buf(:,j), ext, s_invsqrtN(:,j)) end if end do - ! [Debug] if (tod%myid == 0) write(*,*) '| --> Passed the loop with downsampel tod'!(mode) + + ! [Debug] if (tod%myid == 0) write(*,*) '| --> Passed the loop with downsampls tod'!(mode) call multiply_inv_N(tod, i, s_invsqrtN, sampfreq=tod%samprate_lowres, pow=0.5d0) if (trim(mode) == 'abscal' .or. trim(mode) == 'relcal' .or. trim(mode) == 'imbal') then @@ -1021,6 +1022,12 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) if (.not. tod%scans(scan)%d(j)%accept) cycle inv_gain = 1.0 / tod%scans(scan)%d(j)%gain if (tod%compressed_tod) then +!!$ write(*,*) 'calib g', tod%scanid(scan), inv_gain +!!$ write(*,*) 'calib d', tod%scanid(scan), maxval(abs(sd%tod(:,j))) +!!$ write(*,*) 'calib n', tod%scanid(scan), maxval(abs(sd%n_corr(:,j))) +!!$ write(*,*) 'calib t', tod%scanid(scan), maxval(abs(sd%s_tot(:,j))) +!!$ write(*,*) 'calib s', tod%scanid(scan), maxval(abs(sd%s_sky(:,j))) +!!$ write(*,*) 'calib b', tod%scanid(scan), maxval(abs(sd%s_bp(:,j))) d_calib(1,:,j) = (sd%tod(:,j) - sd%n_corr(:,j)) & & * inv_gain - sd%s_tot(:,j) + sd%s_sky(:,j) - sd%s_bp(:,j) else diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index c0a536412..b0f1724e9 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -40,7 +40,7 @@ module comm_tod_hfi_mod public comm_hfi_tod type, extends(comm_tod) :: comm_hfi_tod - integer(i4b), allocatable, dimension(:,:) :: mod_phase + real(sp), allocatable, dimension(:,:) :: mod_phase class(comm_crosstalk), pointer :: xtalk contains procedure :: process_tod => process_hfi_tod diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index 0f481575a..3deece8e0 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -63,22 +63,25 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Set up noise PSD type and priors c%freq = cpar%ds_label(id_abs) c%n_xi = 3 - c%noise_psd_model = 'oof' + !c%noise_psd_model = 'white' ! Using white noise until we get better estimates of the actual noise PSD + c%noise_psd_model = 'oof' ! Not fitted parameters yet allocate(c%xi_n_P_uni(c%n_xi,2)) allocate(c%xi_n_P_rms(c%n_xi)) allocate(c%xi_n_nu_fit(c%n_xi,2)) ! just so that it actually runs - c%xi_n_P_uni(2,:) = [0.010d0, 0.45d0] ! fknee + c%xi_n_P_uni(2,:) = [0.001d0, 1.0d0] ! fknee c%xi_n_P_uni(3,:) = [-2.5d0, -0.4d0] ! alpha - do k = 1, c%n_xi - c%xi_n_nu_fit(k,:) = [0.d0, 3*1.225d0] ! Placeholder - end do + !do k = 1, c%n_xi + ! c%xi_n_nu_fit(k,:) = [0.d0, 3*1.225d0] ! Placeholder + !end do !TODO: These numbers are made up, we should refine them c%xi_n_nu_fit(1,:) = [3.d0, 10.d0] c%xi_n_nu_fit(2,:) = [0.d0, 1.25d0] c%xi_n_nu_fit(3,:) = [0.d0, 1.25d0] - c%xi_n_P_rms = [-1.d0, 0.1d0, 0.2d0] ! [sigma0, fknee, alpha]; sigma0 is not used + !c%xi_n_P_rms = [-1.d0, 0.1d0, 0.2d0] ! [sigma0, fknee, alpha]; sigma0 is not used + c%xi_n_P_rms = [-1.d0, 0.1d0, -1d0] ! [sigma0, fknee, alpha]; sigma0 is not used + !c%xi_n_P_rms = [-1.d0] ! [sigma0]; sigma0 is not used c%n_cray_temps = 3 @@ -88,7 +91,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) call c%tod_constructor(cpar, id, id_abs, info, tod_type) ! Initialize instrument-specific parameters - c%samprate_lowres = 1.d0 ! Lowres samprate in Hz + c%samprate_lowres = 18. ! Lowres samprate in Hz; 10 times lower than the intrinsic HFI rate for now c%nhorn = 1 c%compressed_tod = .true. c%correct_sl = .false. @@ -144,7 +147,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) ! Allocate modulation phase allocate(c%mod_phase(c%ndet,c%nscan)) - c%mod_phase = 1.d0 + c%mod_phase = 1.0 ! initialize crosstalk class allocate(correlations(c%ndet, c%ndet)) @@ -209,7 +212,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps - logical(lgt) :: select_data, sample_gain, sample_abs_bandpass, sample_rel_bandpass, output_scanlist + logical(lgt) :: select_data, sample_gain, sample_ncorr, sample_abs_bandpass, sample_rel_bandpass, output_scanlist type(comm_binmap) :: binmap type(comm_scandata) :: sd type(comm_detdata) :: dd @@ -229,7 +232,8 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Toggle optional operations sample_rel_bandpass = size(delta,3) > 1 ! Sample relative bandpasses if more than one proposal sky sample_abs_bandpass = .false. ! don't sample absolute bandpasses - sample_gain = .true. ! Don't sample gains until other effects are under better control + sample_gain = .false. + sample_ncorr = iter > 1 !.true. select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration @@ -343,13 +347,13 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call self%cray(j)%p%build_cray_templates() - do i=1, self%nscan - call populate_sd_from_dd(sd, dd, i, j) - - call self%cray(j)%p%fit_cray_amplitudes(sd%tod(j,:), sd%s_inst(j, :)) - - call dealloc_scan_data(sd) - end do +!!$ do i=1, self%nscan +!!$ call populate_sd_from_dd(sd, dd, i, j) +!!$ +!!$ call self%cray(j)%p%fit_cray_amplitudes(sd%tod(j,:), sd%s_inst(j, :)) +!!$ +!!$ call dealloc_scan_data(sd) +!!$ end do call dd%dealloc end do @@ -393,22 +397,47 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare data if (sample_rel_bandpass) then -! if (.true. .or. self%myid == 78) write(*,*) 'b', self%myid, self%correct_sl, self%ndet, self%slconv(1)%p%psires call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) else call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) end if - - ! Sample correlated noise - - !call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) - sd%n_corr = 0.d0 - - ! Compute noise spectrum parameters - !call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + + ! Create dynamic mask + if (self%first_call) then + ! Estimate sigma0 for masking + sd%n_corr = 0.d0 + call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, only_sigma0=.true.) + + ! Create mask + do j = 1, sd%ndet + if (.not. self%scans(i)%d(j)%accept) cycle + call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & + & [-5.,5.], sd%mask(:,j), sd%flag(:,j), .false., [.true.,.true.,.true.,.true.,.false.,.true.,.false.,.false.]) + end do + call dealloc_scan_data(sd) + if (.not. any(self%scans(i)%d%accept)) cycle + + ! Update scan data with new flagging + if (sample_rel_bandpass) then + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + else if (sample_abs_bandpass) then + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + else + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + end if + end if + ! Sample correlated noise + if (sample_ncorr) then + call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), nomono=.true.) + call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + else + sd%n_corr = 0.d0 + call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, only_sigma0=.true.) + end if + ! Compute chisquare do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle @@ -426,11 +455,13 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d d_calib = 0.d0 call compute_calibrated_data(self, i, sd, d_calib) -!!$ open(58,file='res.dat', recl=1024) -!!$ do j = 1, sd%ntod -!!$ write(58,*) j, sd%tod(j,1), d_calib(2,j,1), sd%pix(j,1,1), sd%flag(j,1) -!!$ end do -!!$ close(58) + if (self%scanid(i) == 500) then + open(58,file='res'//samptext//'.dat', recl=1024) + do j = 1, sd%ntod + write(58,*) j, sd%tod(j,1), sd%n_corr(j,1), d_calib(1,j,1), d_calib(2,j,1), 1-(sd%flag(j,1)/maxval(sd%flag(:,1))) + end do + close(58) + end if ! Bin TOD call bin_TOD(self, i, sd%pix(:,:,1), sd%psi(:,:,1), sd%flag, d_calib, binmap) @@ -550,7 +581,8 @@ module subroutine sample_hfi_baselines(self, tod, scan, handle, subtract_s_tot) ! tod%scans(scan)%d(i)%gain - the gain constant over a scan [real number] ! sd = self --- self%s_tot - sky signal model ! self%s_tot(self%ntod, self%ndet) - how s_tot structured - + + if (tod%scanid(scan) == 500) open(58,file='baseline.dat', recl=1024) do i = 1, tod%ndet if (.not. tod%scans(scan)%d(i)%accept) cycle sgn = tod%mod_phase(i,scan) @@ -562,26 +594,30 @@ module subroutine sample_hfi_baselines(self, tod, scan, handle, subtract_s_tot) A1 = A1 + 1.d0 b1 = b1 + self%tod(j,i) if (sub_s) b1 = b1 - sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) + if (tod%scanid(scan) == 500) write(58,*) j, self%tod(j,i), self%tod(j,i) - sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) end do A1 = A1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 b1 = b1 / tod%scans(scan)%d(i)%N_psd%sigma0**2 tod%scans(scan)%d(i)%baseline1 = b1/A1 + rand_gauss(handle)/sqrt(A1) ! Even samples + if (tod%scanid(scan) == 500) write(58,*) A2 = 0.d0; b2 = 0.d0 do j = 2, self%ntod, 2 if (self%mask(j,i) == 0) cycle A2 = A2 + 1.d0 b2 = b2 + self%tod(j,i) - if (sub_s) b1 = b1 + sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) + if (sub_s) b2 = b2 + sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) + if (tod%scanid(scan) == 500) write(58,*) j, self%tod(j,i), self%tod(j,i) + sgn*tod%scans(scan)%d(i)%gain * self%s_tot(j,i) end do A2 = A2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 b2 = b2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 tod%scans(scan)%d(i)%baseline2 = b2/A2 + rand_gauss(handle)/sqrt(A2) - !write(*,*) "baseline=", tod%scans(scan)%d(i)%baseline1, tod%scans(scan)%d(i)%baseline2, tod%mod_phase(i,scan) + write(*,'(a,i8,3f16.3)') "baseline =", tod%scanid(scan), tod%scans(scan)%d(i)%baseline1, tod%scans(scan)%d(i)%baseline2, sgn end do + if (tod%scanid(scan) == 500) close(58) end subroutine sample_hfi_baselines @@ -623,9 +659,9 @@ module subroutine set_modulation_phase(self, tod, scan) do j = 1, self%ntod, 2 if (self%pix(j,i,1) > 0.48*tod%info%npix .and. self%pix(j,i,1) < 0.52*tod%info%npix) then if (mod(j,2) == 1) then - mu = mu + self%tod(j,1)-tod%scans(scan)%d(i)%baseline1 + mu = mu + (self%tod(j,1)-tod%scans(scan)%d(i)%baseline1) else - mu = mu - self%tod(j,1)-tod%scans(scan)%d(i)%baseline1 + mu = mu - (self%tod(j,1)-tod%scans(scan)%d(i)%baseline2) end if n = n + 1.d0 end if diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 9818952aa..5573cfb81 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -465,7 +465,9 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%orbital = .true. end if - if (trim(self%noise_psd_model) == 'oof') then + if (trim(self%noise_psd_model) == 'white') then + self%n_xi = 1 ! {sigma0} + else if (trim(self%noise_psd_model) == 'oof') then self%n_xi = 3 ! {sigma0, fknee, alpha} else if (trim(self%noise_psd_model) == '2oof') then self%n_xi = 5 ! {sigma0, fknee, alpha, fknee2, alpha2} @@ -1110,8 +1112,10 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio self%d(i)%gain_def = scalars(1) self%d(i)%gain = scalars(1) - xi_n(1:3) = scalars(2:4) - xi_n(1) = xi_n(1) * self%d(i)%gain_def ! Convert sigma0 to uncalibrated units + xi_n(1) = scalars(2) * self%d(i)%gain_def ! Convert sigma0 to uncalibrated units + if (tod%n_xi >= 3) then + xi_n(2:3) = scalars(3:4) + end if self%d(i)%gain = self%d(i)%gain_def self%d(i)%accept = .true. @@ -1120,24 +1124,23 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio self%d(i)%baseline = 0. end if - if (trim(tod%noise_psd_model) == 'oof') then - self%d(i)%N_psd => comm_noise_psd(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) + if (trim(tod%noise_psd_model) == 'white') then + self%d(i)%N_psd => comm_noise_psd_white(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) + else if (trim(tod%noise_psd_model) == 'oof') then + self%d(i)%N_psd => comm_noise_psd_oof(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) else if (trim(tod%noise_psd_model) == '2oof') then xi_n(4) = 1e-4 ! fknee2 (Hz); arbitrary value xi_n(5) = -1.000 ! alpha2; arbitrary value self%d(i)%N_psd => comm_noise_psd_2oof(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) - else if (trim(tod%noise_psd_model) == 'oof_gauss') then xi_n(4) = 0.00d0 xi_n(5) = 1.35d0 xi_n(6) = 0.40d0 self%d(i)%N_psd => comm_noise_psd_oof_gauss(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) - else if (trim(tod%noise_psd_model) == 'oof_quad') then xi_n(4) = 0d0 xi_n(5) = 0d0 self%d(i)%N_psd => comm_noise_psd_oof_quad(xi_n, tod%xi_n_P_rms, tod%xi_n_P_uni, tod%xi_n_nu_fit) - !!$ open(58,file='noise.dat') !!$ nu = 0.001d0 !!$ do while (.true.) @@ -1147,7 +1150,6 @@ subroutine read_hdf_scan(self, tod, filename, scan, ndet, detlabels, nhorn, ndio !!$ end do !!$ close(58) !!$ stop - end if deallocate(xi_n) @@ -3217,7 +3219,7 @@ subroutine clear_zodi_cache(self, obs_time) end if end subroutine clear_zodi_cache - subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only_solar_mask) + subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only_solar_mask, apply_flag) implicit none class(comm_tod), intent(inout) :: self integer(i4b), intent(in) :: scan, det @@ -3226,6 +3228,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only real(sp), dimension(:), intent(inout) :: mask integer(i4b), dimension(:), intent(inout) :: flag logical(lgt), intent(in) :: only_solar_mask + logical(lgt), dimension(8), intent(in), optional :: apply_flag integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut, b_elon real(dp) :: rms0 @@ -3237,23 +3240,26 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only if (sum(mask) == 0) return - apply_cut(1) = .true. ! Extreme outliers - apply_cut(2) = .true. ! Single sample outliers - apply_cut(3) = .true. ! Excess variance in windows of 5 samples - apply_cut(4) = .true. ! Excess variance in windows of 50 samples - apply_cut(5) = .true. ! Excess variance in windows of 500 samples - apply_cut(6) = .true. ! Isolated samples - apply_cut(7) = .true. ! Long chunks with many masked samples - apply_cut(8) = .true. ! Solar mask - if (only_solar_mask) apply_cut(1:7) = .false. - + if (present(apply_flag)) then + apply_cut = apply_flag + else + apply_cut(1) = .true. ! Extreme outliers + apply_cut(2) = .true. ! Single sample outliers + apply_cut(3) = .true. ! Excess variance in windows of 5 samples + apply_cut(4) = .true. ! Excess variance in windows of 50 samples + apply_cut(5) = .true. ! Excess variance in windows of 500 samples + apply_cut(6) = .true. ! Isolated samples + apply_cut(7) = .true. ! Long chunks with many masked samples + apply_cut(8) = .true. ! Solar mask + if (only_solar_mask) apply_cut(1:7) = .false. + end if ntod = size(res) ntot = count(iand(flag,self%flag0) .eq. 0) nmax = 1000 gain = self%scans(scan)%d(det)%gain - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flagging -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flags -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod ! Generate dynamic mask allocate(mask_dyn(ntod)) @@ -3267,7 +3273,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only if (apply_cut(1)) then ! Extreme outliers - threshold = 20. ! White noise sigma + threshold = 5. ! White noise sigma; DIRBE = 20 ncut = 0 do i = 1, ntod if (mask(i) == 1. .and. abs(res(i)) > threshold) then @@ -3284,7 +3290,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only if (apply_cut(2)) then allocate(cut(ntod)) ncut = 0 - ! open(58, file='var1.dat') + !open(58, file='var1.dat') do iter = 1, 1 ! Compute full-scan, masked rms0 rms0 = 0.d0 @@ -3327,14 +3333,14 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end do !close(58) deallocate(cut) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single spikes-- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if - + if (apply_cut(3)) then ! Look for excess variance excess in small windows; typically cosmic rays and other short glitches allocate(var_window(ntod)) - window = 5; threshold = 3. - call compute_running_variance(res, mask, window, var_window, var_mean=var0) + window = 5; threshold = 1.5 ! DIRBE = 3 + call compute_running_variance(res, mask, window, var_window, var_mean=var0, mean_full=.true.) var_window = sqrt(var_window) var0 = sqrt(var0) ncut = 0 @@ -3362,7 +3368,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only ! Look for excess variance excess in intermediate windows allocate(var_window(ntod)) window = 50; threshold = 2.0 - call compute_running_variance(res, mask, window, var_window, var_mean=var0) + call compute_running_variance(res, mask, window, var_window, var_mean=var0, mean_full=.true.) var_window = sqrt(var_window) ncut = 0 !open(58, file='var3.dat') @@ -3385,11 +3391,17 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if +!!$ open(58, file='var4.dat') +!!$ do i = 1, ntod +!!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) +!!$ end do +!!$ close(58) + if (apply_cut(5)) then ! Look for excess variance excess in large windows allocate(var_window(ntod)) window = 500; threshold = 1.5 - call compute_running_variance(res, mask, window, var_window, var_mean=var0) + call compute_running_variance(res, mask, window, var_window, var_mean=var0, mean_full=.true.) var_window = sqrt(var_window) ncut = 0 ! open(58, file='var3.dat') @@ -3415,21 +3427,21 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only if (apply_cut(6)) then ! Remove isolated samples ncut = 0 - if (mask(1) == 1. .and. mask(2) == 0.) then + if (iand(flag(1),self%flag0) .eq. 0 .and. iand(flag(2),self%flag0) .ne. 0) then mask_dyn(1) = 0. mask(1) = 0. flag(1) = huge(flag(1)) ncut = ncut + 1 end if do i = 2, ntod-1 - if (mask(i-1) == 0. .and. mask(i) == 1. .and. mask(i+1) == 0.) then + if (iand(flag(i-1),self%flag0) .ne. 0 .and. iand(flag(i),self%flag0) .eq. 0 .and. iand(flag(i+1),self%flag0) .ne. 0) then mask_dyn(i) = 0. mask(i) = 0. flag(i) = huge(flag(i)) ncut = ncut + 1 end if end do - if (mask(ntod) == 1. .and. mask(ntod-1) == 0.) then + if (iand(flag(ntod),self%flag0) .eq. 0 .and. iand(flag(ntod-1),self%flag0) .ne. 0) then mask_dyn(ntod) = 0. mask(ntod) = 0. flag(ntod) = huge(flag(ntod)) @@ -3462,38 +3474,16 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only ! close(58) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if - - ! Remove glitches in the high signal-to-noise regime - ! Must 1) be a masked pixel; 2) not already be flagged; 3) have a S/N > 10; 4) have a residual larger than some threshold times the expected signal -!!$ threshold = 0.50 -!!$ ncut = 0 -!!$ do i = 1, ntod -!!$ -!!$ if (mask(i) == 0. .and. iand(flag(i),self%flag0) .eq. 0 .and. abs(gain*s_sky(i)) > 10.d0 * self%scans(scan)%d(det)%N_psd%sigma0 .and. abs(res(i)) > threshold*abs(gain*s_sky(i))) then -!!$ mask_dyn(i) = 0. -!!$ mask(i) = 0. -!!$ flag(i) = huge(flag(i)) -!!$ ncut = ncut + 1 -!!$ end if -!!$ end do -!!$ write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, high S/N -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut - - - !mask_dyn(1:330000) = 0. - !mask(1:330000) = 0. - !mask_dyn(1:550000) = 0. - !mask(1:550000) = 0. - !mask_dyn(575000:) = 0. - !mask(575000:) = 0. - !flag(1:550000) = huge(flag(1)) - !flag(575000:) = huge(flag(1)) !!$ open(58, file='var5.dat') !!$ do i = 1, ntod !!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) !!$ end do !!$ close(58) - +!!$ +!!$ call mpi_finalize(i) +!!$ stop + ! Solar-centric mask if (apply_cut(8)) then ncut = 0 @@ -3576,7 +3566,12 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(iand(flag,self%flag0) .ne. 0),sp) / ntod, count(iand(flag,self%flag0) .ne. 0), ntod end if - + + if (count(iand(flag,self%flag0) .ne. 0) == 0) then + write(*,fmt='(a,a,i6,i4)') ' Dynamic mask, scan rejected = ', trim(self%freq), self%scanid(scan), det + self%scans(scan)%d(det)%accept = .false. + end if + deallocate(bad, mask_dyn) end subroutine create_dynamic_mask diff --git a/commander3/src/comm_tod_noise_mod.f90 b/commander3/src/comm_tod_noise_mod.f90 index 3857819ef..e01ef6022 100644 --- a/commander3/src/comm_tod_noise_mod.f90 +++ b/commander3/src/comm_tod_noise_mod.f90 @@ -72,15 +72,15 @@ subroutine sample_n_corr(self, tod, handle, scan, mask, s_sub, n_corr, pix, freq logical(lgt), intent(in), optional :: nomono integer(i4b) :: i, j, l, k, n, m, nomp, ntod, ndet, err, omp_get_max_threads - integer(i4b) :: nfft, nbuff, j_end, j_start + integer(i4b) :: nfft, nbuff, j_end, j_start, ndof integer*8 :: plan_fwd, plan_back logical(lgt) :: init_masked_region, end_masked_region, pcg_converged, nomono_ real(sp) :: sigma_0, alpha, nu_knee, samprate, gain, mean, N_wn, N_c, nu - real(dp) :: power, fft_norm + real(dp) :: power, fft_norm, var1, var2 character(len=1024) :: filename real(sp), allocatable, dimension(:) :: dt complex(spc), allocatable, dimension(:) :: dv - real(sp), allocatable, dimension(:) :: d_prime, ncorr2 + real(sp), allocatable, dimension(:) :: d_prime, ncorr2, ps call timer%start(TOD_NCORR, self%band) @@ -102,7 +102,7 @@ subroutine sample_n_corr(self, tod, handle, scan, mask, s_sub, n_corr, pix, freq call timer%stop(TOT_FFT) call timer%start(TOT_FFT) - allocate(dt(nfft), dv(0:n-1), d_prime(ntod), ncorr2(ntod)) + allocate(dt(nfft), dv(0:n-1), ps(0:n-1), d_prime(ntod), ncorr2(ntod)) call sfftw_plan_dft_r2c_1d(plan_fwd, nfft, dt, dv, fftw_estimate + fftw_unaligned) call sfftw_plan_dft_c2r_1d(plan_back, nfft, dv, dt, fftw_estimate + fftw_unaligned) call timer%stop(TOT_FFT) @@ -160,12 +160,38 @@ subroutine sample_n_corr(self, tod, handle, scan, mask, s_sub, n_corr, pix, freq ! Remove monopole if requested by user if (nomono_) d_prime = d_prime - sum(d_prime*mask(:,i))/sum(mask(:,i)) + + ! Output power spectrum of signal-subtracted gap-filled TOD to disk + if (.false. .and. self%scanid(scan) == 5012) then + !dt = (tod(:,i) - self%scans(scan)%d(i)%gain * s_tot(:,i))*mask(:,i) + dt(1:ntod) = d_prime(:) + dt(2*ntod:ntod+1:-1) = dt(1:ntod) + call sfftw_execute_dft_r2c(plan_fwd, dt, dv) + open(58,file='noise_psd.dat', recl=1024) + do l = 1, n-1 + ps(l) = abs(dv(l)) ** 2 / ntod + write(58,*) l*(samprate/2)/(n-1), ps(l), self%scans(scan)%d(i)%N_psd%eval_full(real(l*(samprate/2)/(n-1),sp)) + end do + close(58) + end if pcg_converged = .false. call get_ncorr_sm_cg(handle, d_prime, ncorr2, mask(:,i), self%scans(scan)%d(i)%N_psd, samprate, nfft, plan_fwd, plan_back, pcg_converged, self%scanid(scan), i, trim(self%freq), nomono_) n_corr(:,i) = ncorr2(:) + ! Check goodness-of-fit + var1 = 0.d0; var2 = 0.d0 + do j = 1, ntod + if (mask(j,i) == 1.) then + var1 = var1 + (d_prime(j)-ncorr2(j))**2 + var2 = var2 + d_prime(j)**2 + end if + end do + pcg_converged = pcg_converged .and. var1 < var2 + if (.not. pcg_converged) then + !write(*,*) 'Ncorr PCG failed, scan = ', self%scanid(scan), ', RMS ratio = ', sqrt(var1/var2) + ! Preparing for fft dt(1:ntod) = d_prime(:) dt(2*ntod:ntod+1:-1) = dt(1:ntod) @@ -204,24 +230,25 @@ subroutine sample_n_corr(self, tod, handle, scan, mask, s_sub, n_corr, pix, freq call timer%stop(TOT_FFT) dt = dt / nfft n_corr(:,i) = dt(1:ntod) + else + !write(*,*) 'Ncorr PCG accepted, scan = ', self%scanid(scan), ', RMS ratio = ', sqrt(var1/var2) end if - !if (.true. .and. mod(self%scanid(scan),100) == 1) then - ! write(filename, "(A, I0.3, A, I0.3, 3A)") 'ncorr_tods_new/ncorr_times', self%scanid(scan), '_', i, '_',trim(self%freq),'_final_hundred.dat' - ! open(65,file=trim(filename),status='REPLACE') - ! do j = 1, ntod - ! if (present(tod_arr)) then - ! write(65, '(14(E15.6E3))') n_corr(j,i), s_sub(j,i), mask(j,i), d_prime(j), real(tod_arr(j,i),sp), self%scans(scan)%d(i)%gain, self%scans(scan)%d(i)%N_psd%alpha, self%scans(scan)%d(i)%N_psd%fknee, self%scans(scan)%d(i)%N_psd%sigma0, self%scans(scan)%d(i)%N_psd%alpha_def, self%scans(scan)%d(i)%N_psd%fknee_def, self%scans(scan)%d(i)%N_psd%sigma0_def, self%samprate, ncorr2(j) - ! else - ! write(65, '(14(E15.6E3))') n_corr(j,i), s_sub(j,i), mask(j,i), d_prime(j), self%scans(scan)%d(i)%tod(j), self%scans(scan)%d(i)%gain, self%scans(scan)%d(i)%N_psd%alpha, self%scans(scan)%d(i)%N_psd%fknee, self%scans(scan)%d(i)%N_psd%sigma0, self%scans(scan)%d(i)%N_psd%alpha_def, self%scans(scan)%d(i)%N_psd%fknee_def, self%scans(scan)%d(i)%N_psd%sigma0_def, self%samprate, ncorr2(j) - ! end if - ! end do - ! close(65) - ! !stop - !end if + !if (.true. .and. mod(self%scanid(scan),1000) == 1) then + !if (.true. .and. self%scanid(scan) == 5013) then + if (.false.) then + write(filename, "(A, I0.3, A, I0.3, 3A)") 'ncorr_times', self%scanid(scan), '_', i, '_',trim(self%freq),'.dat' + open(65,file=trim(filename),status='REPLACE',recl=1024) + do j = 1, ntod + !write(65, '(i8,6(E15.6E3))') j, n_corr(j,i), s_sub(j,i), mask(j,i), d_prime(j), self%scans(scan)%d(i)%tod(j), ncorr2(j) + write(65, '(i8,7(E15.6E3))') j, d_prime(j), n_corr(j,i), ncorr2(j), sigma_0, ((d_prime(j)-n_corr(j,i))/sigma_0)**2, ((d_prime(j)-ncorr2(j))/sigma_0)**2, mask(j,i) + end do + close(65) + !stop + end if end do - deallocate(dt, dv) + deallocate(dt, dv, ps) deallocate(d_prime) deallocate(ncorr2) @@ -270,17 +297,20 @@ subroutine get_ncorr_sm_cg(handle, d_prime, ncorr, mask, N_psd, samprate, nfft, allocate(x(ntod), b(ntod), r(ntod), d(ntod), Mr(ntod), Ad(ntod)) allocate(u(nmask), bp(nmask), xp(nmask), rp(nmask), p(nmask)) - if (nomono) then - invNcorr(0) = 1d12 - else +! if (nomono) then +! invNcorr(0) = 1d12 +! else invNcorr(0) = 0.d0 - end if +! end if invM(0) = 1.d0 + !open(58,file='N_psd.dat', recl=1024) do l = 1, n-1 freq = l*(samprate/2)/(n-1) invNcorr(l) = N_psd%sigma0**2 / N_psd%eval_corr(freq) invM(l) = 1.d0 / (1.d0 + invNcorr(l)) + !write(58,*) freq, N_psd%sigma0**2, N_psd%eval_corr(freq), invM(l) end do + !close(58) j = 1 do i = 1, ntod @@ -326,6 +356,7 @@ subroutine get_ncorr_sm_cg(handle, d_prime, ncorr, mask, N_psd, samprate, nfft, xp = xp + alp*p rp = rp - alp * Ad(u) r2new = sum(rp**2) + !write(*,*) 'CG ncorr -- ', k, r2new, sigma_bp if (sqrt(abs(r2new)) < eps * sigma_bp * nmask) then ! average error in each datapoint < eps * sigma_bp converged = .true. exit @@ -339,6 +370,9 @@ subroutine get_ncorr_sm_cg(handle, d_prime, ncorr, mask, N_psd, samprate, nfft, x = Ad ncorr = x * N_psd%sigma0 + + ! Subtract monopole + if (nomono) ncorr = ncorr - sum(ncorr*mask)/sum(mask) deallocate(invNcorr, invM) deallocate(x, b, r, d, Mr, Ad) @@ -472,7 +506,7 @@ subroutine sample_noise_psd(self, tod, handle, scan, mask, s_tot, n_corr, freqma samprate = self%samprate n_gibbs = 1 threshold = 5.d0 ! Remove outliers - outscan = -1 !92 + outscan = 5013 !-1 !92 ! Sample sigma_0 from pairwise differenced TOD do i = 1, ndet @@ -630,6 +664,7 @@ subroutine multiply_inv_N(tod, scan, buffer, sampfreq, pow, off) logical(lgt) :: off_ real(sp), allocatable, dimension(:,:) :: dt complex(spc), allocatable, dimension(:,:) :: dv + class(comm_noise_psd), pointer :: N_psd ntod = size(buffer, 1) ndet = size(buffer, 2) @@ -639,7 +674,26 @@ subroutine multiply_inv_N(tod, scan, buffer, sampfreq, pow, off) pow_ = 1.d0; if (present(pow)) pow_ = pow off_ = .false.; if (present(off)) off_ = off samprate = real(tod%samprate,sp); if (present(sampfreq)) samprate = real(sampfreq,sp) - + + ! Check if white noise is requested; in that case, skip FFTs + N_psd => tod%scans(scan)%d(1)%N_psd + select type (N_psd) + class is (comm_noise_psd_white) + do i = 1, ndet + if (.not. tod%scans(scan)%d(i)%accept) then + buffer(:,i) = 0.d0 + else + buffer(:,i) = buffer(:,i) / (tod%scans(scan)%d(i)%N_psd%sigma0**2 * samprate / tod%samprate)**pow_ + end if + if (off_) then + ! Subtract offset + buffer(:,i) = buffer(:,i) - sum(buffer(:,i))/size(buffer(:,i)) + end if + end do + return + end select + + ! If not white noise, perform the multiplication in Fourier space allocate(dt(2*ntod,m), dv(0:n-1,m)) call timer%start(TOT_FFT) call sfftw_plan_many_dft_r2c(plan_fwd, 1, 2*ntod, m, dt, & diff --git a/commander3/src/comm_tod_noise_psd_mod.f90 b/commander3/src/comm_tod_noise_psd_mod.f90 index 8f9a5a516..93a01dac9 100644 --- a/commander3/src/comm_tod_noise_psd_mod.f90 +++ b/commander3/src/comm_tod_noise_psd_mod.f90 @@ -32,7 +32,7 @@ module comm_tod_noise_psd_mod implicit none private - public comm_noise_psd, comm_noise_psd_2oof, comm_noise_psd_oof_gauss, comm_noise_psd_oof_quad + public comm_noise_psd, comm_noise_psd_white, comm_noise_psd_oof, comm_noise_psd_2oof, comm_noise_psd_oof_gauss, comm_noise_psd_oof_quad integer(i4b), parameter :: SIGMA0 = 1 integer(i4b), parameter :: FKNEE = 2 @@ -45,7 +45,7 @@ module comm_tod_noise_psd_mod integer(i4b), parameter :: SLOPE = 4 integer(i4b), parameter :: QUADRATIC = 5 - type :: comm_noise_psd + type, abstract :: comm_noise_psd ! ! Class definition for basic 1/f noise PSD model ! @@ -60,16 +60,73 @@ module comm_tod_noise_psd_mod logical(lgt) :: apply_filter ! If we should apply the spline filter to the noise output type(spline_type) :: modulation_filter ! The filter multiplied to the output noise contains - procedure :: eval_full => eval_noise_psd_full - procedure :: eval_corr => eval_noise_psd_corr + procedure(eval_noise_psd_full), deferred :: eval_full + procedure(eval_noise_psd_corr), deferred :: eval_corr procedure :: init_common end type comm_noise_psd - interface comm_noise_psd - procedure constructor_oof - end interface comm_noise_psd - - + abstract interface + function eval_noise_psd_full(self, nu) + import comm_noise_psd, sp + ! + ! Evaluation routine for general noise PSD object; both correlated and uncorrelated components + ! + ! Arguments + ! --------- + ! self: derived type (comm_noise_psd) + ! Basic noise PSD object + ! nu: sp (scalar) + ! Frequency (in Hz) at which to evaluate PSD + ! + implicit none + class(comm_noise_psd), intent(in) :: self + real(sp), intent(in) :: nu + real(sp) :: eval_noise_psd_full + end function eval_noise_psd_full + end interface + + abstract interface + function eval_noise_psd_corr(self, nu) + import comm_noise_psd, sp + ! + ! Evaluation routine for general noise PSD object; correlated noise only + ! + ! Arguments + ! --------- + ! self: derived type (comm_noise_psd) + ! Basic noise PSD object + ! nu: sp (scalar) + ! Frequency (in Hz) at which to evaluate PSD + ! + implicit none + class(comm_noise_psd), intent(in) :: self + real(sp), intent(in) :: nu + real(sp) :: eval_noise_psd_corr + end function eval_noise_psd_corr + end interface + + ! ####################################### + ! Specific noise class definition + ! ####################################### + + type, extends(comm_noise_psd) :: comm_noise_psd_white + ! + ! Class definition for white noise PSD model + ! + contains + procedure :: eval_full => eval_noise_psd_white_full + procedure :: eval_corr => eval_noise_psd_white_corr + end type comm_noise_psd_white + + type, extends(comm_noise_psd) :: comm_noise_psd_oof + ! + ! Class definition for basic 1/f noise PSD model + ! + contains + procedure :: eval_full => eval_noise_psd_oof_full + procedure :: eval_corr => eval_noise_psd_oof_corr + end type comm_noise_psd_oof + type, extends(comm_noise_psd) :: comm_noise_psd_2oof ! ! Class definition for 2-component 1/f noise PSD model @@ -79,6 +136,7 @@ module comm_tod_noise_psd_mod procedure :: eval_corr => eval_noise_psd_2oof_corr end type comm_noise_psd_2oof + type, extends(comm_noise_psd) :: comm_noise_psd_oof_gauss ! ! Class definition for 2-component 1/f + Gauss noise PSD model @@ -97,6 +155,14 @@ module comm_tod_noise_psd_mod procedure :: eval_corr => eval_noise_psd_oof_quad_corr end type comm_noise_psd_oof_quad + interface comm_noise_psd_white + procedure constructor_white + end interface comm_noise_psd_white + + interface comm_noise_psd_oof + procedure constructor_oof + end interface comm_noise_psd_oof + interface comm_noise_psd_2oof procedure constructor_2oof end interface comm_noise_psd_2oof @@ -108,9 +174,135 @@ module comm_tod_noise_psd_mod interface comm_noise_psd_oof_quad procedure constructor_oof_quad end interface comm_noise_psd_oof_quad - + contains + subroutine init_common(self, P_active_mean, P_active_rms, P_uni, nu_fit, filter) + ! Contains common initialization for all classes of noise model + ! + ! Arguments: + ! + ! self : comm_tod_noise_psd_mod + ! The noise model object to initialize + implicit none + class(comm_noise_psd), target, intent(inout) :: self + real(sp), dimension(:), intent(in) :: P_active_mean + real(sp), dimension(:), intent(in) :: P_active_rms + real(sp), dimension(:,:), intent(in) :: P_uni + real(sp), dimension(:,:), intent(in) :: nu_fit + real(dp), optional, dimension(:,:), intent(in) :: filter + + allocate(self%xi_n(self%npar)) + allocate(self%P_uni(self%npar,2)) + allocate(self%P_active(self%npar,2)) + allocate(self%P_lognorm(self%npar)) + + self%xi_n = P_active_mean + self%P_uni = P_uni + self%P_active(:,1) = P_active_mean + self%P_active(:,2) = P_active_rms + self%nu_fit = nu_fit + + self%sigma0 => self%xi_n(1) + + if(.not. present(filter)) then + self%apply_filter = .false. + else + self%apply_filter = .true. + end if + + if(self%apply_filter) then + call spline(self%modulation_filter, filter(1,:), filter(2,:)) + end if + end subroutine + + function constructor_white(P_active_mean, P_active_rms, P_uni, nu_fit, filter) + ! + ! Constructor for basic white noise PSD object, where + ! + ! P(nu) = sigma0^2 + ! + ! Arguments + ! --------- + ! xi_n_def: sp (array) + ! 3-element array containing default {sigma0, alpha, fknee}, where + ! [sigma0] = du/volts/tod unit, [alpha] = 1, and [fknee] = Hz + ! P_uni: sp (2D array) + ! Array containing absolute upper and lower limits for each parameter (npar,upper/lower) + ! P_active: sp (2D array) + ! Array containing informative priors for each parameter (npar,mean/rms) + ! nu_fit: sp (2-element array) + ! Array with [nu_min,nu_max] in Hz, defining ranged used for fittig non-linear parameters + ! + ! filter : dp of size (2, :), optional + ! The noise filter to apply, in the form (x(:), y(:)). Regions + ! outside x(1) -> x(n) will not be filtered. Omit this if you + ! don't want filtering + + implicit none + real(sp), dimension(:), intent(in) :: P_active_mean + real(sp), dimension(:), intent(in) :: P_active_rms + real(sp), dimension(:,:), intent(in) :: P_uni + real(sp), dimension(:,:), intent(in) :: nu_fit + real(dp), optional, dimension(:,:), intent(in) :: filter + class(comm_noise_psd_white), pointer :: constructor_white + + allocate(constructor_white) + + constructor_white%npar = 1 + + call constructor_white%init_common(P_active_mean, P_active_rms, P_uni, nu_fit, filter) + + constructor_white%P_lognorm = [.false.] ! [sigma0] + + end function constructor_white + + function eval_noise_psd_white_full(self, nu) + ! + ! Evaluation routine for basic white noise PSD object + ! + ! Arguments + ! --------- + ! self: derived type (comm_noise_psd) + ! Basic noise PSD object + ! nu: sp (scalar) + ! Frequency (in Hz) at which to evaluate PSD + ! + implicit none + class(comm_noise_psd_white), intent(in) :: self + real(sp), intent(in) :: nu + real(sp) :: eval_noise_psd_white_full + + eval_noise_psd_white_full = self%xi_n(SIGMA0)**2 + + if(self%apply_filter) then + if(nu >= self%modulation_filter%x(1) .and. nu <= self%modulation_filter%x(size(self%modulation_filter%x))) then + eval_noise_psd_white_full = eval_noise_psd_white_full * splint(self%modulation_filter, dble(nu)) + end if + end if + + end function eval_noise_psd_white_full + + function eval_noise_psd_white_corr(self, nu) + ! + ! Evaluation routine for basic white noise PSD object; correlated noise only, so this returns zero + ! + ! Arguments + ! --------- + ! self: derived type (comm_noise_psd) + ! Basic noise PSD object + ! nu: sp (scalar) + ! Frequency (in Hz) at which to evaluate PSD + ! + implicit none + class(comm_noise_psd_white), intent(in) :: self + real(sp), intent(in) :: nu + real(sp) :: eval_noise_psd_white_corr + + eval_noise_psd_white_corr = 0. + + end function eval_noise_psd_white_corr + function constructor_oof(P_active_mean, P_active_rms, P_uni, nu_fit, filter) ! ! Constructor for basic 1/f noise PSD object, where @@ -140,7 +332,7 @@ function constructor_oof(P_active_mean, P_active_rms, P_uni, nu_fit, filter) real(sp), dimension(:,:), intent(in) :: P_uni real(sp), dimension(:,:), intent(in) :: nu_fit real(dp), optional, dimension(:,:), intent(in) :: filter - class(comm_noise_psd), pointer :: constructor_oof + class(comm_noise_psd_oof), pointer :: constructor_oof allocate(constructor_oof) @@ -155,50 +347,9 @@ function constructor_oof(P_active_mean, P_active_rms, P_uni, nu_fit, filter) constructor_oof%P_lognorm = [.false., .true., .false.] ! [sigma0, fknee, alpha] - end function constructor_oof - - subroutine init_common(self, P_active_mean, P_active_rms, P_uni, nu_fit, filter) - ! Contains common initialization for all classes of noise model - ! - ! Arguments: - ! - ! self : comm_tod_noise_psd_mod - ! The noise model object to initialize - implicit none - class(comm_noise_psd), target, intent(inout) :: self - real(sp), dimension(:), intent(in) :: P_active_mean - real(sp), dimension(:), intent(in) :: P_active_rms - real(sp), dimension(:,:), intent(in) :: P_uni - real(sp), dimension(:,:), intent(in) :: nu_fit - real(dp), optional, dimension(:,:), intent(in) :: filter - - allocate(self%xi_n(self%npar)) - allocate(self%P_uni(self%npar,2)) - allocate(self%P_active(self%npar,2)) - allocate(self%P_lognorm(self%npar)) - - self%xi_n = P_active_mean - self%P_uni = P_uni - self%P_active(:,1) = P_active_mean - self%P_active(:,2) = P_active_rms - self%nu_fit = nu_fit - - self%sigma0 => self%xi_n(1) - - if(.not. present(filter)) then - self%apply_filter = .false. - else - self%apply_filter = .true. - end if - - if(self%apply_filter) then - call spline(self%modulation_filter, filter(1,:), filter(2,:)) - end if - - - end subroutine + end function constructor_oof - function eval_noise_psd_full(self, nu) + function eval_noise_psd_oof_full(self, nu) ! ! Evaluation routine for basic 1/f noise PSD object ! @@ -210,21 +361,21 @@ function eval_noise_psd_full(self, nu) ! Frequency (in Hz) at which to evaluate PSD ! implicit none - class(comm_noise_psd), intent(in) :: self + class(comm_noise_psd_oof), intent(in) :: self real(sp), intent(in) :: nu - real(sp) :: eval_noise_psd_full + real(sp) :: eval_noise_psd_oof_full - eval_noise_psd_full = self%xi_n(SIGMA0)**2 * (1. + (nu/self%xi_n(FKNEE))**self%xi_n(ALPHA)) + eval_noise_psd_oof_full = self%xi_n(SIGMA0)**2 * (1. + (nu/self%xi_n(FKNEE))**self%xi_n(ALPHA)) if(self%apply_filter) then if(nu >= self%modulation_filter%x(1) .and. nu <= self%modulation_filter%x(size(self%modulation_filter%x))) then - eval_noise_psd_full = eval_noise_psd_full * splint(self%modulation_filter, dble(nu)) + eval_noise_psd_oof_full = eval_noise_psd_oof_full * splint(self%modulation_filter, dble(nu)) end if end if - end function eval_noise_psd_full + end function eval_noise_psd_oof_full - function eval_noise_psd_corr(self, nu) + function eval_noise_psd_oof_corr(self, nu) ! ! Evaluation routine for basic 1/f noise PSD object; correlated noise only ! @@ -236,19 +387,19 @@ function eval_noise_psd_corr(self, nu) ! Frequency (in Hz) at which to evaluate PSD ! implicit none - class(comm_noise_psd), intent(in) :: self + class(comm_noise_psd_oof), intent(in) :: self real(sp), intent(in) :: nu - real(sp) :: eval_noise_psd_corr + real(sp) :: eval_noise_psd_oof_corr - eval_noise_psd_corr = self%xi_n(SIGMA0)**2 * (nu/self%xi_n(FKNEE))**self%xi_n(ALPHA) + eval_noise_psd_oof_corr = self%xi_n(SIGMA0)**2 * (nu/self%xi_n(FKNEE))**self%xi_n(ALPHA) if(self%apply_filter) then if(nu >= self%modulation_filter%x(1) .and. nu <= self%modulation_filter%x(size(self%modulation_filter%x))) then - eval_noise_psd_corr = eval_noise_psd_corr * splint(self%modulation_filter, dble(nu)) + eval_noise_psd_oof_corr = eval_noise_psd_oof_corr * splint(self%modulation_filter, dble(nu)) end if end if - end function eval_noise_psd_corr + end function eval_noise_psd_oof_corr function constructor_2oof(P_active_mean, P_active_rms, P_uni, nu_fit, filter) ! diff --git a/commander3/src/comm_utils.f90 b/commander3/src/comm_utils.f90 index 914355587..384fc8aba 100644 --- a/commander3/src/comm_utils.f90 +++ b/commander3/src/comm_utils.f90 @@ -40,9 +40,17 @@ module comm_utils !include "mpif.h" include 'fftw3.f' + interface compute_running_variance + module procedure compute_running_variance_sp, compute_running_variance_dp + end interface compute_running_variance + + interface median + module procedure median_sp, median_dp + end interface + contains - function median(array) result(res) + function median_dp(array) result(res) implicit none real(dp) :: array(:), res real(dp), dimension(:), allocatable :: tmp @@ -52,7 +60,19 @@ function median(array) result(res) call QuickSort_real(tmp) res = tmp(size(tmp)/2+1) deallocate(tmp) - end function median + end function median_dp + + function median_sp(array) result(res) + implicit none + real(sp) :: array(:), res + real(dp), dimension(:), allocatable :: tmp + + allocate(tmp(size(array))) + tmp = array + call QuickSort_real(tmp) + res = tmp(size(tmp)/2+1) + deallocate(tmp) + end function median_sp function getlun() implicit none @@ -1482,4 +1502,187 @@ FUNCTION is_numeric(string) is_numeric = e == 0 END FUNCTION is_numeric + subroutine compute_running_variance_sp(x, mask, window, variance, var_mean, mean_full) + implicit none + real(sp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(sp), dimension(:), intent(out) :: variance + real(sp), intent(out), optional :: var_mean + logical(lgt), intent(in), optional :: mean_full + + integer(i4b) :: i, j, k, l, n, m + real(sp) :: mu, mu_full + logical(lgt) :: mean_full_ + !integer(i4b), allocatable, dimension(:) :: m + + mean_full_ = .false.; if (present(mean_full)) mean_full_ = mean_full + + n = size(x) + + if (mean_full_) then + mu_full = median(x) +!!$ mu_full = 0. +!!$ m = 0 +!!$ do l = j, k +!!$ if (mask(l) == 1.) then +!!$ mu_full = mu_full + x(l) +!!$ m = m + 1 +!!$ end if +!!$ end do +!!$ if (m > 0) mu_full = mu_full / m + end if + + do i = 1, n + j = max(i-window,1) + k = min(i+window,n) + variance(i) = 0. + mu = 0. + m = 0 + do l = j, k + if (mask(l) == 1.) then + mu = mu + x(l) + m = m + 1 + end if + end do + if (m < 3) then + variance(i) = 0. + else + if (mean_full_) then + mu = mu_full + else + mu = mu / m + end if + do l = j, k + if (mask(l) == 1.) then + variance(i) = variance(i) + (x(l) - mu)**2 + end if + end do + variance(i) = variance(i) / (m-1) + end if + end do + +!!$ allocate(m(n)) +!!$ variance(1) = 0.d0 +!!$ m = 0 +!!$ do j = 1, window +!!$ if (mask(j) == 1.d0) then +!!$ variance(1) = variance(1) + x(j)**2 +!!$ m(1) = m(1) + 1 +!!$ end if +!!$ end do +!!$ +!!$ ! Compute running mean variance +!!$ do i = 2, n +!!$ variance(i) = variance(i-1) +!!$ m(i) = m(i-1) +!!$ k = i-window +!!$ if (k > 0) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) - x(k)**2 +!!$ m(i) = m(i) - 1 +!!$ end if +!!$ end if +!!$ k = i+window +!!$ if (k <= n) then +!!$ if (mask(k) == 1.d0) then +!!$ variance(i) = variance(i) + x(k)**2 +!!$ m(i) = m(i) + 1 +!!$ end if +!!$ end if +!!$ end do +!!$ do i = 1, n +!!$ if (m(i) > 2) then +!!$ variance(i) = variance(i) / (m(i) - 1.d0) +!!$ else +!!$ variance(i) = 0.d0 +!!$ end if +!!$ end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0 .and. variance(i) > 0.) then + var_mean = var_mean + variance(i) + j = j+1 + !write(*,*) i, var_mean, j, var_mean/j + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + !deallocate(m) + + end subroutine compute_running_variance_sp + + + + subroutine compute_running_variance_dp(x, mask, window, variance, var_mean) + implicit none + real(dp), dimension(:), intent(in) :: x, mask + integer(i4b), intent(in) :: window + real(dp), dimension(:), intent(out) :: variance + real(dp), intent(out), optional :: var_mean + + integer(i4b) :: i, j, k, n + integer(i4b), allocatable, dimension(:) :: m + + n = size(x) + + allocate(m(n)) + variance(1) = 0.d0 + m = 0 + do j = 1, window + if (mask(j) == 1.d0) then + variance(1) = variance(1) + x(j)**2 + m(1) = m(1) + 1 + end if + end do + + ! Compute running mean variance + do i = 2, n + variance(i) = variance(i-1) + m(i) = m(i-1) + k = i-window + if (k > 0) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) - x(k)**2 + m(i) = m(i) - 1 + end if + end if + k = i+window + if (k <= n) then + if (mask(k) == 1.d0) then + variance(i) = variance(i) + x(k)**2 + m(i) = m(i) + 1 + end if + end if + end do + do i = 1, n + if (m(i) > 2) then + variance(i) = variance(i) / (m(i) - 1.d0) + else + variance(i) = 0.d0 + end if + end do + + ! Compute average variance if requested + if (present(var_mean)) then + var_mean = 0.d0 + j = 0 + do i = 1, n + if (mask(i) == 1.d0) then + var_mean = var_mean + variance(i) + j = j+1 + end if + end do + if (j > 0) var_mean = var_mean / j + end if + + deallocate(m) + + end subroutine compute_running_variance_dp + + end module comm_utils diff --git a/commander3/src/math_tools.f90 b/commander3/src/math_tools.f90 index 447020605..eb3d54f20 100644 --- a/commander3/src/math_tools.f90 +++ b/commander3/src/math_tools.f90 @@ -35,10 +35,6 @@ module math_tools module procedure convert_fract2sigma_sp, convert_fract2sigma_dp end interface convert_fract2sigma - interface compute_running_variance - module procedure compute_running_variance_sp, compute_running_variance_dp - end interface - contains subroutine invert_matrix_dpc(matrix) @@ -1758,166 +1754,6 @@ function calc_linear_regression(x_arr, y_arr, n_lim) end function calc_linear_regression - subroutine compute_running_variance_sp(x, mask, window, variance, var_mean) - implicit none - real(sp), dimension(:), intent(in) :: x, mask - integer(i4b), intent(in) :: window - real(sp), dimension(:), intent(out) :: variance - real(sp), intent(out), optional :: var_mean - - integer(i4b) :: i, j, k, l, n, m - real(sp) :: mu - !integer(i4b), allocatable, dimension(:) :: m - - n = size(x) - - do i = 1, n - j = max(i-window,1) - k = min(i+window,n) - variance(i) = 0. - mu = 0. - m = 0 - do l = j, k - if (mask(l) == 1.) then - mu = mu + x(l) - m = m + 1 - end if - end do - if (m < 3) then - variance(i) = 0. - else - mu = mu / m - do l = j, k - if (mask(l) == 1.) then - variance(i) = variance(i) + (x(l) - mu)**2 - end if - end do - variance(i) = variance(i) / (m-1) - end if - end do - -!!$ allocate(m(n)) -!!$ variance(1) = 0.d0 -!!$ m = 0 -!!$ do j = 1, window -!!$ if (mask(j) == 1.d0) then -!!$ variance(1) = variance(1) + x(j)**2 -!!$ m(1) = m(1) + 1 -!!$ end if -!!$ end do -!!$ -!!$ ! Compute running mean variance -!!$ do i = 2, n -!!$ variance(i) = variance(i-1) -!!$ m(i) = m(i-1) -!!$ k = i-window -!!$ if (k > 0) then -!!$ if (mask(k) == 1.d0) then -!!$ variance(i) = variance(i) - x(k)**2 -!!$ m(i) = m(i) - 1 -!!$ end if -!!$ end if -!!$ k = i+window -!!$ if (k <= n) then -!!$ if (mask(k) == 1.d0) then -!!$ variance(i) = variance(i) + x(k)**2 -!!$ m(i) = m(i) + 1 -!!$ end if -!!$ end if -!!$ end do -!!$ do i = 1, n -!!$ if (m(i) > 2) then -!!$ variance(i) = variance(i) / (m(i) - 1.d0) -!!$ else -!!$ variance(i) = 0.d0 -!!$ end if -!!$ end do - - ! Compute average variance if requested - if (present(var_mean)) then - var_mean = 0.d0 - j = 0 - do i = 1, n - if (mask(i) == 1.d0 .and. variance(i) > 0.) then - var_mean = var_mean + variance(i) - j = j+1 - !write(*,*) i, var_mean, j, var_mean/j - end if - end do - if (j > 0) var_mean = var_mean / j - end if - - !deallocate(m) - - end subroutine compute_running_variance_sp - - - - subroutine compute_running_variance_dp(x, mask, window, variance, var_mean) - implicit none - real(dp), dimension(:), intent(in) :: x, mask - integer(i4b), intent(in) :: window - real(dp), dimension(:), intent(out) :: variance - real(dp), intent(out), optional :: var_mean - - integer(i4b) :: i, j, k, n - integer(i4b), allocatable, dimension(:) :: m - - n = size(x) - - allocate(m(n)) - variance(1) = 0.d0 - m = 0 - do j = 1, window - if (mask(j) == 1.d0) then - variance(1) = variance(1) + x(j)**2 - m(1) = m(1) + 1 - end if - end do - - ! Compute running mean variance - do i = 2, n - variance(i) = variance(i-1) - m(i) = m(i-1) - k = i-window - if (k > 0) then - if (mask(k) == 1.d0) then - variance(i) = variance(i) - x(k)**2 - m(i) = m(i) - 1 - end if - end if - k = i+window - if (k <= n) then - if (mask(k) == 1.d0) then - variance(i) = variance(i) + x(k)**2 - m(i) = m(i) + 1 - end if - end if - end do - do i = 1, n - if (m(i) > 2) then - variance(i) = variance(i) / (m(i) - 1.d0) - else - variance(i) = 0.d0 - end if - end do - - ! Compute average variance if requested - if (present(var_mean)) then - var_mean = 0.d0 - j = 0 - do i = 1, n - if (mask(i) == 1.d0) then - var_mean = var_mean + variance(i) - j = j+1 - end if - end do - if (j > 0) var_mean = var_mean / j - end if - - deallocate(m) - - end subroutine compute_running_variance_dp end module math_tools From fe7f33a175a47ce0218ed244048e3ddd8ecdba2c Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 5 Mar 2025 20:23:35 +0100 Subject: [PATCH 126/171] Zodi clean-up and generalized phase function; added bp to comm_tod for easier access --- commander3/src/Makefile | 2 +- commander3/src/comm_bp_mod.f90 | 22 ++ commander3/src/comm_cmb_comp_mod.f90 | 2 +- commander3/src/comm_data_mod.f90 | 46 +-- commander3/src/comm_line_comp_mod.f90 | 2 +- commander3/src/comm_param_mod.f90 | 6 + commander3/src/comm_tod_mod.f90 | 4 + commander3/src/comm_zodi_mod.f90 | 397 +++++++++++++++----------- 8 files changed, 269 insertions(+), 212 deletions(-) diff --git a/commander3/src/Makefile b/commander3/src/Makefile index 6c0b74167..4ff9c6c8c 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -250,7 +250,7 @@ comm_tod_lb_mod.o : comm_tod_mod.o comm_tod_driver_mod.o comm_conviqt_ comm_tod_lfi_mod.o : comm_conviqt_mod.o comm_tod_driver_mod.o comm_tod_lfi_smod.o : comm_tod_lfi_mod.o comm_tod_mapmaking_mod.o : comm_tod_mod.o comm_shared_arr_mod.o comm_map_mod.o -comm_tod_mod.o : comm_fft_mod.o comm_huffman_mod.o comm_conviqt_mod.o comm_tod_cray_mod.o comm_tod_orbdipole_mod.o comm_tod_noise_psd_mod.o comm_shared_arr_mod.o comm_utils.o +comm_tod_mod.o : comm_bp_mod.o comm_fft_mod.o comm_huffman_mod.o comm_conviqt_mod.o comm_tod_cray_mod.o comm_tod_orbdipole_mod.o comm_tod_noise_psd_mod.o comm_shared_arr_mod.o comm_utils.o comm_tod_noise_mod.o : comm_tod_mod.o invsamp_mod.o comm_tod_noise_psd_mod.o comm_status_mod.o comm_tod_noise_psd_mod.o : comm_utils.o comm_tod_orbdipole_mod.o : comm_map_mod.o diff --git a/commander3/src/comm_bp_mod.f90 b/commander3/src/comm_bp_mod.f90 index 6aa40285f..c5e13786a 100644 --- a/commander3/src/comm_bp_mod.f90 +++ b/commander3/src/comm_bp_mod.f90 @@ -30,6 +30,7 @@ module comm_bp_mod integer(i4b) :: n, npar real(dp) :: threshold real(dp) :: nu_c, a2t, f2t, a2sz, unit_scale, nu_eff, a2f + real(dp) :: RJ2data real(dp), allocatable, dimension(:) :: nu0, nu, tau0, tau, delta, a2f_arr contains ! Data procedures @@ -213,6 +214,27 @@ function constructor_bp(cpar, id, id_abs, detlabel, subdets) result(c) ! WARNING! Should be replaced with proper integral. See planck2013 HFI spectral response eq. 2 c%nu_eff = sum(c%tau*c%nu)/sum(c%tau) + + ! Initialize conversion from RJ to data units + select case (trim(cpar%ds_unit(id_abs))) + case ('uK_cmb') + c%RJ2data = c%a2t + case ('mK_cmb') + c%RJ2data = c%a2t * 1d-3 + case ('K_cmb') + c%RJ2data = c%a2t * 1d-6 + case ('MJy/sr') + c%RJ2data = c%a2f + case ('y_SZ') + c%RJ2data = c%a2sz + case ('uK_RJ') + c%RJ2data = 1.d0 + case ('K km/s') + write(*,*) 'Conversion from RJ to Kkm/s not implemented yet' + c%RJ2data = 1.d0 + case default + c%RJ2data = 1.d0 + end select end function constructor_bp diff --git a/commander3/src/comm_cmb_comp_mod.f90 b/commander3/src/comm_cmb_comp_mod.f90 index f22eaa11c..5bfeef186 100644 --- a/commander3/src/comm_cmb_comp_mod.f90 +++ b/commander3/src/comm_cmb_comp_mod.f90 @@ -109,7 +109,7 @@ subroutine updateIntF_cmb(self, band) cycle end if end if - f = comp_a2t(self%nu_ref(k)) / data(i)%bp(j)%p%a2t * data(i)%RJ2data(j) + f = comp_a2t(self%nu_ref(k)) / data(i)%bp(j)%p%a2t * data(i)%bp(j)%p%RJ2data !if (.not. associated(self%F_int(k,i,j)%p)) then self%F_int(k,i,j)%p => comm_F_int_0D(self, data(i)%bp(j)%p, k, f_precomp=f) !else diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 7adbb016c..b43361b8c 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -63,7 +63,6 @@ module comm_data_mod type(comm_B_bl_ptr), allocatable, dimension(:) :: B_postproc class(comm_N_ptr), allocatable, dimension(:) :: N_smooth contains - procedure :: RJ2data procedure :: chisq => get_chisq !procedure :: apply_proc_mask end type comm_data_set @@ -187,7 +186,7 @@ subroutine initialize_data_mod(cpar, handle) write(*,*) 'Unrecognized TOD experiment type = ', trim(data(n)%tod_type) stop end if - + if (trim(cpar%ds_tod_type(i)) /= 'none') then data(n)%map0 => comm_map(data(n)%map) !copy the input map that has no added regnoise, for output to HDF data(n)%tod_freq = cpar%ds_tod_freq(i) @@ -281,8 +280,7 @@ subroutine initialize_data_mod(cpar, handle) call update_status(status, "data_N") ! Initialize bandpass structures; 0 is full freq, j is detector - allocate(data(n)%bp(0:data(n)%ndet)) - + allocate(data(n)%bp(0:data(n)%ndet)) do j = 1, data(n)%ndet if (j==1) then data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=trim(data(n)%tod%label(j))) @@ -314,6 +312,15 @@ subroutine initialize_data_mod(cpar, handle) else data(n)%bp(0)%p => comm_bp(cpar, n, i, subdets=cpar%ds_tod_dets(i)) end if + ! Set up bp pointers in the TOD object + if (cpar%enable_TOD_analysis) then + allocate(data(n)%tod%bp(0:data(n)%ndet)) + do j = 0, data(n)%ndet + data(n)%tod%bp(j)%p => data(n)%bp(j)%p + end do + end if + + ! Initialize smoothed data structures allocate(data(n)%B_smooth(cpar%num_smooth_scales)) allocate(data(n)%B_postproc(cpar%num_smooth_scales)) @@ -392,37 +399,6 @@ function get_chisq(self) end function get_chisq - function RJ2data(self, det) - implicit none - - class(comm_data_set), intent(in) :: self - integer(i4b), intent(in), optional :: det - real(dp) :: RJ2data - - integer(i4b) :: d - - d = 0; if (present(det)) d = det - - select case (trim(self%unit)) - case ('uK_cmb') - RJ2data = self%bp(d)%p%a2t - case ('mK_cmb') - RJ2data = self%bp(d)%p%a2t * 1d-3 - case ('K_cmb') - RJ2data = self%bp(d)%p%a2t * 1d-6 - case ('MJy/sr') - RJ2data = self%bp(d)%p%a2f - case ('y_SZ') - RJ2data = self%bp(d)%p%a2sz - case ('uK_RJ') - RJ2data = 1.d0 - case ('K km/s') - RJ2data = 1.d0 - case default - RJ2data = 1.d0 - end select - - end function RJ2data subroutine dump_unit_conversion(dir) implicit none diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index dbf25b1ca..f2e9bb6f0 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -151,7 +151,7 @@ function constructor_line(cpar, id, id_abs) result(c) do k = 0, data(i)%ndet ! write(*,*) 'line disabled' c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & - & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) + & c%line2RJ(j) / c%line2RJ_ref * data(i)%bp(k)%p%RJ2data, j) end do j = j+1 else diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index bb5e05bd9..4f37d7d2c 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -282,6 +282,8 @@ module comm_param_mod ! Zodi parameters integer(i4b) :: zs_ncomps, zs_num_samp_groups, zs_covar_first, zs_covar_last + character(len=24) :: zs_phasefunc, zs_bandpass + real(dp) :: zs_nu_min_scatter, zs_nu_max_thermal integer(i4b), dimension(:) :: zs_los_steps(MAXZODICOMPS) real(dp), allocatable, dimension(:, :) :: zs_phase_coeff ! (n_band, 3) real(dp), allocatable, dimension(:) :: zs_nu_ref, zs_solar_irradiance ! (n_band) @@ -2996,6 +2998,10 @@ subroutine read_zodi_params_hash(htbl, cpar) call get_parameter_hashtable(htbl, 'NUM_ZODI_COMPS', par_int=cpar%zs_ncomps) call get_parameter_from_hash(htbl, 'ZODI_DELTA_T_RESET', par_dp=cpar%zs_delta_t_reset) + call get_parameter_from_hash(htbl, 'ZODI_PHASE_FUNCTION_TYPE', par_string=cpar%zs_phasefunc) + call get_parameter_from_hash(htbl, 'ZODI_BANDPASS_TYPE', par_string=cpar%zs_bandpass) + call get_parameter_from_hash(htbl, 'ZODI_NU_MIN_SCATTERING', par_dp=cpar%zs_nu_min_scatter) + call get_parameter_from_hash(htbl, 'ZODI_NU_MAX_THERMAL', par_dp=cpar%zs_nu_max_thermal) call get_parameter_from_hash(htbl, 'ZODI_OUTPUT_COMP_MAPS', par_lgt=cpar%zs_output_comps) call get_parameter_from_hash(htbl, 'ZODI_JOINT_MONOPOLE_SAMPLING', par_lgt=cpar%zs_joint_mono) call get_parameter_from_hash(htbl, 'ZODI_OUTPUT_TOD_RESIDUALS', par_lgt=cpar%zs_output_tod_res) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 3267ea159..2f1e47cb6 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -27,6 +27,7 @@ module comm_tod_mod use comm_tod_noise_psd_mod use comm_shared_arr_mod use comm_utils + use comm_bp_mod USE ISO_C_BINDING implicit none @@ -251,6 +252,9 @@ module comm_tod_mod real(dp) :: gain_alpha_std ! std for metropolis-hastings sampling integer(i4b), allocatable, dimension(:) :: split + ! Bandpass, pointer to comm_data%bp + class(comm_bp_ptr), allocatable, dimension(:) :: bp + ! Zodi parameters and spline objects integer(i4b) :: zodi_n_comps ! real(sp), allocatable, dimension(:, :, :) :: zodi_scat_cache, zodi_therm_cache ! Cached s_zodi array for a given processor diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 7199289ca..3516293af 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -19,14 +19,14 @@ module comm_zodi_mod type :: ZodiModel class(ZodiComponentContainer), allocatable :: comps(:) character(len=24), allocatable :: comp_labels(:), general_labels(:), par_labels(:), par_labels_full(:) - integer(i4b) :: n_comps, n_params, n_common_params, n_general_params + character(len=24) :: phasefunc_type, bandpass_type + integer(i4b) :: n_comps, n_params, n_common_params, n_general_params, n_phase, numband logical(lgt) :: joint_mono real(dp) :: min_solar_elong, max_solar_elong + real(dp) :: nu_min_scatter, nu_max_thermal real(dp) :: T_0, delta real(dp), dimension(10) :: F_sun = [2.3405606d8, 1.2309874d8, 64292872d0, 35733824d0, 5763843d0, 1327989.4d0, 230553.73d0, 82999.336d0, 42346.605d0, 14409.608d0] * 1d-20 ! convert to specific intensity units - real(dp), dimension(10) :: C0 = [-0.94209999, -0.52670002, -0.4312, -0.4312, 0., 0., 0., 0., 0., 0.] - real(dp), dimension(10) :: C1 = [0.1214, 0.18719999, 0.1715, 0.1715, 0., 0., 0., 0., 0., 0.] - real(dp), dimension(10) :: C2 = [-0.1648, -0.59829998, -0.63330001, -0.63330001, 0., 0., 0., 0., 0., 0.] + real(dp), allocatable, dimension(:) :: par_phase integer(i4b) :: npar_tot integer(i4b), allocatable, dimension(:,:) :: theta_stat @@ -39,7 +39,7 @@ module comm_zodi_mod ! real(dp), allocatable, dimension(:) :: amp_static ! real(dp), allocatable, dimension(:,:) :: map_static contains - procedure :: init_comps, init_general_params, model_to_chain, params_to_model2, model_to_params2, comp_from_chain, get_par_ind, init_general_priors_and_scales + procedure :: init_comps, init_general_params, model_to_chain, params_to_model2, model_to_params2, comp_from_chain, get_par_ind, init_general_priors_and_scales, get_phase_function end type ZodiModel type(ZodiModel), target :: zodi_model @@ -56,12 +56,17 @@ module comm_zodi_mod real(dp), allocatable :: T_grid(:), B_nu_integrals(:) type(ZodiCompLOS), allocatable, dimension(:) :: comp_LOS type(spline_type) :: earth_pos_spl_obj(3) + + real(dp), dimension(10) :: C0_K98 = [-0.94209999, -0.52670002, -0.4312, -0.4312, 0., 0., 0., 0., 0., 0.] + real(dp), dimension(10) :: C1_K98 = [0.1214, 0.18719999, 0.1715, 0.1715, 0., 0., 0., 0., 0., 0.] + real(dp), dimension(10) :: C2_K98 = [-0.1648, -0.59829998, -0.63330001, -0.63330001, 0., 0., 0., 0., 0., 0.] + contains subroutine initialize_zodi_mod(cpar) implicit none type(comm_params), intent(in) :: cpar - integer(i4b) :: i, j, k, ierr, ind, npar, ntok, gauss_degree + integer(i4b) :: i, j, k, ierr, ind, npar, ntok, gauss_degree, band real(dp) :: min_temp = 40.0, max_temp = 550.0 integer(i4b) :: n_interp_points = 100 character(len=256) :: file_path @@ -71,22 +76,59 @@ subroutine initialize_zodi_mod(cpar) ! Find number of bands and labels - numband = count(cpar%ds_active) - allocate(band_labels(numband),band_instlabels(numband),band_todtype(numband),band_nu_c(numband),band_monopole(numband),band_update_monopole(numband,0:cpar%zs_num_samp_groups)) - band_labels = pack(cpar%ds_label, cpar%ds_active) - band_instlabels = pack(cpar%ds_instlabel, cpar%ds_active) - band_todtype = pack(cpar%ds_tod_type, cpar%ds_active) - band_nu_c = pack(cpar%ds_nu_c, cpar%ds_active) - zodi_refband = cpar%zs_refband + numband = count(cpar%ds_active) + zodi_model%numband = numband + allocate(band_labels(numband),band_instlabels(numband),band_todtype(numband),band_nu_c(numband),band_monopole(numband),band_update_monopole(numband,0:cpar%zs_num_samp_groups)) + band_labels = pack(cpar%ds_label, cpar%ds_active) + band_instlabels = pack(cpar%ds_instlabel, cpar%ds_active) + band_todtype = pack(cpar%ds_tod_type, cpar%ds_active) + band_nu_c = pack(cpar%ds_nu_c, cpar%ds_active) + zodi_refband = cpar%zs_refband - ! Set model and zodi_mod parameters from cpar - zodi_model%n_comps = cpar%zs_ncomps - allocate(comp_params(zodi_model%n_comps, size(cpar%zs_comp_params, dim=1))) - zodi_model%general_labels = cpar%zodi_param_labels%general - zodi_model%comp_labels = cpar%zs_comp_labels(1:zodi_model%n_comps) - zodi_model%n_common_params = size(cpar%zodi_param_labels%common) - zodi_model%n_general_params = size(cpar%zodi_param_labels%general) - zodi_model%joint_mono = cpar%zs_joint_mono + ! Set model and zodi_mod parameters from cpar + zodi_model%nu_min_scatter = cpar%zs_nu_min_scatter * 1d9 + zodi_model%nu_max_thermal = cpar%zs_nu_max_thermal * 1d9 + zodi_model%phasefunc_type = cpar%zs_phasefunc + zodi_model%bandpass_type = cpar%zs_bandpass + zodi_model%n_comps = cpar%zs_ncomps + allocate(comp_params(zodi_model%n_comps, size(cpar%zs_comp_params, dim=1))) + zodi_model%general_labels = cpar%zodi_param_labels%general + zodi_model%comp_labels = cpar%zs_comp_labels(1:zodi_model%n_comps) + zodi_model%n_common_params = size(cpar%zodi_param_labels%common) + zodi_model%n_general_params = size(cpar%zodi_param_labels%general) + zodi_model%joint_mono = cpar%zs_joint_mono + + if (trim(zodi_model%phasefunc_type) == 'K98') then + zodi_model%n_phase = 3*numband + allocate(zodi_model%par_phase(zodi_model%n_phase)) + do i = 1, numband + read(band_instlabels(i),*) band + if (band >= 1 .and. band <= 10) then + zodi_model%par_phase(band+0*numband) = C0_K98(band) + zodi_model%par_phase(band+1*numband) = C1_K98(band) + zodi_model%par_phase(band+2*numband) = C2_K98(band) + else + write(*,*) 'Invalid band label for K98 phase function = ', band_instlabels(i) + end if + end do + else if (trim(zodi_model%phasefunc_type) == 'Wright') then + zodi_model%n_phase = 2 + allocate(zodi_model%par_phase(zodi_model%n_phase)) + zodi_model%par_phase(1) = -0.3133d0 ! p20 + zodi_model%par_phase(2) = 0.5749d0 ! p21 + else if (trim(zodi_model%phasefunc_type) == 'Hong') then + zodi_model%n_phase = 6 + allocate(zodi_model%par_phase(zodi_model%n_phase)) + zodi_model%par_phase(1) = 0.700d0 ! g_1 + zodi_model%par_phase(2) = -0.200d0 ! g_2 + zodi_model%par_phase(3) = -0.810d0 ! g_3 + zodi_model%par_phase(4) = 0.665d0 ! w_1 + zodi_model%par_phase(5) = 0.330d0 ! w_2 + zodi_model%par_phase(6) = 0.005d0 ! w_3 + else + write(*,*) 'Unsupported zodi phase function type:', trim(zodi_model%phasefunc_type) + stop + end if comp_params = cpar%zs_comp_params(:, :, 1) do i = 1, zodi_model%n_comps @@ -1218,7 +1260,7 @@ end subroutine samp_group2stat - subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, model, always_scattering, use_lowres_pointing, comp) + subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, model, use_lowres_pointing, comp) ! Returns the predicted zodiacal emission for a scan (chunk of time-ordered data). ! ! Parameters @@ -1237,8 +1279,6 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod ! Contribution from thermal interplanetary dust emission. ! model : type(ZodiModel) ! The zodiacal emission model. - ! always_scattering : logical(lgt), optional - ! If present, this overrides the default behavior of only including scattering when the albedo is non-zero. ! use_lowres_pointing : logical(lgt), optional ! If present, the input pixels are converted to low resolution pixels before evaluating the zodiacal emission. ! comp : integer(i4b), optional @@ -1255,12 +1295,12 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod integer(i4b), intent(in) :: pix(:), scan, det real(sp), dimension(:, :), intent(inout) :: s_zodi_scat, s_zodi_therm type(ZodiModel), intent(in) :: model - logical(lgt), intent(in), optional :: always_scattering, use_lowres_pointing + logical(lgt), intent(in), optional :: use_lowres_pointing integer(i4b), intent(in), optional :: comp integer(i4b) :: i, j, k, l, pix_at_zodi_nside, lookup_idx, n_tod, ierr, cache_hits - logical(lgt) :: scattering, use_lowres - real(dp) :: earth_lon, R_obs, R_min, R_max, dt_tod, obs_time, phase_normalization, C0, C1, C2, lat, lon + logical(lgt) :: scattering, thermal, use_lowres + real(dp) :: earth_lon, R_obs, R_min, R_max, dt_tod, obs_time, lat, lon real(dp) :: unit_vector(3), obs_pos(3), earth_pos(3) !real(dp), dimension(gauss_degree) :: R_LOS, T_LOS, density_LOS, solar_flux_LOS, scattering_angle, phase_function, b_nu_LOS @@ -1275,21 +1315,9 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod obs_time = tod%scans(scan)%t0(1) earth_lon = atan(earth_pos(2), earth_pos(1)) - C0 = zodi_model%C0(tod%zodiband) - C1 = zodi_model%C1(tod%zodiband) - C2 = zodi_model%C2(tod%zodiband) - phase_normalization = get_phase_normalization(C0, C1, C2) - if (present(always_scattering)) then - scattering = always_scattering - else - scattering = .false. - do i = 1, zodi_model%n_comps - if (zodi_model%comps(i)%c%albedo(tod%id) > EPS) then - scattering = .true. - exit - end if - end do - end if + scattering = tod%central_freq >= model%nu_min_scatter + thermal = tod%central_freq <= model%nu_max_thermal + ! select the correct cache if (present(use_lowres_pointing)) then if (tod%nside == zodi_nside) then @@ -1305,7 +1333,6 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod else use_lowres = .false. end if - !use_lowres = .false. cache_hits = 0 !!$ open(58,file="zodi.dat",recl=1024) @@ -1331,8 +1358,8 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod if (use_lowres) then lookup_idx = tod%pix2ind_lowres(tod%udgrade_pix_zodi(pix(i))) if (tod%zodi_therm_cache_lowres(lookup_idx, 1, det) > 0.d0) then - if (scattering) s_zodi_scat(i, :) = tod%zodi_scat_cache_lowres(lookup_idx, :, det) - s_zodi_therm(i, :) = tod%zodi_therm_cache_lowres(lookup_idx, :, det) + if (scattering) s_zodi_scat(i,:) = tod%zodi_scat_cache_lowres(lookup_idx, :, det) + if (thermal) s_zodi_therm(i,:) = tod%zodi_therm_cache_lowres(lookup_idx, :, det) cache_hits = cache_hits + 1 cycle end if @@ -1342,8 +1369,8 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !write(*,*) 'q1', tod%scanid(scan), lookup_idx !write(*,*) 'q2', tod%scanid(scan), lookup_idx, pix(i), det, tod%zodi_therm_cache(lookup_idx, 1, det) if (tod%zodi_therm_cache(lookup_idx, 1, det) > 0.d0) then - if (scattering) s_zodi_scat(i, :) = tod%zodi_scat_cache(lookup_idx, :, det) - s_zodi_therm(i, :) = tod%zodi_therm_cache(lookup_idx, :, det) + if (scattering) s_zodi_scat(i,:) = tod%zodi_scat_cache(lookup_idx, :, det) + if (thermal) s_zodi_therm(i,:) = tod%zodi_therm_cache(lookup_idx, :, det) cache_hits = cache_hits + 1 cycle end if @@ -1381,31 +1408,30 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod if (scattering) then comp_LOS(k)%F_sol = model%F_sun(tod%zodiband)/comp_LOS(k)%R**2 call get_scattering_angle(comp_LOS(k)%X, comp_LOS(k)%X_unit, comp_LOS(k)%R, comp_LOS(k)%Theta) - call get_phase_function(comp_LOS(k)%Theta, C0, C1, C2, phase_normalization, comp_LOS(k)%Phi) + call model%get_phase_function(comp_LOS(k)%Theta, tod%zodiband, comp_LOS(k)%Phi) end if - call get_dust_grain_temperature(comp_LOS(k)%R, comp_LOS(k)%T, model%T_0, model%delta) -!!$ write(*,*) tod%info%myid, k, size(comp_LOS(k)%T), size(tod%zodi_B_nu_spl_obj(det)%x), size(tod%zodi_B_nu_spl_obj(det)%y) -!!$ write(*,*) tod%info%myid, k, comp_LOS(k)%T -!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%x -!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%y -!!$ write(*,*) tod%info%myid, k, tod%zodi_B_nu_spl_obj(det)%y2 + ! Get dust grain temperature, and compute splined blackbody emission + comp_LOS(k)%T = model%T_0 * comp_LOS(k)%R**(-model%delta) call splint_simple_multi(tod%zodi_b_nu_spl_obj(det), comp_LOS(k)%T, comp_LOS(k)%B_nu) + ! Compute predicted signal; store computed signal in cache call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) if (scattering) then s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 if (use_lowres) then tod%zodi_scat_cache_lowres(lookup_idx, k, det) = s_zodi_scat(i, k) else - tod%zodi_scat_cache(lookup_idx, k, det) = s_zodi_scat(i, k) + tod%zodi_scat_cache(lookup_idx, k, det) = s_zodi_scat(i, k) end if end if - s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 - if (use_lowres) then - tod%zodi_therm_cache_lowres(lookup_idx, k, det) = s_zodi_therm(i, k) - else - tod%zodi_therm_cache(lookup_idx, k, det) = s_zodi_therm(i, k) + if (thermal) then + s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 + if (use_lowres) then + tod%zodi_therm_cache_lowres(lookup_idx, k, det) = s_zodi_therm(i, k) + else + tod%zodi_therm_cache(lookup_idx, k, det) = s_zodi_therm(i, k) + end if end if end do !!$ call vec2ang(unit_vector, lat, lon) @@ -1426,105 +1452,120 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !!$ write(*,*) "s", comp_LOS(1)%B_nu*0.958 end do -!!$ close(58) -!!$ call mpi_finalize(i) -!!$ stop - end subroutine get_zodi_emission ! Functions for evaluating the zodiacal emission ! ----------------------------------------------------------------------------------- + ! Computes R_max (the length of the LOS such that it stops exactly at los_cutoff_radius). subroutine get_sphere_intersection(unit_vector, obs_pos, R_obs, R_cutoff, R_intersection) - ! Computes R_max (the length of the LOS such that it stops exactly at los_cutoff_radius). - - real(dp), intent(in), dimension(:) :: unit_vector, obs_pos - real(dp), intent(in) :: R_obs, R_cutoff - real(dp), intent(out) :: R_intersection - real(dp) :: lon, lat, cos_lat, b, d, q - - if (R_obs > R_cutoff) then - R_intersection = EPS - return - end if - - lon = atan(unit_vector(2), unit_vector(1)) - lat = asin(unit_vector(3)) - cos_lat = cos(lat) - b = 2.*(obs_pos(1)*cos_lat*cos(lon) + obs_pos(2)*cos_lat*sin(lon)) - d = R_obs**2 - R_cutoff**2 - q = -0.5*b*(1.+sqrt(b**2 - (4.*d))/abs(b)) - R_intersection = max(q, d/q) + implicit none + real(dp), intent(in), dimension(:) :: unit_vector, obs_pos + real(dp), intent(in) :: R_obs, R_cutoff + real(dp), intent(out) :: R_intersection + + real(dp) :: lon, lat, cos_lat, b, d, q + + if (R_obs > R_cutoff) then + R_intersection = EPS + return + end if + + lon = atan(unit_vector(2), unit_vector(1)) + lat = asin(unit_vector(3)) + cos_lat = cos(lat) + b = 2.d0*(obs_pos(1)*cos_lat*cos(lon) + obs_pos(2)*cos_lat*sin(lon)) + d = R_obs**2 - R_cutoff**2 + q = -0.5d0*b*(1.d0+sqrt(b**2 - (4.d0*d))/abs(b)) + R_intersection = max(q, d/q) end subroutine get_sphere_intersection - subroutine get_dust_grain_temperature(R, T_out, T_0, delta) - real(dp), dimension(:), intent(in) :: R - real(dp), dimension(:), intent(out) :: T_out - real(dp), intent(in) :: T_0, delta - T_out = T_0*R**(-delta) - end subroutine get_dust_grain_temperature - subroutine get_blackbody_emission(nus, T, b_nu) - real(dp), intent(in) :: nus(:), T - real(dp), dimension(:), intent(out) :: b_nu - integer(i4b) :: i - real(dp) :: x - do i = 1, size(nus) - x = h*nus(i)/(k_B*T) - if (x < 0.001d0) then - ! Use RJ approximation - b_nu(i) = 2.d0*nus(i)**2*k_B*T/c**2 - else if (x > 50.d0) then - ! Use Wien approximation - b_nu(i) = 2.d0*h*nus(i)**3/c**2 * exp(-x) - else - ! Use exact expression - b_nu(i) = 2.d0*h*nus(i)**3/c**2 / (exp(x) - 1.d0) - end if - end do - !b_nu = b_nu * 1d20 ! Convert from W/(m^2*sr*Hz) to MJy/sr + implicit none + real(dp), intent(in) :: nus(:), T + real(dp), dimension(:), intent(out) :: b_nu + + integer(i4b) :: i + real(dp) :: x + do i = 1, size(nus) + x = h*nus(i)/(k_B*T) + if (x < 0.001d0) then + ! Use RJ approximation + b_nu(i) = 2.d0*nus(i)**2*k_B*T/c**2 + else if (x > 50.d0) then + ! Use Wien approximation + b_nu(i) = 2.d0*h*nus(i)**3/c**2 * exp(-x) + else + ! Use exact expression + b_nu(i) = 2.d0*h*nus(i)**3/c**2 / (exp(x) - 1.d0) + end if + end do + !b_nu = b_nu * 1d20 ! Convert from W/(m^2*sr*Hz) to MJy/sr end subroutine get_blackbody_emission subroutine get_scattering_angle(X_helio_vec_LOS, X_vec_LOS, R_helio_LOS, scattering_angle) - real(dp), intent(in) :: X_helio_vec_LOS(:, :), X_vec_LOS(:, :), R_helio_LOS(:) - real(dp), dimension(:), intent(out) :: scattering_angle - real(dp), allocatable, dimension(:) :: cos_theta, R_LOS - - allocate(cos_theta(size(X_vec_LOS, dim=1))) - allocate(R_LOS(size(X_vec_LOS, dim=1))) - - R_LOS = norm2(X_vec_LOS, dim=1) - if (any(abs(R_LOS*R_helio_LOS) < 1e-6)) then - write(*,*) 'Error in get_scattering_angle' - write(*,*) 'X_vec_LOS = ', X_vec_LOS - write(*,*) 'R_LOS = ', R_LOS - write(*,*) 'helio = ', R_helio_LOS - end if - cos_theta = sum(X_helio_vec_LOS*X_vec_LOS, dim=1)/(R_LOS*R_helio_LOS) - ! clip cos(theta) to [-1, 1] - where (cos_theta > 1) - cos_theta = 1 - elsewhere(cos_theta < -1) - cos_theta = -1 - end where - scattering_angle = acos(-cos_theta) + implicit none + real(dp), intent(in) :: X_helio_vec_LOS(:, :), X_vec_LOS(:, :), R_helio_LOS(:) + real(dp), dimension(:), intent(out) :: scattering_angle + + real(dp), allocatable, dimension(:) :: cos_theta, R_LOS + + allocate(cos_theta(size(X_vec_LOS, dim=1))) + allocate(R_LOS(size(X_vec_LOS, dim=1))) + + R_LOS = norm2(X_vec_LOS, dim=1) + if (any(abs(R_LOS*R_helio_LOS) < 1e-6)) then + write(*,*) 'Error in get_scattering_angle' + write(*,*) 'X_vec_LOS = ', X_vec_LOS + write(*,*) 'R_LOS = ', R_LOS + write(*,*) 'helio = ', R_helio_LOS + end if + cos_theta = sum(X_helio_vec_LOS*X_vec_LOS, dim=1)/(R_LOS*R_helio_LOS) + ! clip cos(theta) to [-1, 1] + where (cos_theta > 1.d0) + scattering_angle = 0.d0 + elsewhere(cos_theta < -1.d0) + scattering_angle = pi + elsewhere + scattering_angle = acos(-cos_theta) + end where + deallocate(cos_theta, R_LOS) end subroutine get_scattering_angle - subroutine get_phase_function(Theta, C0 , C1 , C2, N, phase_function) - real(dp), intent(in) :: Theta(:), C0, C1, C2, N - real(dp), intent(out) :: phase_function(:) - phase_function = N * (C0 + (C1 * Theta) + exp(C2 * Theta)) - end subroutine + subroutine get_phase_function(self, Theta, band, Phi) + implicit none + class(ZodiModel), intent(in) :: self + real(dp), intent(in) :: Theta(:) + integer(i4b), intent(in) :: band + real(dp), intent(out) :: Phi(:) - function get_phase_normalization(C0, C1, C2) result(N) - real(dp), intent(in) :: C0, C1, C2 - real(dp) :: term1, term2, term3, term4, N + real(dp) :: C0, C1, C2, p20, p21, g, w, norm + integer(i4b) :: n + + if (trim(self%phasefunc_type) == 'K98') then + n = self%numband + C0 = self%par_phase(band+0*n) + C1 = self%par_phase(band+1*n) + C2 = self%par_phase(band+2*n) + norm = 1.d0 / (2.d0*pi * (2.d0*C0 + pi*C1 + (exp(C2 * pi) + 1.d0)/(C2**2 + 1.d0))) + Phi = norm * (C0 + (C1 * Theta) + exp(C2 * Theta)) + else if (trim(self%phasefunc_type) == 'Wright') then + p20 = self%par_phase(1) + p21 = self%par_phase(2) + Phi = exp(-p20*cos(Theta) + p21*cos(Theta)**2) + else if (trim(self%phasefunc_type) == 'Hong') then + g = self%par_phase(1); w = self%par_phase(4) + Phi = w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 + g = self%par_phase(1); w = self%par_phase(4) + Phi = Phi + w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 + g = self%par_phase(1); w = self%par_phase(4) + Phi = Phi + w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 + Phi = Phi / (4.d0*pi) + else + write(*,*) 'Unsupported zodi phase function type:', trim(self%phasefunc_type) + stop + end if - term1 = 2.*pi - term2 = 2.*C0 - term3 = pi*C1 - term4 = (exp(C2 * pi) + 1.)/(C2**2 + 1.) - N = 1. / (term1 * (term2 + term3 + term4)) - end function + end subroutine get_phase_function subroutine initialize_earth_pos_spline(cpar) ! Returns the spline object which is used to evaluate the earth position @@ -1550,31 +1591,31 @@ subroutine initialize_earth_pos_spline(cpar) end subroutine initialize_earth_pos_spline subroutine update_zodi_splines(tod, bandpass, det, model) - ! Updates the spectral spline objects in the TOD object. - ! - ! In the K98 model, several spectral parameters are tabulated at individual frequencies, - ! which we need to evaluate over the bandpass. In a future version, we may want to fit - ! a modified blackbody which would allow us to drop using some of these spline objects. - ! - ! ----------------------------------------------------------------------------------------- - ! | The difficulty with this functino is that it needs the access to the bandpass, so is is | - ! | very limited in where it can be excecuted in commander. | - ! ----------------------------------------------------------------------------------------- - ! - ! Parameters - ! ---------- - ! tod : class(comm_tod) - ! The TOD object holding the spline objects to update. - ! bandpass : class(comm_bp_ptr) - ! The bandpass object holding the bandpass frequencies, and the SED2F function - ! (bandpass integration). - ! det : integer(i4b) - ! The detector to update the spline objects for. - - class(comm_tod), intent(inout) :: tod - class(comm_bp_ptr), intent(in) :: bandpass - integer(i4b), intent(in) :: det - type(ZodiModel), intent(inout) :: model + implicit none + ! Updates the spectral spline objects in the TOD object. + ! + ! In the K98 model, several spectral parameters are tabulated at individual frequencies, + ! which we need to evaluate over the bandpass. In a future version, we may want to fit + ! a modified blackbody which would allow us to drop using some of these spline objects. + ! + ! ----------------------------------------------------------------------------------------- + ! | The difficulty with this functino is that it needs the access to the bandpass, so is is | + ! | very limited in where it can be excecuted in commander. | + ! ----------------------------------------------------------------------------------------- + ! + ! Parameters + ! ---------- + ! tod : class(comm_tod) + ! The TOD object holding the spline objects to update. + ! bandpass : class(comm_bp_ptr) + ! The bandpass object holding the bandpass frequencies, and the SED2F function + ! (bandpass integration). + ! det : integer(i4b) + ! The detector to update the spline objects for. + class(comm_tod), intent(inout) :: tod + class(comm_bp_ptr), intent(in) :: bandpass + integer(i4b), intent(in) :: det + type(ZodiModel), intent(inout) :: model real(dp), allocatable :: b_nu(:) integer(i4b) :: i, j @@ -1582,11 +1623,19 @@ subroutine update_zodi_splines(tod, bandpass, det, model) allocate (b_nu(bandpass%p%n)) do i = 1, size(B_nu_integrals) - call get_blackbody_emission( bandpass%p%nu, T_grid(i), b_nu) - call get_blackbody_emission([bandpass%p%nu_c], T_grid(i), Inu0) ! Center frequency for color correction - K = tsum(bandpass%p%nu, bandpass%p%tau * b_nu/Inu0(1)) / tsum(bandpass%p%nu, bandpass%p%tau * bandpass%p%nu_c/bandpass%p%nu) ! Color correction - B_nu_integrals(i) = K * Inu0(1) - !B_nu_integrals(i) = tsum(bandpass%p%nu, bandpass%p%tau*b_nu) + call get_blackbody_emission( bandpass%p%nu, T_grid(i), b_nu) ! MJy/sr + if (trim(model%bandpass_type) == 'DIRBE') then + call get_blackbody_emission([bandpass%p%nu_c], T_grid(i), Inu0) ! Center frequency for color correction + K = tsum(bandpass%p%nu, bandpass%p%tau * b_nu/Inu0(1)) / tsum(bandpass%p%nu, bandpass%p%tau * bandpass%p%nu_c/bandpass%p%nu) ! Color correction + B_nu_integrals(i) = K * Inu0(1) + else if (trim(model%bandpass_type) == 'Wright') then + B_nu_integrals(i) = tsum(bandpass%p%nu, bandpass%p%tau*b_nu) + else if (trim(model%bandpass_type) == 'default') then + b_nu = 1.d0/(2.d0*bandpass%p%nu**2*k_b/c**2 * 1d14) * b_nu ! uK_RJ + B_nu_integrals(i) = tod%bp(det)%p%SED2F(b_nu) ! Converts to data units + else + write(*,*) 'Update_zodi_splines -- unknown bandpass type = ', trim(model%bandpass_type) + end if end do call spline_simple(tod%zodi_b_nu_spl_obj(det), T_grid, B_nu_integrals, regular=.true.) end subroutine update_zodi_splines From 7b92d8eb1c9f1c8e1364cbd0d9653eb676506e89 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 5 Mar 2025 20:57:17 +0100 Subject: [PATCH 127/171] Started on phase function parameter sampling --- commander3/src/comm_param_mod.f90 | 2 +- commander3/src/comm_zodi_mod.f90 | 132 +++++++++++++++++------------- 2 files changed, 75 insertions(+), 59 deletions(-) diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 4f37d7d2c..3f78afd51 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -41,7 +41,7 @@ module comm_param_mod type(status_file) :: status type InterplanetaryDustParamLabels - character(len=2048), dimension(2) :: general = [character(len=2048) :: "T_0", "T_DELTA"] + character(len=2048), dimension(2) :: general = [character(len=2048) :: "T_0", "T_DELTA", "G1", "G2", "G3", "W1", "W2", "W3"] character(len=2048), dimension(6) :: common = [character(len=2048) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] character(len=2048), dimension(4) :: cloud = [character(len=2048) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] character(len=2048), dimension(4) :: band = [character(len=2048) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 3516293af..b9d52f379 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -20,7 +20,7 @@ module comm_zodi_mod class(ZodiComponentContainer), allocatable :: comps(:) character(len=24), allocatable :: comp_labels(:), general_labels(:), par_labels(:), par_labels_full(:) character(len=24) :: phasefunc_type, bandpass_type - integer(i4b) :: n_comps, n_params, n_common_params, n_general_params, n_phase, numband + integer(i4b) :: n_comps, n_params, n_common_params, n_general_params, n_phase_params, numband logical(lgt) :: joint_mono real(dp) :: min_solar_elong, max_solar_elong real(dp) :: nu_min_scatter, nu_max_thermal @@ -99,8 +99,8 @@ subroutine initialize_zodi_mod(cpar) zodi_model%joint_mono = cpar%zs_joint_mono if (trim(zodi_model%phasefunc_type) == 'K98') then - zodi_model%n_phase = 3*numband - allocate(zodi_model%par_phase(zodi_model%n_phase)) + zodi_model%n_phase_params = 3*numband + allocate(zodi_model%par_phase(zodi_model%n_phase_params)) do i = 1, numband read(band_instlabels(i),*) band if (band >= 1 .and. band <= 10) then @@ -112,13 +112,13 @@ subroutine initialize_zodi_mod(cpar) end if end do else if (trim(zodi_model%phasefunc_type) == 'Wright') then - zodi_model%n_phase = 2 - allocate(zodi_model%par_phase(zodi_model%n_phase)) + zodi_model%n_phase_params = 2 + allocate(zodi_model%par_phase(zodi_model%n_phase_params)) zodi_model%par_phase(1) = -0.3133d0 ! p20 zodi_model%par_phase(2) = 0.5749d0 ! p21 else if (trim(zodi_model%phasefunc_type) == 'Hong') then - zodi_model%n_phase = 6 - allocate(zodi_model%par_phase(zodi_model%n_phase)) + zodi_model%n_phase_params = 6 + allocate(zodi_model%par_phase(zodi_model%n_phase_params)) zodi_model%par_phase(1) = 0.700d0 ! g_1 zodi_model%par_phase(2) = -0.200d0 ! g_2 zodi_model%par_phase(3) = -0.810d0 ! g_3 @@ -130,55 +130,55 @@ subroutine initialize_zodi_mod(cpar) stop end if - comp_params = cpar%zs_comp_params(:, :, 1) - do i = 1, zodi_model%n_comps - if (trim(adjustl(cpar%zs_init_hdf(i))) /= 'none') then - call zodi_model%comp_from_chain(cpar, comp_params, i) - end if - end do - call zodi_model%init_comps(comp_params, cpar%zs_comp_types, cpar%zodi_param_labels) - call zodi_model%init_general_params(cpar%zs_general_params(:, 1)) - - ! Find total number of free parameters, and set up parameter mapping - zodi_model%npar_tot = zodi_model%n_general_params + 2*zodi_model%n_comps*numband + numband - zodi_model%comps(1)%start_ind = zodi_model%n_general_params + 1 - do i = 1, zodi_model%n_comps - zodi_model%npar_tot = zodi_model%npar_tot + zodi_model%comps(i)%npar - if (i < zodi_model%n_comps) then - zodi_model%comps(i+1)%start_ind = zodi_model%comps(i)%start_ind + & - & zodi_model%comps(i)%npar + 2*numband - end if - end do - - ! stat = 0 -> sample freely - ! stat = -1 -> fix to input - ! stat = -2 -> fix to zero - ! stat = -3 -> fix to unity - ! stat > 0 -> set equal to parameter stat - allocate(zodi_model%theta_stat(zodi_model%npar_tot,0:cpar%zs_num_samp_groups)) - allocate(zodi_model%theta2band(zodi_model%npar_tot)) - allocate(zodi_model%theta_prior(4,zodi_model%npar_tot)) ! [min,max,mean,rms] - allocate(zodi_model%theta_scale(zodi_model%npar_tot,2)) - allocate(zodi_model%par_labels(zodi_model%npar_tot)) - allocate(zodi_model%par_labels_full(zodi_model%npar_tot)) + comp_params = cpar%zs_comp_params(:, :, 1) + do i = 1, zodi_model%n_comps + if (trim(adjustl(cpar%zs_init_hdf(i))) /= 'none') then + call zodi_model%comp_from_chain(cpar, comp_params, i) + end if + end do + call zodi_model%init_comps(comp_params, cpar%zs_comp_types, cpar%zodi_param_labels) + call zodi_model%init_general_params(cpar%zs_general_params(:, 1)) + + ! Find total number of free parameters, and set up parameter mapping + zodi_model%npar_tot = zodi_model%n_general_params + 2*zodi_model%n_comps*numband + numband + zodi_model%comps(1)%start_ind = zodi_model%n_general_params + 1 + do i = 1, zodi_model%n_comps + zodi_model%npar_tot = zodi_model%npar_tot + zodi_model%comps(i)%npar + if (i < zodi_model%n_comps) then + zodi_model%comps(i+1)%start_ind = zodi_model%comps(i)%start_ind + & + & zodi_model%comps(i)%npar + 2*numband + end if + end do - ! Set up sampling groups - allocate(zodi_model%sampgroup_active_band(numband,cpar%zs_num_samp_groups)) - zodi_model%sampgroup_active_band = .false. - do i = 1, cpar%zs_num_samp_groups - call get_tokens(cpar%zs_samp_group_bands(i), ',', tokens, ntok) - do j = 1, ntok - k = get_string_index(band_labels, tokens(j)) - zodi_model%sampgroup_active_band(k,i) = .true. - end do - call samp_group2stat(cpar, i, zodi_model%sampgroup_active_band(:,i), zodi_model%theta_stat(:,i)) - end do - do i = 1, zodi_model%npar_tot - zodi_model%theta_stat(i,0) = maxval(zodi_model%theta_stat(i,1:cpar%zs_num_samp_groups)) - end do - do i = 1, numband - band_update_monopole(i,0) = any(band_update_monopole(i,1:cpar%zs_num_samp_groups)) - end do + ! stat = 0 -> sample freely + ! stat = -1 -> fix to input + ! stat = -2 -> fix to zero + ! stat = -3 -> fix to unity + ! stat > 0 -> set equal to parameter stat + allocate(zodi_model%theta_stat(zodi_model%npar_tot,0:cpar%zs_num_samp_groups)) + allocate(zodi_model%theta2band(zodi_model%npar_tot)) + allocate(zodi_model%theta_prior(4,zodi_model%npar_tot)) ! [min,max,mean,rms] + allocate(zodi_model%theta_scale(zodi_model%npar_tot,2)) + allocate(zodi_model%par_labels(zodi_model%npar_tot)) + allocate(zodi_model%par_labels_full(zodi_model%npar_tot)) + + ! Set up sampling groups + allocate(zodi_model%sampgroup_active_band(numband,cpar%zs_num_samp_groups)) + zodi_model%sampgroup_active_band = .false. + do i = 1, cpar%zs_num_samp_groups + call get_tokens(cpar%zs_samp_group_bands(i), ',', tokens, ntok) + do j = 1, ntok + k = get_string_index(band_labels, tokens(j)) + zodi_model%sampgroup_active_band(k,i) = .true. + end do + call samp_group2stat(cpar, i, zodi_model%sampgroup_active_band(:,i), zodi_model%theta_stat(:,i)) + end do + do i = 1, zodi_model%npar_tot + zodi_model%theta_stat(i,0) = maxval(zodi_model%theta_stat(i,1:cpar%zs_num_samp_groups)) + end do + do i = 1, numband + band_update_monopole(i,0) = any(band_update_monopole(i,1:cpar%zs_num_samp_groups)) + end do ! Initialize parameter-band mapping zodi_model%theta2band(1:zodi_model%n_general_params) = 0 ! General parameters affect all bands @@ -298,8 +298,11 @@ end subroutine initialize_zodi_mod subroutine init_general_params(self, general_params) class(ZodiModel), intent(inout) :: self real(dp), intent(in) :: general_params(:) - self%T_0 = general_params(1) + self%T_0 = general_params(1) self%delta = general_params(2) + if (self%phasefunc_type == 'Hong') then + self%par_phase(1:6) = general_params(3:8) + end if end subroutine subroutine init_general_priors_and_scales(self, prior, scale) @@ -311,7 +314,20 @@ subroutine init_general_priors_and_scales(self, prior, scale) prior(:,1) = [250.d0, 300.d0, 286.d0, 5.d0] ! T_0 scale(1,:) = [286.d0, 3.d0] prior(:,2) = [0.4d0, 0.5d0, 0.467d0, 0.004d0] ! delta - scale(2,:) = [0.4d0, 0.01d0] + scale(2,:) = [0.4d0, 0.01d0] + prior(:,3) = [-1d0, 1d0, 0.70d0, 0.1d0] ! g_1 + scale(3,:) = [1d0, 0.01d0] + prior(:,4) = [-1d0, 1d0, -0.20d0, 0.1d0] ! g_2 + scale(4,:) = [1d0, 0.01d0] + prior(:,5) = [-1d0, 1d0, -0.81d0, 0.1d0] ! g_3 + scale(5,:) = [1d0, 0.01d0] + prior(:,6) = [0d0, 1d0, 0.665d0, 0.1d0] ! w_1 + scale(6,:) = [1d0, 0.01d0] + prior(:,7) = [0d0, 1d0, 0.330d0, 0.1d0] ! w_2 + scale(7,:) = [1d0, 0.01d0] + prior(:,8) = [0d0, 1d0, 0.005d0, 0.0001d0] ! w_3 + scale(8,:) = [1d0, 0.0005d0] + end subroutine init_general_priors_and_scales @@ -1001,7 +1017,7 @@ subroutine samp_group2stat(cpar, samp_group, active, stat) label = comp_param(1) call get_tokens(label, '@', comp_param, num=n) if (n == 1) then - ! General parameter + ! General ind = zodi_model%get_par_ind(param=comp_param(1)) stat(ind) = 0 else if (n == 2) then From a0c6cb647c0b49805ec1595c80956cb883d47ab0 Mon Sep 17 00:00:00 2001 From: Angela Bonato Date: Thu, 6 Mar 2025 17:45:10 +0100 Subject: [PATCH 128/171] Fixed default parameter_files --- .../defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults | 12 +++++++++++- .../defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults~ | 12 +++++++++++- .../defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults~ | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults | 10 ++++++++++ .../defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults~ | 10 ++++++++++ 30 files changed, 302 insertions(+), 2 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults index 664201885..d6b9e6294 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults index 8970bce6d..dee36b5f8 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults~ index 1cd1e0b7e..6912efa4b 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults~ @@ -66,3 +66,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01.fits BAND_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults index ee36ae77c..6678189d2 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_02.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults~ index 647063a74..a57352cc5 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults~ @@ -66,3 +66,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_02_n512.fits BAND_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_ZODI_ALBEDO&&& = 0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults index d252bcebd..3632f9e99 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_02_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0,0.25521132892052301d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults index c29b5554a..7aa7069cb 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults @@ -66,3 +66,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_03.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0 BAND_TOD_ZODI_ALBEDO&&& = 0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults index ce82d2424..b607bb842 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults @@ -68,3 +68,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_03_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0 BAND_TOD_ZODI_ALBEDO&&& = 0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults~ index 5ed17eac1..65e27a1ea 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults~ @@ -68,3 +68,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_03.fits BAND_ZODI_EMISSIVITY&&& = 1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0,1.6598924040649741d0 BAND_ZODI_ALBEDO&&& = 0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0,0.21043660481632315d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults index 85612895d..c4b684c10 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_04.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.99740908486652979d0,0.35926451958350442d0,0.35926451958350442d0,0.35926451958350442d0,1.0675116768340536d0,1.0675116768340536d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults index 8738adddf..d45ea71d1 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_04_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.99740908486652979d0,0.35926451958350442d0,0.35926451958350442d0,0.35926451958350442d0,1.0675116768340536d0,1.0675116768340536d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults~ index 80ecd4967..17e1c9819 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults~ @@ -67,3 +67,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_04.fits BAND_ZODI_EMISSIVITY&&& = 0.99740908486652979d0,0.35926451958350442d0,0.35926451958350442d0,0.35926451958350442d0,1.0675116768340536d0,1.0675116768340536d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults index c2d038f97..ed33e4391 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_05.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.95766914805948866d0,1.0127926948497732d0,1.0127926948497732d0,0.35926451958350442d0,1.0608768682182081d0,1.0608768682182081d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults index 8d06a24a6..8e4630d61 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06_n512_v2.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.95766914805948866d0,1.0127926948497732d0,1.0127926948497732d0,0.35926451958350442d0,1.0608768682182081d0,1.0608768682182081d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults~ index ed3947179..eca2ddef6 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults~ @@ -67,3 +67,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_05.fits BAND_ZODI_EMISSIVITY&&& = 0.95766914805948866d0,1.0127926948497732d0,1.0127926948497732d0,0.35926451958350442d0,1.0608768682182081d0,1.0608768682182081d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults index dd5797b3b..3e4ec03ab 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults index abe6d2df6..59d4746de 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06_n512_v2.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .true. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults~ index 9f173d2cb..fd2b75adc 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults~ @@ -66,3 +66,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_06.fits BAND_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults index 9450fdfcf..ae725cd9b 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults @@ -64,4 +64,14 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_07.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.73338832616768868d0,1.2539242027824944d0,1.2539242027824944d0,1.2539242027824944d0,0.87266361378785184d0,0.87266361378785184d0 -BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 \ No newline at end of file +BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults index 6644a2aa9..7d2ab4710 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_07_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.73338832616768868d0,1.2539242027824944d0,1.2539242027824944d0,1.2539242027824944d0,0.87266361378785184d0,0.87266361378785184d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults~ index 7a255c47d..3ec6daf31 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults~ @@ -66,4 +66,14 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be set BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_07.fits BAND_ZODI_EMISSIVITY&&& = 0.73338832616768868d0,1.2539242027824944d0,1.2539242027824944d0,1.2539242027824944d0,0.87266361378785184d0,0.87266361378785184d0 -BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 \ No newline at end of file +BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults index e83dbf867..170814862 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_08.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.64789881802224070d0,1.5167023376593836d0,1.5167023376593836d0,1.5167023376593836d0,1.0985346556794289d0,1.0985346556794289d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults index 84ede897b..a186b343e 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_08_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.64789881802224070d0,1.5167023376593836d0,1.5167023376593836d0,1.5167023376593836d0,1.0985346556794289d0,1.0985346556794289d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults~ index 153eeca6d..62e1bf62a 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults~ @@ -66,3 +66,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_08.fits BAND_ZODI_EMISSIVITY&&& = 0.64789881802224070d0,1.5167023376593836d0,1.5167023376593836d0,1.5167023376593836d0,1.0985346556794289d0,1.0985346556794289d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults index 31edfecee..ad3079295 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_09.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.67694205881047387d0,1.1317240279481993d0,1.1317240279481993d0,1.1317240279481993d0,1.1515825707787077d0,1.1515825707787077d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults index 16e71dac1..5b7891659 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_09_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.67694205881047387d0,1.1317240279481993d0,1.1317240279481993d0,1.1317240279481993d0,1.1515825707787077d0,1.1515825707787077d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults~ index 8056f8c62..ee9b7d0dc 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults~ @@ -67,3 +67,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_09.fits BAND_ZODI_EMISSIVITY&&& = 0.67694205881047387d0,1.1317240279481993d0,1.1317240279481993d0,1.1317240279481993d0,1.1515825707787077d0,1.1515825707787077d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults index 53ec08271..4d3148ea8 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults @@ -65,3 +65,13 @@ BAND_TOD_ZODI_SUBTRACTION&&& = .true. BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_10.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.51912085401950736d0,1.3996145963796358d0,1.3996145963796358d0,1.3996145963796358d0,0.85763800994217443d0,0.85763800994217443d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults index 10e284292..3d5960fca 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults @@ -67,3 +67,13 @@ BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_10_n512.fits BAND_TOD_ZODI_EMISSIVITY&&& = 0.51912085401950736d0,1.3996145963796358d0,1.3996145963796358d0,1.3996145963796358d0,0.85763800994217443d0,0.85763800994217443d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults~ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults~ index 5309cf790..8566dd78e 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults~ +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults~ @@ -68,3 +68,13 @@ BAND_TOD_SUBTRACT_ZODI&&& = .true. # if true, the following parameters must be BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_10.fits BAND_ZODI_EMISSIVITY&&& = 0.51912085401950736d0,1.3996145963796358d0,1.3996145963796358d0,1.3996145963796358d0,0.85763800994217443d0,0.85763800994217443d0 BAND_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file From 4104f7cffff2200021cc809e3b4f4aae6712f5a9 Mon Sep 17 00:00:00 2001 From: Angela Bonato Date: Thu, 6 Mar 2025 17:49:32 +0100 Subject: [PATCH 129/171] Fixed use_moon_point and use_earth_elon --- commander3/src/comm_tod_dirbe_mod.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 880d2d34f..869adf9d8 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -115,8 +115,8 @@ function constructor_dirbe(cpar, id, id_abs, info, tod_type) result(c) c%correct_orb = .false. c%orb_4pi_beam = .false. c%sample_zodi = cpar%sample_zodi .and. c%subtract_zodi ! Sample zodi parameters - c%use_moon_point = .true. - c%use_earth_elon = .true. + c%use_moon_point = cpar%sample_moon_maps + c%use_earth_elon = cpar%sample_earth_maps c%symm_flags = .false. ! c%chisq_threshold = 100000000000.d0 !20.d0 ! 9.d0 c%chisq_threshold = 50000. From 129f234e4284bedf0dead77d3459205676caab94 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Fri, 7 Mar 2025 16:04:56 +0100 Subject: [PATCH 130/171] some bugfixes and new 100 GHz TOD defaults --- .../defaults/bands/HFI/HFI_100_TOD.defaults | 75 +++++++++++++++++++ .../defaults/bands/HFI/HFI_545_TOD.defaults | 3 - .../defaults/bands/LFI/LFI_030_TOD.defaults | 11 +++ commander3/src/comm_data_mod.f90 | 2 +- commander3/src/comm_signal_mod.f90 | 6 +- commander3/src/comm_tod_hfi_smod.f90 | 9 ++- commander3/src/comm_tod_lfi_smod.f90 | 6 +- commander3/src/comm_utils.f90 | 2 +- 8 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults new file mode 100644 index 000000000..040f9a15b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults @@ -0,0 +1,75 @@ +#HFI 100 GHz TOD default parameters + +BAND_LABEL&&& = 100 +BAND_INSTRUMENT_LABEL&&& = HFI +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .true. +BAND_NSIDE&&& = 1024 +BAND_LMAX&&& = 3000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 1 +BAND_MASKFILE&&& = fullsky +BAND_MASKFILE_CALIB&&& = mask_common_dx12_n1024_TQU.fits fullsky +BAND_BEAMTYPE&&& = b_l # {b_l, febecop} +BAND_BEAM_B_L_FILE&&& = Bl_TEB_npipe6v19_100-ds2x100-ds2.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n1024.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift # {powlaw_tilt, additive_shift} +BAND_NOMINAL_FREQ&&& = 100 +BAND_SAMP_BANDPASS&&& = .false. +BAND_BANDPASSFILE&&& = HFI_instrument_v3.h5 +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 0.1 +BAND_GAIN_CALIB_COMP&&& = all cmb +BAND_GAIN_LMIN&&& = -1 +BAND_GAIN_LMAX&&& = -1 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_LEVEL&&& = L1 + +BAND_TOD_TYPE&&& = HFI +BAND_TOD_BP_INIT_PROP&&& = none +BAND_TOD_HALFRING&&& = 0 +BAND_TOD_START_SCANID&&& = 700 # 3 +BAND_TOD_END_SCANID&&& = 18300 #53724 +BAND_TOD_TOT_NUMSCAN&&& = 18338 #53724 +BAND_TOD_FLAG&&& = 0 +BAND_TOD_ABSCAL_COMP&&& = full +BAND_TOD_DETECTOR_LIST&&& = 100-1a,100-1b,100-2a,100-2b,100-3a,100-3b,100-4a,100-4b +BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. +BAND_TOD_INIT_FROM_HDF&&& = default + +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + + +#TODO: make these paths into real defaults in the Oslo legacy archive +BAND_MAPFILE&&& = HFI_SkyMap_100-BPassCorrected-field-IQU_1024_R4.00_full.fits +BAND_NOISEFILE&&& = npipe6v20_100_wcov_1024.fits +BAND_REG_NOISEFILE&&& = npipe6v20_100_wcov_1024.fits +BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_100_wcov_1024.fits +BAND_NOISE_RMS&&&_SMOOTH02 = npipe6v20_100_wcov_1024.fits +BAND_NOISE_RMS&&&_SMOOTH03 = npipe6v20_100_wcov_1024.fits +BAND_BANDPASSFILE&&& = HFI_instrument_v3.h5 + +BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_100_n2048_mask.fits +BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_100_n2048_mask.fits +N_GIBBS_PER_TOD&&& = 1 +BAND_TOD_RIMO&&& = HFI_instrument_v3.h5 +BAND_TOD_FILELIST&&& = filelist_100.txt + diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index 56f8e4ca6..8c66e8231 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -45,9 +45,6 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 545-1,545-2,545-4 BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_INIT_FROM_HDF&&& = default -BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none -BAND_TOD_SOLAR_CENTRIC_MASK&&& = none -BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none BAND_TOD_SOLAR_CENTRIC_MASK&&& = none diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults index 63e89f0dc..13f857037 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults @@ -45,6 +45,17 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 27M,27S,28M,28S BAND_TOD_INIT_FROM_HDF&&& = default +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + + #TODO: make these paths into real defaults in the Oslo legacy archive BAND_MAPFILE&&& = init_tod_map_030_n512_BP8.1_v1.fits BAND_NOISEFILE&&& = init_tod_rms_030_n512_BP8.1_v1.fits diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index c99975c26..ec21347e6 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -287,7 +287,7 @@ subroutine initialize_data_mod(cpar, handle) data(n)%bp(1)%p => comm_bp(cpar, n, i, detlabel=trim(data(n)%tod%label(j))) else ! Check if bandpass already exists in detector list - call read_bandpass(trim(cpar%datadir) // '/' // trim(adjustl(cpar%ds_bpfile(i))), & + call read_bandpass(trim(adjustl(cpar%ds_bpfile(i))), & & trim(data(n)%tod%label(j)), & & data(n)%bp(1)%p%threshold, & & n_dummy, & diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index cce52df71..62cc36fa1 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -105,7 +105,11 @@ subroutine initialize_signal_mod(cpar) case default call report_error("Unknown component type: "//trim(cpar%cs_type(i))) end select - call add_to_complist(c) + if(associated(c)) then + call add_to_complist(c) + else + if(cpar%myid == 0) write(*,*) "Component failed to initialize: "//trim(cpar%cs_type(i)) + end if case ("ptsrc") c => comm_ptsrc_comp(cpar, ncomp, i) call add_to_complist(c) diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index 3deece8e0..d887936e8 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -132,7 +132,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) call c%load_instrument_file(c%nside_beam, nmaps_beam, pol_beam, cpar%comm_chain) ! Allocate sidelobe convolution data structures - !allocate(c%slconv(c%ndet), c%orb_dp) + if(c%correct_sl) allocate(c%slconv(c%ndet), c%orb_dp) allocate(c%orb_dp) !c%orb_dp => comm_orbdipole(c%mbeam) ! HKE: Removed mbeam for now due to crash; should be fixed @@ -377,7 +377,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare intermediate data structures - call binmap%init(self, .true., sample_rel_bandpass) + call binmap%init(self, .true., .false.)!, nplus2=.true.) if (sample_abs_bandpass .or. sample_rel_bandpass) then allocate(chisq_S(self%ndet,size(delta,3))) chisq_S = 0.d0 @@ -494,7 +494,8 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d call synchronize_binmap(binmap, self) if (sample_rel_bandpass) then if (self%nmaps > 1) then - call finalize_binned_map_nplus2(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2, correct_transfer=.true.) + !call finalize_binned_map_nplus2(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2, correct_transfer=.true.) + call finalize_binned_map(self, binmap, rms_out, 1.d0, chisq_S=chisq_S, mask=procmask2) else call finalize_binned_map_unpol(self, binmap, rms_out, 1.d0, chisq_S=chisq_s, mask=procmask2, correct_transfer=.true.) end if @@ -614,7 +615,7 @@ module subroutine sample_hfi_baselines(self, tod, scan, handle, subtract_s_tot) b2 = b2 / tod%scans(scan)%d(i)%N_psd%sigma0**2 tod%scans(scan)%d(i)%baseline2 = b2/A2 + rand_gauss(handle)/sqrt(A2) - write(*,'(a,i8,3f16.3)') "baseline =", tod%scanid(scan), tod%scans(scan)%d(i)%baseline1, tod%scans(scan)%d(i)%baseline2, sgn + !write(*,'(a,i8,3f16.3)') "baseline =", tod%scanid(scan), tod%scans(scan)%d(i)%baseline1, tod%scans(scan)%d(i)%baseline2, sgn end do if (tod%scanid(scan) == 500) close(58) diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index c90100e4b..ce8f91b81 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -531,10 +531,10 @@ module function constructor_lfi(handle, cpar, id, id_abs, info, tod_type) result call update_status(status, "init_noise_filter_from_chain") ! init the noise filter from chain if we are not computing it - if(trim(res%init_from_HDF) == 'default') then - call get_chainfile_and_samp(cpar%init_chain_prefix, chainfile, initsamp) - else if(trim(res%init_from_HDF) == 'none') then + if(trim(res%init_from_HDF) == 'none' .or. cpar%init_chain_prefix == 'none') then chainfile = "" + else if(trim(res%init_from_HDF) == 'default') then + call get_chainfile_and_samp(cpar%init_chain_prefix, chainfile, initsamp) else call get_chainfile_and_samp(res%init_from_HDF, chainfile, initsamp) end if diff --git a/commander3/src/comm_utils.f90 b/commander3/src/comm_utils.f90 index 384fc8aba..3523ea743 100644 --- a/commander3/src/comm_utils.f90 +++ b/commander3/src/comm_utils.f90 @@ -622,7 +622,7 @@ subroutine report_error(message) call mpi_comm_rank(MPI_COMM_WORLD, myid, ierr) - if (myid == 0) write(*,*) trim(message) + write(*,*) trim(message) call mpi_abort(MPI_COMM_WORLD, 1, ierr) From 0cea1361c780d41fc885e352fd8d1e6259a0c965 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 10 Mar 2025 10:15:58 +0100 Subject: [PATCH 131/171] Fixed flagging bug; enabled zodi subtraction in HFI_mod --- .../defaults/bands/HFI/HFI_100_TOD.defaults | 7 +++- .../defaults/bands/HFI/HFI_545-1_TOD.defaults | 6 ++-- commander3/src/comm_tod_hfi_smod.f90 | 35 +++++++++++++------ commander3/src/comm_tod_mod.f90 | 2 +- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults index 040f9a15b..b08a8c6d9 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults @@ -6,7 +6,7 @@ BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 1024 BAND_LMAX&&& = 3000 -BAND_UNIT&&& = uK_cmb +BAND_UNIT&&& = K_cmb BAND_NOISE_FORMAT&&& = rms BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 1 BAND_MASKFILE&&& = fullsky @@ -73,3 +73,8 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_RIMO&&& = HFI_instrument_v3.h5 BAND_TOD_FILELIST&&& = filelist_100.txt +BAND_TOD_ZODI_SUBTRACTION&&& = .false. +BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n2048_TQU.fits +BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 +BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 +BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults index 7c911e804..b0e4526c6 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults @@ -74,8 +74,8 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 BAND_TOD_FILELIST&&& = filelist_545_Artem_full_pointing_DPC.txt #filelist_545_Artem_full.txt -BAND_TOD_ZODI_SUBTRACTION&&& = .false. -BAND_TOD_ZODI_MASK&&& = zodi_proc_mask_01_n512.fits +BAND_TOD_ZODI_SUBTRACTION&&& = .true. +BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n2048_TQU.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 -BAND_TOD_ZODI_ALBEDO&&& = 0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0,0.20411939612669797d0 +BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index d887936e8..289e6b2af 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -95,7 +95,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%nhorn = 1 c%compressed_tod = .true. c%correct_sl = .false. - if(c%freq(1:3) == '545' .or. c%freq(1:3) == '857') then !currently no sidelobe models + if(.true. .or. c%freq(1:3) == '545' .or. c%freq(1:3) == '857') then !currently no sidelobe models c%correct_sl = .false. else c%correct_sl = .true. @@ -104,6 +104,7 @@ module function constructor_hfi(cpar, id, id_abs, info, tod_type) result(c) c%apply_inst_corr = .true. c%orb_4pi_beam = .false. c%symm_flags = .false. + c%sample_zodi = cpar%sample_zodi .and. c%subtract_zodi ! Sample zodi parameters c%chisq_threshold = 1000.d0 !20.d0 ! 9.d0 c%nmaps = info%nmaps c%ndet = num_tokens(cpar%ds_tod_dets(id_abs), "," ) @@ -212,7 +213,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d real(dp) :: t1, t2 integer(i4b) :: i, j, k, l, ierr, ndelta, nside, npix, nmaps - logical(lgt) :: select_data, sample_gain, sample_ncorr, sample_abs_bandpass, sample_rel_bandpass, output_scanlist + logical(lgt) :: select_data, sample_gain, sample_ncorr, sample_abs_bandpass, sample_rel_bandpass, output_scanlist, sample_zodi, output_zodi_comps type(comm_binmap) :: binmap type(comm_scandata) :: sd type(comm_detdata) :: dd @@ -220,7 +221,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d character(len=6) :: samptext, scantext character(len=512) :: prefix, postfix, prefix4D, filename character(len=512), allocatable, dimension(:) :: slist - real(sp), allocatable, dimension(:) :: procmask, procmask2, sigma0 + real(sp), allocatable, dimension(:) :: procmask, procmask2, procmask_zodi, sigma0 real(sp), allocatable, dimension(:,:) :: s_buf real(sp), allocatable, dimension(:,:,:) :: d_calib real(sp), allocatable, dimension(:,:,:,:) :: map_sky, m_gain @@ -232,8 +233,10 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Toggle optional operations sample_rel_bandpass = size(delta,3) > 1 ! Sample relative bandpasses if more than one proposal sky sample_abs_bandpass = .false. ! don't sample absolute bandpasses - sample_gain = .false. + sample_gain = .true. sample_ncorr = iter > 1 !.true. + sample_zodi = self%sample_zodi .and. self%subtract_zodi ! Sample zodi parameters + output_zodi_comps = self%output_zodi_comps .and. self%subtract_zodi ! Output zodi components select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,10) == 0 ! only output scanlist every 10th iteration @@ -247,6 +250,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (self%output_aux_maps > 0 .or. .true.) then if (mod(iter-1,self%output_aux_maps) == 0) self%output_n_maps = 7 end if + if (output_zodi_comps) self%output_n_maps = self%output_n_maps + zodi_model%n_comps call int2string(chain, ctext) call int2string(iter, samptext) @@ -264,6 +268,10 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d allocate(m_buf(0:npix-1,nmaps), procmask(0:npix-1), procmask2(0:npix-1)) call self%procmask%bcast_fullsky_map(m_buf); procmask = m_buf(:,1) call self%procmask2%bcast_fullsky_map(m_buf); procmask2 = m_buf(:,1) + if (self%sample_zodi .and. self%subtract_zodi) then + allocate(procmask_zodi(0:npix-1)) + call self%procmask_zodi%bcast_fullsky_map(m_buf); procmask_zodi = m_buf(:,1) + end if deallocate(m_buf) call map_in(1,1)%p%writeFITS(trim(self%outdir) // "/input_sky_model_"//trim(self%label(1))//".fits") @@ -298,7 +306,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d do i = 1, self%nscan ! Skip scan if no accepted data if (.not. any(self%scans(i)%d%accept)) cycle - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, skip_nonlin=.true., darkdata=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, skip_nonlin=.true., darkdata=.true.) !!$ open(58,file='res.dat', recl=1024) !!$ do j = 1, sd%ntod @@ -397,11 +405,11 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Prepare data if (sample_rel_bandpass) then - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true., init_s_sky_prop=.true.) else - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) end if ! Create dynamic mask @@ -421,11 +429,11 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d ! Update scan data with new flagging if (sample_rel_bandpass) then - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_bp_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true., init_s_bp_prop=.true.) else if (sample_abs_bandpass) then - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true., init_s_sky_prop=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true., init_s_sky_prop=.true.) else - call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, init_s_bp=.true.) + call init_scan_data_singlehorn(sd, self, i, map_sky, m_gain, procmask, procmask2, procmask_zodi, init_s_bp=.true.) end if end if @@ -523,6 +531,11 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (self%output_n_maps > 4) call binmap%outmaps(5)%p%writeFITS(trim(prefix)//'orb'//trim(postfix)) if (self%output_n_maps > 5) call binmap%outmaps(6)%p%writeFITS(trim(prefix)//'sl'//trim(postfix)) if (self%output_n_maps > 6) call binmap%outmaps(7)%p%writeFITS(trim(prefix)//'zodi'//trim(postfix)) + if (self%output_n_maps > 8 .and. self%subtract_zodi .and. output_zodi_comps) then + do i = 1, zodi_model%n_comps + call binmap%outmaps(8+i)%p%writeFITS(trim(prefix)//'zodi_'//trim(zodi_model%comp_labels(i))//trim(postfix)) + end do + endif ! Clean up call binmap%dealloc() diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 5573cfb81..2c2461975 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -3567,7 +3567,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(iand(flag,self%flag0) .ne. 0),sp) / ntod, count(iand(flag,self%flag0) .ne. 0), ntod end if - if (count(iand(flag,self%flag0) .ne. 0) == 0) then + if (count(iand(flag,self%flag0) .eq. 0) == 0) then write(*,fmt='(a,a,i6,i4)') ' Dynamic mask, scan rejected = ', trim(self%freq), self%scanid(scan), det self%scans(scan)%d(det)%accept = .false. end if From 66cfaf94bb68ba1a7cfe3450d2a634698972b0e9 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 10 Mar 2025 10:40:24 +0100 Subject: [PATCH 132/171] Implemented phase function fitting --- .../stars/faint_WISE_DIRBE.defaults | 4 +- commander3/src/comm_param_mod.f90 | 2 +- commander3/src/comm_tod_dirbe_mod.f90 | 2 +- commander3/src/comm_tod_gain_smod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 47 +- commander3/src/comm_zodi_mod.f90 | 629 ++++++++-------- commander3/src/comm_zodi_samp_mod.f90 | 693 +----------------- commander3/src/commander.f90 | 2 - 8 files changed, 350 insertions(+), 1031 deletions(-) diff --git a/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults b/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults index 2e2c4f604..ef47b385d 100644 --- a/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults @@ -7,11 +7,11 @@ COMP_CG_SCALE_T&& = 1.d0 COMP_CG_SCALE_P&& = 1.d0 COMP_CG_SAMPLE_GROUP&& = 0 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 -COMP_NSIDE&& = 512 +COMP_NSIDE&& = 2048 COMP_MONOPOLE_PRIOR&& = none COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1500 -COMP_OUTPUT_FWHM&& = 42 # arcmin +COMP_OUTPUT_FWHM&& = 0 42 # arcmin COMP_UNIT&& = MJy/sr COMP_NU_MIN&& = 10000.d0 # Cut off below Band 6 (25um) COMP_NU_MAX&& = 1d30 diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 3f78afd51..67630f376 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -41,7 +41,7 @@ module comm_param_mod type(status_file) :: status type InterplanetaryDustParamLabels - character(len=2048), dimension(2) :: general = [character(len=2048) :: "T_0", "T_DELTA", "G1", "G2", "G3", "W1", "W2", "W3"] + character(len=2048), dimension(7) :: general = [character(len=2048) :: "T_0", "T_DELTA", "G1", "G2", "G3", "W2", "W3"] character(len=2048), dimension(6) :: common = [character(len=2048) :: 'N_0', 'I', 'OMEGA', 'X_0', 'Y_0', 'Z_0'] character(len=2048), dimension(4) :: cloud = [character(len=2048) :: 'ALPHA', 'BETA', 'GAMMA', 'MU'] character(len=2048), dimension(4) :: band = [character(len=2048) :: 'DELTA_ZETA', 'DELTA_R', 'V', 'P'] diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 880d2d34f..355a36a2f 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -393,7 +393,7 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, do j = 1, sd%ndet if (.not. self%scans(i)%d(j)%accept) cycle call self%create_dynamic_mask(i, j, (sd%tod(:,j)-real(self%scans(i)%d(j)%gain,sp)*sd%s_tot(:,j))/self%scans(i)%d(j)%N_psd%sigma0, & - & [-5.,5.], sd%mask(:,j), sd%flag(:,j), only_solar_mask) + & [-5.,5.], sd%mask(:,j), sd%flag(:,j), only_solar_mask, s_tot=sd%s_tot(:,j)) end do call sd%dealloc if (.not. any(self%scans(i)%d%accept)) cycle diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index cee63e1f5..d90a19322 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -125,7 +125,7 @@ module subroutine calculate_gain_mean_std_per_scan(tod, scan_id, s_invsqrtN, mas ! write(*,*) tod%scanid(scan_id), real(tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(3)%gain_invsigma,sp), real(tod%gain0(0) + tod%gain0(3) + tod%scans(scan_id)%d(3)%dgain/tod%scans(scan_id)%d(3)%gain_invsigma,sp), '# deltagain' !if (.false. .and. trim(tod%freq) == '030' .and. mod(tod%scanid(scan_id),100) == 0) then - if (.false.) then + if (.true.) then call int2string(tod%scanid(scan_id), itext) !write(*,*) 'gain'//itext//' = ', tod%gain0(0) + tod%gain0(1), tod%scans(scan_id)%d(1)%dgain/tod%scans(scan_id)%d(1)%gain_invsigma open(58,file='gain_delta_'//itext//'.dat', recl=1024) diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 2f1e47cb6..6e3a53b98 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -3166,7 +3166,7 @@ subroutine clear_zodi_cache(self, obs_time) end if end subroutine clear_zodi_cache - subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only_solar_mask) + subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only_solar_mask, s_tot) implicit none class(comm_tod), intent(inout) :: self integer(i4b), intent(in) :: scan, det @@ -3175,6 +3175,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only real(sp), dimension(:), intent(inout) :: mask integer(i4b), dimension(:), intent(inout) :: flag logical(lgt), intent(in) :: only_solar_mask + real(sp), dimension(:), intent(in), optional :: s_tot integer(i4b) :: i, j, k, n, pix, ntod, nmax, window, ntot, iter, ncut, b_elon real(dp) :: rms0 @@ -3233,7 +3234,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only if (apply_cut(2)) then allocate(cut(ntod)) ncut = 0 - ! open(58, file='var1.dat') + open(58, file='var1.dat') do iter = 1, 1 ! Compute full-scan, masked rms0 rms0 = 0.d0 @@ -3249,7 +3250,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only do i = 1, ntod cut(i) = (mask(i) == 1. .and. (res(i) < rms_range(1)*rms0 .or. res(i) > rms_range(2)*rms0)) - !if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) + if (mask(i) == 1.) write(58,*) i, res(i), count(cut(i:i) == 1.) end do ! Apply RMS selection criterium @@ -3274,7 +3275,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only ncut = ncut + 1 end if end do - !close(58) + close(58) deallocate(cut) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, rms cut -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3287,9 +3288,9 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only var_window = sqrt(var_window) var0 = sqrt(var0) ncut = 0 - !open(58, file='var2.dat') + open(58, file='var2.dat') do i = 1, ntod - !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 + if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0), threshold*var0 if (mask(i) == 1. .and. var_window(i) > threshold*var0) then do k = max(i-window,1), min(i+window,ntod) !if (mask(k) == 1) then @@ -3302,7 +3303,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end do end if end do - !close(58) + close(58) deallocate(var_window) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3314,9 +3315,9 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only call compute_running_variance(res, mask, window, var_window, var_mean=var0) var_window = sqrt(var_window) ncut = 0 - !open(58, file='var3.dat') + open(58, file='var3.dat') do i = 1, ntod - !if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) if (mask(i) == 1. .and. var_window(i) > threshold*var0) then do k = max(i-window,1), min(i+window,ntod) if (iand(flag(k),self%flag0) .eq. 0) then @@ -3329,7 +3330,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end do end if end do - !close(58) + close(58) deallocate(var_window) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3341,9 +3342,9 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only call compute_running_variance(res, mask, window, var_window, var_mean=var0) var_window = sqrt(var_window) ncut = 0 - ! open(58, file='var3.dat') + open(58, file='var3.dat') do i = 1, ntod - ! if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) + if (mask(i) == 1.) write(58,*) i, res(i), var_window(i), var_window(i)/(threshold*var0) if (mask(i) == 1. .and. var_window(i) > threshold*var0) then do k = max(i-window,1), min(i+window,ntod) if (iand(flag(k),self%flag0) .eq. 0) then @@ -3356,7 +3357,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end do end if end do - ! close(58) + close(58) deallocate(var_window) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3392,9 +3393,9 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only ! Remove consecutive chunks with many flagged samples window = 2000; threshold = 0.30 ncut = 0 - ! open(58, file='var4.dat') + open(58, file='var4.dat') do i = 1, ntod - ! write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 + write(58,*) i, res(i), iand(flag(k),self%flag0) .eq. 0 j = max(i-window,1) k = min(i+window,ntod) if (count(flag(j:k) == huge(flag(1)))/real(k-j+1,sp) > threshold) then @@ -3408,7 +3409,7 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only end do end if end do - ! close(58) + close(58) write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if @@ -3437,11 +3438,15 @@ subroutine create_dynamic_mask(self, scan, det, res, rms_range, mask, flag, only !flag(1:550000) = huge(flag(1)) !flag(575000:) = huge(flag(1)) -!!$ open(58, file='var5.dat') -!!$ do i = 1, ntod -!!$ if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), flag(i) -!!$ end do -!!$ close(58) + open(58, file='var5.dat') + do i = 1, ntod + if (present(s_tot)) then + if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i), s_tot(i) + else + if (iand(flag(i),self%flag0) .eq. 0) write(58,*) i, res(i) + end if + end do + close(58) ! Solar-centric mask if (apply_cut(8)) then diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index b9d52f379..bd9e9e9e0 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -20,7 +20,7 @@ module comm_zodi_mod class(ZodiComponentContainer), allocatable :: comps(:) character(len=24), allocatable :: comp_labels(:), general_labels(:), par_labels(:), par_labels_full(:) character(len=24) :: phasefunc_type, bandpass_type - integer(i4b) :: n_comps, n_params, n_common_params, n_general_params, n_phase_params, numband + integer(i4b) :: n_comps, n_common_params, n_general_params, n_phase_params, numband logical(lgt) :: joint_mono real(dp) :: min_solar_elong, max_solar_elong real(dp) :: nu_min_scatter, nu_max_thermal @@ -39,7 +39,7 @@ module comm_zodi_mod ! real(dp), allocatable, dimension(:) :: amp_static ! real(dp), allocatable, dimension(:,:) :: map_static contains - procedure :: init_comps, init_general_params, model_to_chain, params_to_model2, model_to_params2, comp_from_chain, get_par_ind, init_general_priors_and_scales, get_phase_function + procedure :: init_comps, init_general_params, model_to_chain, params_to_model, model_to_params, comp_from_chain, get_par_ind, init_general_priors_and_scales, get_phase_function end type ZodiModel type(ZodiModel), target :: zodi_model @@ -95,11 +95,11 @@ subroutine initialize_zodi_mod(cpar) zodi_model%general_labels = cpar%zodi_param_labels%general zodi_model%comp_labels = cpar%zs_comp_labels(1:zodi_model%n_comps) zodi_model%n_common_params = size(cpar%zodi_param_labels%common) - zodi_model%n_general_params = size(cpar%zodi_param_labels%general) zodi_model%joint_mono = cpar%zs_joint_mono if (trim(zodi_model%phasefunc_type) == 'K98') then - zodi_model%n_phase_params = 3*numband + zodi_model%n_phase_params = 3*numband + zodi_model%n_general_params = 2 + zodi_model%n_phase_params allocate(zodi_model%par_phase(zodi_model%n_phase_params)) do i = 1, numband read(band_instlabels(i),*) band @@ -112,19 +112,20 @@ subroutine initialize_zodi_mod(cpar) end if end do else if (trim(zodi_model%phasefunc_type) == 'Wright') then - zodi_model%n_phase_params = 2 + zodi_model%n_general_params = 2 + zodi_model%n_general_params = 2 + zodi_model%n_phase_params allocate(zodi_model%par_phase(zodi_model%n_phase_params)) zodi_model%par_phase(1) = -0.3133d0 ! p20 zodi_model%par_phase(2) = 0.5749d0 ! p21 else if (trim(zodi_model%phasefunc_type) == 'Hong') then - zodi_model%n_phase_params = 6 + zodi_model%n_general_params = size(cpar%zodi_param_labels%general) + zodi_model%n_phase_params = 5 allocate(zodi_model%par_phase(zodi_model%n_phase_params)) zodi_model%par_phase(1) = 0.700d0 ! g_1 zodi_model%par_phase(2) = -0.200d0 ! g_2 zodi_model%par_phase(3) = -0.810d0 ! g_3 - zodi_model%par_phase(4) = 0.665d0 ! w_1 - zodi_model%par_phase(5) = 0.330d0 ! w_2 - zodi_model%par_phase(6) = 0.005d0 ! w_3 + zodi_model%par_phase(4) = 0.330d0 ! w_2 + zodi_model%par_phase(5) = 0.005d0 ! w_3 else write(*,*) 'Unsupported zodi phase function type:', trim(zodi_model%phasefunc_type) stop @@ -195,10 +196,20 @@ subroutine initialize_zodi_mod(cpar) ! Initialize priors and scale factors call zodi_model%init_general_priors_and_scales(zodi_model%theta_prior, & & zodi_model%theta_scale) - zodi_model%par_labels(1:zodi_model%n_general_params) = & - & zodi_model%general_labels - zodi_model%par_labels_full(1:zodi_model%n_general_params) = & - & zodi_model%par_labels(1:zodi_model%n_general_params) + + if (trim(zodi_model%phasefunc_type) == 'Hong') then + zodi_model%par_labels(1:zodi_model%n_general_params) = & + & zodi_model%general_labels + zodi_model%par_labels_full(1:zodi_model%n_general_params) = & + & zodi_model%par_labels(1:zodi_model%n_general_params) + else + zodi_model%par_labels(1:2) = zodi_model%general_labels(1:2) + zodi_model%par_labels_full(1:2) = zodi_model%par_labels(1:2) + do i = 3, zodi_model%n_general_params + zodi_model%par_labels(i) = 'skip' + zodi_model%par_labels_full(i) = 'skip' + end do + end if do i = 1, zodi_model%n_comps ! Shape parameters ind = zodi_model%comps(i)%start_ind @@ -301,7 +312,7 @@ subroutine init_general_params(self, general_params) self%T_0 = general_params(1) self%delta = general_params(2) if (self%phasefunc_type == 'Hong') then - self%par_phase(1:6) = general_params(3:8) + self%par_phase(1:5) = general_params(3:7) end if end subroutine @@ -321,18 +332,17 @@ subroutine init_general_priors_and_scales(self, prior, scale) scale(4,:) = [1d0, 0.01d0] prior(:,5) = [-1d0, 1d0, -0.81d0, 0.1d0] ! g_3 scale(5,:) = [1d0, 0.01d0] - prior(:,6) = [0d0, 1d0, 0.665d0, 0.1d0] ! w_1 + prior(:,6) = [0d0, 1d0, 0.330d0, 0.1d0] ! w_2 scale(6,:) = [1d0, 0.01d0] - prior(:,7) = [0d0, 1d0, 0.330d0, 0.1d0] ! w_2 - scale(7,:) = [1d0, 0.01d0] - prior(:,8) = [0d0, 1d0, 0.005d0, 0.0001d0] ! w_3 - scale(8,:) = [1d0, 0.0005d0] + prior(:,7) = [0d0, 1d0, 0.005d0, 0.0001d0] ! w_3 + scale(7,:) = [1d0, 0.0005d0] end subroutine init_general_priors_and_scales - subroutine init_comps(self, params, comp_types, param_labels) + subroutine init_comps(self, params, comp_types, param_labels) + implicit none ! Initializes the components in the zodi model and computes the number of parameters in the model. class(ZodiModel), target, intent(inout) :: self real(dp), intent(in) :: params(:, :) @@ -340,7 +350,6 @@ subroutine init_comps(self, params, comp_types, param_labels) class(InterplanetaryDustParamLabels), intent(in) :: param_labels integer(i4b) :: i, ierr allocate (self%comps(self%n_comps)) - self%n_params = self%n_general_params ! NOTE: The order of the parameters in the `params` array must match the below order of readin do i = 1, self%n_comps !self%comps(i)%labels = [param_labels%common] @@ -510,112 +519,70 @@ subroutine init_comps(self, params, comp_types, param_labels) end select self%comps(i)%npar = size(self%comps(i)%labels) call self%comps(i)%c%init() - self%n_params = self%n_params + size(self%comps(i)%labels) ! Initialize emissivity and albedo allocate(self%comps(i)%c%emissivity(numband),self%comps(i)%c%albedo(numband)) self%comps(i)%c%emissivity(numband) = 1.d0 self%comps(i)%c%albedo(numband) = 0.d0 end do - end subroutine + end subroutine init_comps - subroutine model_to_params2(self, x, labels) - ! Dumps a zodi model to a parameter vector `x`. If `labels` is present, it is populated with - ! the corresponding parameter labels. - class(ZodiModel), intent(in) :: self - real(dp), intent(out) :: x(:) - character(len=*), allocatable, optional, intent(inout) :: labels(:) - character(len=128), allocatable :: labels_copy(:), comp_label_upper(:) - integer(i4b) :: i, j, running_idx - - if (size(x) /= self%n_params) stop "Error: argument 'x' has the wrong size. must be `size(zodi_model%n_params)`" - if (present(labels)) then - if (allocated(labels)) stop "`labels` must not be allocated at the time of passing it in to `model_to_params`" - allocate(comp_label_upper(self%n_comps)) - end if + subroutine model_to_params(self, x, samp_group, labels) + implicit none + class(ZodiModel), intent(in) :: self + real(dp), dimension(:), intent(out) :: x + integer(i4b), intent(in), optional :: samp_group + character(len=*), allocatable, optional, intent(inout) :: labels(:) + + integer(i4b) :: i, j, idx + real(dp), allocatable, dimension(:) :: z + character(len=128), allocatable :: labels_copy(:), comp_label_upper(:) + + allocate(z(self%npar_tot)) + + if (present(labels)) then + if (allocated(labels)) stop "`labels` must not be allocated at the time of passing it in to `model_to_params`" + allocate(comp_label_upper(self%n_comps)) + end if + + ! General parameters + z(1) = self%T_0 + z(2) = self%delta + if (trim(self%phasefunc_type) == 'Hong') then + z(3:7) = self%par_phase(1:5) + end if + if (present(labels)) then + if (trim(self%phasefunc_type) == 'Hong') then + labels = self%general_labels + else + labels = self%general_labels(1:2) + do i = 1, self%n_phase_params + labels = [labels, "SKIP"] + end do + end if + end if + idx = self%n_general_params + + ! Component parameters + do i = 1, self%n_comps + ! Shape parameters + call self%comps(i)%c%model2param(z(idx+1:idx+self%comps(i)%npar)) + idx = idx + self%comps(i)%npar + + ! Emissivity and albedo + do j = 1, numband + if (band_todtype(j) == "none") then + z(idx +j) = 0.d0 + z(idx+numband+j) = 0.d0 + else + z(idx +j) = self%comps(i)%c%emissivity(j) + z(idx+numband+j) = self%comps(i)%c%albedo(j) + end if + end do + idx = idx + 2*numband - running_idx = 0 - do i = 1, self%n_comps - x(running_idx + 1) = self%comps(i)%c%n_0 - x(running_idx + 2) = self%comps(i)%c%incl - x(running_idx + 3) = self%comps(i)%c%Omega - x(running_idx + 4) = self%comps(i)%c%x_0 - x(running_idx + 5) = self%comps(i)%c%y_0 - x(running_idx + 6) = self%comps(i)%c%z_0 - running_idx = running_idx + self%n_common_params - select type (comp => self%comps(i)%c) - class is (ZodiCloud) - x(running_idx + 1) = comp%alpha - x(running_idx + 2) = comp%beta - x(running_idx + 3) = comp%gamma - x(running_idx + 4) = comp%mu - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiBand) - x(running_idx + 1) = comp%delta_zeta - x(running_idx + 2) = comp%delta_r - x(running_idx + 3) = comp%v - x(running_idx + 4) = comp%p - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiRing) - x(running_idx + 1) = comp%R_0 - x(running_idx + 2) = comp%sigma_r - x(running_idx + 3) = comp%sigma_z - x(running_idx + 4) = comp%theta_0 - x(running_idx + 5) = comp%sigma_theta - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiFeature) - x(running_idx + 1) = comp%R_0 - x(running_idx + 2) = comp%sigma_r - x(running_idx + 3) = comp%sigma_z - x(running_idx + 4) = comp%theta_0 - x(running_idx + 5) = comp%sigma_theta - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiInterstellar) - x(running_idx + 1) = comp%R - x(running_idx + 2) = comp%alpha - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiFan) - x(running_idx + 1) = comp%Q - x(running_idx + 2) = comp%P - x(running_idx + 3) = comp%gamma - x(running_idx + 4) = comp%Z_midplane_0 - x(running_idx + 5) = comp%R_outer - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiComet) - x(running_idx + 1) = comp%P - x(running_idx + 2) = comp%Z_midplane_0 - x(running_idx + 3) = comp%R_inner - x(running_idx + 4) = comp%R_outer - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiWrightCloudRing) - x(running_idx + 1) = comp%p1 - x(running_idx + 2) = comp%p3 - x(running_idx + 3) = comp%p4 - x(running_idx + 4) = comp%p5 - x(running_idx + 5) = comp%p6 - x(running_idx + 6) = comp%p7 - x(running_idx + 7) = comp%p8 - x(running_idx + 8) = comp%p9 - x(running_idx + 9) = comp%p10 - x(running_idx + 10) = comp%p13 - x(running_idx + 11) = comp%p14 - x(running_idx + 12) = comp%p15 - x(running_idx + 13) = comp%p16 - x(running_idx + 14) = comp%p17 - x(running_idx + 15) = comp%p18 - x(running_idx + 16) = comp%p19 - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiWrightBand) - x(running_idx + 1) = comp%q1 - x(running_idx + 2) = comp%q5 - x(running_idx + 3) = comp%q6 - x(running_idx + 4) = comp%q7 - x(running_idx + 5) = comp%q8 - x(running_idx + 6) = comp%R_1 - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - end select if (present(labels)) then labels_copy = self%comps(i)%labels comp_label_upper(i) = self%comp_labels(i) @@ -623,114 +590,113 @@ subroutine model_to_params2(self, x, labels) do j = 1, size(labels_copy) labels_copy(j) = trim(adjustl(comp_label_upper(i)))//'_'//trim(adjustl(labels_copy(j))) end do - labels = [labels, labels_copy] + labels = [labels, labels_copy] + ! Add placeholders for emissivity and albedo + do j = 1, numband + labels = [labels, ["skip","skip"]] + end do end if - end do - x(running_idx + 1) = self%T_0 - x(running_idx + 2) = self%delta - if (present(labels)) then - labels = [labels, self%general_labels] - end if - end subroutine model_to_params2 + end do + + ! Monopoles + do i = 1, numband + idx = idx+1 + if (band_todtype(i) /= "none") then + z(idx) = band_monopole(i) !get_monopole_amp(data(i)%label) + !write(*,*) 'get', i, trim(data(i)%label), z(idx) + else + z(idx) = 0.d0 + end if + if (present(labels)) labels = [labels, "skip"] + end do + + if (present(samp_group)) then + x = pack(z, self%theta_stat(:,samp_group)==0) + if (present(labels)) labels = pack(labels, self%theta_stat(:,samp_group)==0) + else + x = z + end if + deallocate(z) + + end subroutine model_to_params + + subroutine params_to_model(self, x, samp_group) + implicit none + class(ZodiModel), intent(inout) :: self + real(dp), dimension(:), intent(in) :: x + integer(i4b), intent(in), optional :: samp_group + + integer(i4b) :: i, j, idx + real(dp), allocatable, dimension(:) :: z, z_prev + + allocate(z(self%npar_tot)) + + ! Initialize full parameter vector + if (present(samp_group)) then + allocate(z_prev(self%npar_tot)) + call self%model_to_params(z_prev) + idx = 1 + do i = 1, self%npar_tot + if (self%theta_stat(i,samp_group) == 0) then + z(i) = x(idx) + idx = idx+1 + else if (self%theta_stat(i,samp_group) == -1) then + z(i) = z_prev(i) + else if (self%theta_stat(i,samp_group) == -2) then + z(i) = 0.d0 + else if (self%theta_stat(i,samp_group) == -3) then + z(i) = 1.d0 + end if + end do + do i = 1, self%npar_tot + if (self%theta_stat(i,samp_group) > 0) then + z(i) = z(self%theta_stat(i,samp_group)) + end if + end do + deallocate(z_prev) + else + z = x + end if + + ! General parameters + self%T_0 = z(1) + self%delta = z(2) + if (trim(self%phasefunc_type) == 'Hong') then + self%par_phase(1:5) = z(3:7) + end if + + ! Component parameters + idx = self%n_general_params + do i = 1, self%n_comps + ! Shape parameters + call self%comps(i)%c%param2model(z(idx+1:idx+self%comps(i)%npar)) + call self%comps(i)%c%init() + + ! Emissivity and albedo + idx = idx + self%comps(i)%npar + do j = 1, numband + if (band_todtype(j) /= "none") then + self%comps(i)%c%emissivity(j) = z(idx+j) + self%comps(i)%c%albedo(j) = z(idx+numband+j) + end if + end do + idx = idx + 2*numband + end do + + ! Monopoles + do i = 1, numband + idx = idx+1 + if (band_todtype(i) /= "none") then + band_monopole(i) = z(idx) + end if + end do + + deallocate(z) + + end subroutine params_to_model - subroutine params_to_model2(self, x) - ! Dumps a zodi model to a parameter vector `x`. - class(ZodiModel), intent(inout) :: self - real(dp), intent(in) :: x(:) - integer(i4b) :: i, running_idx - if (size(x) /= self%n_params) then - write(*,*) "Error: argument 'x' has the wrong size. must be `size(zodi_model%n_params)`", size(x), self%n_params - stop - end if - running_idx = 0 - do i = 1, self%n_comps - self%comps(i)%c%n_0 = x(running_idx + 1) - self%comps(i)%c%incl = mod(x(running_idx + 2), 360.) ! degree prior - self%comps(i)%c%Omega = mod(x(running_idx + 3), 360.) ! degree prior - self%comps(i)%c%x_0 = x(running_idx + 4) - self%comps(i)%c%y_0 = x(running_idx + 5) - self%comps(i)%c%z_0 = x(running_idx + 6) - running_idx = running_idx + self%n_common_params - - ! The order of these operations much match the order tabulated in the labels in `InterplanetaryDustParamLabels` - select type (comp => self%comps(i)%c) - class is (ZodiCloud) - comp%alpha = x(running_idx + 1) - comp%beta = x(running_idx + 2) - comp%gamma = x(running_idx + 3) - comp%mu = x(running_idx + 4) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiBand) - comp%delta_zeta = mod(x(running_idx + 1), 360.) ! degree prior - comp%delta_r = x(running_idx + 2) - comp%v = x(running_idx + 3) - comp%p = x(running_idx + 4) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiRing) - comp%R_0 = x(running_idx + 1) - comp%sigma_r = x(running_idx + 2) - comp%sigma_z = x(running_idx + 3) - comp%theta_0 = mod(x(running_idx + 4), 360.) ! degree prior - comp%sigma_theta = mod(x(running_idx + 5), 360.) ! degree prior - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiFeature) - comp%R_0 = x(running_idx + 1) - comp%sigma_r = x(running_idx + 2) - comp%sigma_z = x(running_idx + 3) - comp%theta_0 = mod(x(running_idx + 4), 360.) ! degree prior - comp%sigma_theta = mod(x(running_idx + 5), 360.) ! degree prior - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiInterstellar) - comp%R = x(running_idx + 1) - comp%alpha = x(running_idx + 2) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiFan) - comp%Q = x(running_idx + 1) - comp%P = x(running_idx + 2) - comp%gamma = x(running_idx + 3) - comp%Z_midplane_0 = x(running_idx + 4) - comp%R_outer = x(running_idx + 5) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiComet) - comp%P = x(running_idx + 1) - comp%Z_midplane_0 = x(running_idx + 2) - comp%R_inner = x(running_idx + 3) - comp%R_outer = x(running_idx + 4) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiWrightCloudRing) - comp%p1 = x(running_idx + 1) - comp%p3 = x(running_idx + 2) - comp%p4 = x(running_idx + 3) - comp%p5 = x(running_idx + 4) - comp%p6 = x(running_idx + 5) - comp%p7 = x(running_idx + 6) - comp%p8 = x(running_idx + 7) - comp%p9 = x(running_idx + 8) - comp%p10 = x(running_idx + 9) - comp%p13 = x(running_idx + 10) - comp%p14 = x(running_idx + 11) - comp%p15 = x(running_idx + 12) - comp%p16 = x(running_idx + 13) - comp%p17 = x(running_idx + 14) - comp%p18 = x(running_idx + 15) - comp%p19 = x(running_idx + 16) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - class is (ZodiWrightBand) - comp%q1 = x(running_idx + 1) - comp%q5 = x(running_idx + 2) - comp%q6 = x(running_idx + 3) - comp%q7 = x(running_idx + 4) - comp%q8 = x(running_idx + 5) - comp%R_1 = x(running_idx + 6) - running_idx = running_idx + size(self%comps(i)%labels) - self%n_common_params - end select - call self%comps(i)%c%init() - end do - self%T_0 = x(running_idx + 1) - self%delta = x(running_idx + 2) - end subroutine params_to_model2 subroutine model_to_chain(self, cpar, iter) ! Dumps the zodi model to the chain file @@ -767,10 +733,16 @@ subroutine model_to_chain(self, cpar, iter) comp_group_path = trim(adjustl(zodi_path))//'/comps' call create_hdf_group(file, trim(adjustl(comp_group_path))) - allocate(params(self%n_params)) - call self%model_to_params2(params, labels) - - param_idx = 0 + allocate(params(self%npar_tot)) + call self%model_to_params(params, labels=labels) + + do i = 1, self%n_general_params + if (trim(labels(i)) == 'skip' .or. trim(labels(i)) == 'SKIP') cycle + param_label = trim(adjustl(general_group_path))//'/'//trim(adjustl(self%general_labels(i))) + call write_hdf(file, trim(adjustl(param_label)), params(i)) + end do + + param_idx = self%n_general_params do i = 1, self%n_comps comp_path = trim(adjustl(comp_group_path))//'/'//trim(adjustl(self%comp_labels(i)))//'/' call create_hdf_group(file, trim(adjustl(comp_path))) @@ -783,11 +755,6 @@ subroutine model_to_chain(self, cpar, iter) call write_hdf(file, trim(adjustl(comp_path))//'/emissivity', self%comps(i)%c%emissivity) call write_hdf(file, trim(adjustl(comp_path))//'/albedo', self%comps(i)%c%albedo) end do - if (param_idx + self%n_general_params /= self%n_params) stop "Error: param_idx + self%n_general_params /= self%n_params" - do i = 1, self%n_general_params - param_label = trim(adjustl(general_group_path))//'/'//trim(adjustl(self%general_labels(i))) - call write_hdf(file, trim(adjustl(param_label)), params(param_idx + i)) - end do ! Static component !path = trim(adjustl(zodi_path))//'/static' @@ -1554,7 +1521,7 @@ subroutine get_phase_function(self, Theta, band, Phi) integer(i4b), intent(in) :: band real(dp), intent(out) :: Phi(:) - real(dp) :: C0, C1, C2, p20, p21, g, w, norm + real(dp) :: C0, C1, C2, p20, p21, g1, g2, g3, w1, w2, w3, norm integer(i4b) :: n if (trim(self%phasefunc_type) == 'K98') then @@ -1569,12 +1536,15 @@ subroutine get_phase_function(self, Theta, band, Phi) p21 = self%par_phase(2) Phi = exp(-p20*cos(Theta) + p21*cos(Theta)**2) else if (trim(self%phasefunc_type) == 'Hong') then - g = self%par_phase(1); w = self%par_phase(4) - Phi = w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 - g = self%par_phase(1); w = self%par_phase(4) - Phi = Phi + w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 - g = self%par_phase(1); w = self%par_phase(4) - Phi = Phi + w * (1d0-g**2)/(1.d0+g**2-2d0*g*cos(Theta))**1.5d0 + g1 = self%par_phase(1) + g2 = self%par_phase(2) + g3 = self%par_phase(3) + w1 = 1.d0-sum(self%par_phase(4:5)) + w2 = self%par_phase(4) + w3 = self%par_phase(5) + Phi = w1 * (1d0-g1**2)/(1.d0+g1**2-2d0*g1*cos(Theta))**1.5d0 + Phi = Phi + w2 * (1d0-g2**2)/(1.d0+g2**2-2d0*g2*cos(Theta))**1.5d0 + Phi = Phi + w3 * (1d0-g3**2)/(1.d0+g3**2-2d0*g3*cos(Theta))**1.5d0 Phi = Phi / (4.d0*pi) else write(*,*) 'Unsupported zodi phase function type:', trim(self%phasefunc_type) @@ -1900,18 +1870,27 @@ subroutine zodi_model_to_ascii(cpar, model, filename, overwrite) end if open(newunit=io, file=trim(adjustl(filename)), action="write") - allocate(params(model%n_params)) - call model%model_to_params2(params, labels=labels) + allocate(params(model%npar_tot)) + call model%model_to_params(params, labels=labels) - allocate(comp_switch_indices(model%n_comps)) + allocate(comp_switch_indices(0:model%n_comps)) + + ! Newline after general parameters + if (trim(model%phasefunc_type) == 'Hong') then + comp_switch_indices(0) = model%n_general_params + else + comp_switch_indices(0) = 2 + end if - running_idx = 0 + ! Newline after each component + running_idx = model%n_general_params do i = 1, model%n_comps running_idx = running_idx + size(model%comps(i)%labels) comp_switch_indices(i) = running_idx end do - do i = 1, model%n_params + do i = 1, model%npar_tot + if (trim(labels(i)) == 'skip' .or. trim(labels(i)) == 'SKIP') cycle if (any(comp_switch_indices == i)) then write(io, fmt='(a, T25, a, ES12.5, a)') trim(adjustl(labels(i))), "= ", params(i), new_line('a') else @@ -1956,87 +1935,93 @@ subroutine zodi_model_to_ascii(cpar, model, filename, overwrite) end subroutine subroutine ascii_to_zodi_model(cpar, model, filename) - ! Reads in and updates the zodi model from an ascii file on the format {COMP}_{PARAM} = {VALUE}. - class(ZodiModel), target, intent(inout) :: model - type(comm_params), intent(in) :: cpar - character(len=*), intent(in) :: filename - type(hash_tbl_sll) :: htbl - - integer(i4b) :: i, j, io, io_status, ierr, n_comps - logical(lgt) :: exists - character(len=512) :: key, val, line - character(len=128), allocatable :: labels(:) - characteR(len=128) :: toks(100) - characteR(len=512) :: concatenated_string - real(dp), allocatable :: params(:) - - allocate(params(model%n_params)) - !if (cpar%myid_chain == cpar%root) then - inquire(file=trim(adjustl(filename)), exist=exists) - if (.not. exists) then - print *, "zodi asciifile: " // trim(adjustl(filename)) // " does not exist" - stop - end if - - call init_hash_tbl_sll(htbl, tbl_len=500) - - open(newunit=io, file=trim(adjustl(filename)), action="read") - io_status = 0 - do while (io_status == 0) - read(io, "(a)", iostat=io_status) line - if (io_status == 0 .and. line /= "") then - j = index(line, "=") - if (j == 0) then - print *, "Error: invalid line in ascii file: ", trim(adjustl(line)) - close(io) - stop - end if - - key = trim(adjustl(line(:j-1))) - val = trim(adjustl(line(j+1:))) - call tolower(key) - call put_hash_tbl_sll(htbl, trim(adjustl(key)), trim(adjustl(val))) - end if - end do - close(io) - - call model%model_to_params2(params, labels) - params = 0. - if (size(labels) /= size(params)) stop "Error: size of labels and params do not match" - do i = 1, size(labels) - call get_parameter_hashtable(htbl, labels(i), par_dp=params(i)) - end do - !end if - - !call mpi_bcast(params, size(params), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - call model%params_to_model2(params) - - do i = 1, numband - if (trim(band_todtype(i)) == 'none') cycle - !if (.not. data(i)%tod%subtract_zodi) cycle - !if (cpar%myid == 0) then - call get_parameter_hashtable(htbl, trim(adjustl("EMISSIVITY_"//trim(adjustl(band_labels(i))))), par_string=concatenated_string) - call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) - if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model emissivity" - do j = 1, n_comps - read(toks(j), *) model%comps(j)%c%emissivity(i) - end do - - call get_parameter_hashtable(htbl, trim(adjustl("ALBEDO_"//trim(adjustl(band_labels(i))))), par_string=concatenated_string) - call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) - if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model albedo" - do j = 1, n_comps - read(toks(j), *) model%comps(j)%c%albedo(i) - end do - -! call get_parameter_hashtable(htbl, trim(adjustl("AMP_STATIC_"//trim(adjustl(band_labels(i))))), par_dp=zodi_model%amp_static(i)) - !end if - !call mpi_bcast(data(i)%tod%zodi_emissivity, size(data(i)%tod%zodi_emissivity), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - !call mpi_bcast(data(i)%tod%zodi_albedo, size(data(i)%tod%zodi_albedo), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - end do - end subroutine - + implicit none + ! Reads in and updates the zodi model from an ascii file on the format {COMP}_{PARAM} = {VALUE}. + class(ZodiModel), target, intent(inout) :: model + type(comm_params), intent(in) :: cpar + character(len=*), intent(in) :: filename + type(hash_tbl_sll) :: htbl + + integer(i4b) :: i, j, io, io_status, ierr, n_comps + logical(lgt) :: exists + character(len=512) :: key, val, line + character(len=128), allocatable :: labels(:) + characteR(len=128) :: toks(100) + characteR(len=512) :: concatenated_string + real(dp), allocatable :: params(:) + + allocate(params(model%npar_tot)) + !if (cpar%myid_chain == cpar%root) then + inquire(file=trim(adjustl(filename)), exist=exists) + if (.not. exists) then + print *, "zodi asciifile: " // trim(adjustl(filename)) // " does not exist" + stop + end if + + call init_hash_tbl_sll(htbl, tbl_len=500) + + open(newunit=io, file=trim(adjustl(filename)), action="read") + io_status = 0 + do while (io_status == 0) + read(io, "(a)", iostat=io_status) line + if (io_status == 0 .and. line /= "") then + j = index(line, "=") + if (j == 0) then + print *, "Error: invalid line in ascii file: ", trim(adjustl(line)) + close(io) + stop + end if + + key = trim(adjustl(line(:j-1))) + val = trim(adjustl(line(j+1:))) + call tolower(key) + call put_hash_tbl_sll(htbl, trim(adjustl(key)), trim(adjustl(val))) + end if + end do + close(io) + + call model%model_to_params(params, labels=labels) + params = 0. + if (size(labels) /= size(params)) then + write(*,*) labels + write(*,*) params + write(*,*) size(labels), size(params) + stop "Error: size of labels and params do not match" + end if + do i = 1, size(labels) + if (trim(labels(i)) == 'skip' .or. trim(labels(i)) == 'SKIP') cycle + call get_parameter_hashtable(htbl, labels(i), par_dp=params(i)) + end do + !end if + !call mpi_bcast(params, size(params), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) + call model%params_to_model(params) + + do i = 1, numband + if (trim(band_todtype(i)) == 'none') cycle + !if (.not. data(i)%tod%subtract_zodi) cycle + !if (cpar%myid == 0) then + call get_parameter_hashtable(htbl, trim(adjustl("EMISSIVITY_"//trim(adjustl(band_labels(i))))), par_string=concatenated_string) + call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) + if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model emissivity" + do j = 1, n_comps + read(toks(j), *) model%comps(j)%c%emissivity(i) + end do + + call get_parameter_hashtable(htbl, trim(adjustl("ALBEDO_"//trim(adjustl(band_labels(i))))), par_string=concatenated_string) + call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) + if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model albedo" + do j = 1, n_comps + read(toks(j), *) model%comps(j)%c%albedo(i) + end do + + ! call get_parameter_hashtable(htbl, trim(adjustl("AMP_STATIC_"//trim(adjustl(band_labels(i))))), par_dp=zodi_model%amp_static(i)) + !end if + !call mpi_bcast(data(i)%tod%zodi_emissivity, size(data(i)%tod%zodi_emissivity), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) + !call mpi_bcast(data(i)%tod%zodi_albedo, size(data(i)%tod%zodi_albedo), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) + end do + end subroutine ascii_to_zodi_model + subroutine print_zodi_model(theta, samp_group) implicit none real(dp), allocatable, intent(in) :: theta(:) diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index f03084098..30c4d6ae5 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -5,7 +5,7 @@ module comm_zodi_samp_mod implicit none private - public initialize_zodi_samp_mod, downsamp_invariant_structs, project_and_downsamp_sky, compute_downsamp_zodi, sample_zodi_group, sample_linear_zodi + public initialize_zodi_samp_mod, downsamp_invariant_structs, project_and_downsamp_sky, compute_downsamp_zodi public minimize_zodi_with_powell, get_chisq_priors, precompute_lowres_zodi_lookups, create_zodi_glitch_mask public apply_zodi_glitch_mask, sample_static_zodi_map!, sample_static_zodi_amps @@ -56,72 +56,6 @@ subroutine initialize_zodi_samp_mod(cpar) stop "Error: cannot sample zodi without the reference band being active." end if end if -!!$ if (trim(adjustl(cpar%zs_sample_method)) == "powell") then -!!$ allocate(powell_albedo(n_samp_bands, zodi_model%n_comps)) -!!$ allocate(powell_emissivity(n_samp_bands, zodi_model%n_comps)) -!!$ end if - - ! crappy way of picking initial stepsizes for the zodi parameters -!!$ allocate (step_sizes_albedo(n_samp_bands, zodi_model%n_comps)) -!!$ allocate (step_sizes_emissivity(n_samp_bands, zodi_model%n_comps)) -!!$ allocate (step_sizes_n0(zodi_model%n_comps)) -!!$ -!!$ do i = 1, zodi_model%n_comps -!!$ step_sizes_n0(i) = 0.01*zodi_model%comps(i)%c%n_0 -!!$ end do -!!$ do i = 1, numband -!!$ if (data(i)%tod_type == 'none') then -!!$ step_sizes_emissivity(i,:) = 0.d0 -!!$ step_sizes_albedo(i, :) = 0.d0 -!!$ else -!!$ step_sizes_emissivity(i,:) = 0.01d0 * data(i)%tod%zodi_emissivity -!!$ step_sizes_albedo(i, :) = 0.01d0 * data(i)%tod%zodi_albedo -!!$ end if -!!$ end do - -!!$ allocate(param_vec(zodi_model%n_params)) -!!$ call zodi_model%model_to_params2(param_vec, labels) - -!!$ allocate (step_sizes_ipd(zodi_model%n_params)) -!!$ step_sizes_ipd = 0.005*param_vec -!!$ -!!$ allocate (prior_vec(zodi_model%n_params, 3)) -!!$ idx_start = 1 -!!$ do i = 1, zodi_model%n_comps -!!$ idx_stop = idx_start + size(zodi_model%comps(i)%labels) - 1 -!!$ prior_vec(idx_start:idx_stop, :) = cpar%zs_comp_params(i, :size(zodi_model%comps(i)%labels), 2:) -!!$ idx_start = idx_stop + 1 -!!$ end do -!!$ do i = 1, zodi_model%n_general_params -!!$ prior_vec(idx_start, :) = cpar%zs_general_params(i, 2:) -!!$ idx_start = idx_start + 1 -!!$ end do -!!$ -!!$ emissivity_prior = [0., 5.] -!!$ albedo_prior = [0., 1.] - - ! validate sampling group parameters -!!$ do group_idx = 1, cpar%zs_num_samp_groups -!!$ ! Get indices of the parameters to sample in the current sampling group -!!$ call parse_samp_group_strings(cpar%zs_samp_groups(group_idx), labels, indices) -!!$ end do - ! do i = 1, size(labels) - ! if (index(trim(adjustl(labels(i))), "X_0") /= 0) then - ! step_sizes_ipd(i) = step_sizes_ipd(i) * 10. - ! else if (index(trim(adjustl(labels(i))), "Y_0") /= 0) then - ! step_sizes_ipd(i) = step_sizes_ipd(i) * 10. - ! else if (index(trim(adjustl(labels(i))), "Z_0") /= 0) then - ! step_sizes_ipd(i) = step_sizes_ipd(i) * 10. - ! end if - ! end do - - ! if (trim(adjustl(cpar%zs_covar_chain)) /= "none") then - ! call read_zodi_covariance(cpar) - ! end if - - ! Set up mapping between parameter vextor and band -!!$ allocate(param2band(zodi_model%n_params)) -!!$ param2band = 0 ! Assume for now that all parameters affect all bands end subroutine initialize_zodi_samp_mod @@ -133,487 +67,6 @@ function get_boxwidth(samprate_lowres, samprate) result(box_width) end function - subroutine sample_linear_zodi(cpar, handle, gibbs_iter, model, verbose) - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: gibbs_iter - type(ZodiModel), intent(inout) :: model - logical(lgt), intent(in), optional :: verbose - - !call compute_downsamp_zodi(cpar, model) - !if (cpar%myid == cpar%root) print *, new_line('A'), "sampling and subtracting monopole" - !call sample_and_subtract_monopole(cpar, handle) - !if (cpar%myid == cpar%root) print *, new_line('A'), "sampling n0" - call sample_n0_emissivity_and_albedo(cpar, handle, gibbs_iter, model) - end subroutine - - subroutine sample_and_subtract_monopole(cpar, handle) - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - - type(hdf_file) :: tod_file - integer(i4b) :: i, j, prop, nprop, ndet, scan, nscan, ierr, n_accepted - integer(i4b), allocatable, dimension(:) :: n_downsamp_tod - real(dp) :: box_width, chisq_scan, chisq_new, chisq_prev, chisq_diff, ln_accept_prob, accept_rate - real(dp), allocatable, dimension(:) :: monopole_prev, monopole_new, monopole_init, monopole_step, eta - logical(lgt) :: is_root, accepted, first_prop - character(len=3) :: itext - character(len=512) :: path - - nprop = 200 - is_root = cpar%myid == cpar%root - allocate(monopole_init(n_samp_bands), monopole_new(n_samp_bands), monopole_prev(n_samp_bands), eta(n_samp_bands), n_downsamp_tod(n_samp_bands)) - n_downsamp_tod = 0 - monopole_init = 0. - monopole_new = 0. - monopole_prev = monopole_new - - n_accepted = 0 - do prop = 0, nprop - first_prop = prop == 0 - if (.not. first_prop .and. is_root) then - eta = [(rand_gauss(handle), i = 1, n_samp_bands)] - monopole_new = monopole_prev + monopole_step * eta - else - monopole_new = monopole_prev - end if - call mpi_bcast(monopole_new, 1, MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - - chisq_scan = 0. - chisq_new = 0. - - ! compute chisq for new model - do i = 1, numband - if ((data(i)%tod_type == "none") .or. (.not. data(i)%tod%sample_zodi)) cycle - ndet = data(i)%tod%ndet - nscan = data(i)%tod%nscan - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) - do scan = 1, nscan - do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - - n_downsamp_tod(i) = n_downsamp_tod(i) + size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) - ! rescale downsampled zodi comp-wise emission with newly proposed n0s - call get_s_zodi(i, & - & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - &) - ! compute monopole step size - if (first_prop) then - ! print *, "tod", maxval(data(i)%tod%scans(scan)%d(j)%downsamp_tod), minval(data(i)%tod%scans(scan)%d(j)%downsamp_tod) - ! print *, "sky", maxval(data(i)%tod%scans(scan)%d(j)%downsamp_sky), minval(data(i)%tod%scans(scan)%d(j)%downsamp_sky) - ! print *, "zodi", maxval(data(i)%tod%scans(scan)%d(j)%downsamp_zodi), minval(data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - ! print *, "pix", maxval(data(i)%tod%scans(scan)%d(j)%downsamp_pix), minval(data(i)%tod%scans(scan)%d(j)%downsamp_pix) - ! stop - monopole_init(i) = monopole_init(i) + sum( & - & (data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi) & - & ) - end if - - chisq_scan = chisq_scan + sum( & - & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - & - monopole_new(i) & - & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & - &) - end do - end do - end do - call mpi_reduce(chisq_scan, chisq_new, 1, MPI_DOUBLE_PRECISION, MPI_SUM, cpar%root, MPI_COMM_WORLD, ierr) - - ! Use chisq from the first iteration where we dont draw new parameters as the base chisq - if (first_prop) then - call mpi_allreduce(MPI_IN_PLACE, monopole_init, size(monopole_init), MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD, ierr) - call mpi_allreduce(MPI_IN_PLACE, n_downsamp_tod, size(n_downsamp_tod), MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr) - monopole_prev = monopole_init/n_downsamp_tod - monopole_step = 0.1*monopole_prev - chisq_prev = chisq_new - else - if (is_root) then - chisq_diff = max(chisq_new - chisq_prev, 0.) - ln_accept_prob = -0.5 * chisq_diff - select case (cpar%operation) - case ("sample") - accepted = ln_accept_prob > log(rand_uni(handle)) - case ("optimize") - accepted = chisq_diff < 0. - case default - stop "Error: invalid cpar%operation in comm_zodi_samp_mod sample_monopole routine" - end select - end if - call mpi_bcast(accepted, 1, MPI_LOGICAL, cpar%root, cpar%comm_chain, ierr) - - if (accepted) then - n_accepted = n_accepted + 1 - chisq_prev = chisq_new - monopole_prev = monopole_new - if (is_root) then - print *, "proposal:", prop - write(*, '(a, ES12.5)') "chisq: ", chisq_new - print *, "monopole: ", monopole_new - print *, " " - end if - else - monopole_new = monopole_prev - end if - accept_rate = real(n_accepted)/real(prop) - end if - end do - - if (is_root) print *, "monopole accept rate: ", (real(n_accepted)/real(nprop))*100. - - do i = 1, numband - if ((data(i)%tod_type == "none") .or. (.not. data(i)%tod%sample_zodi)) cycle - do scan = 1, nscan - do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - data(i)%tod%scans(scan)%d(j)%downsamp_tod = data(i)%tod%scans(scan)%d(j)%downsamp_tod - monopole_prev(i) - end do - end do - end do - end subroutine - - subroutine sample_n0_emissivity_and_albedo(cpar, handle, gibbs_iter, model) - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: gibbs_iter - type(ZodiModel), intent(inout) :: model - - integer(i4b) :: i, j, prop, nprop, ndet, scan, nscan, ierr, n_accepted, comp - real(dp) :: box_width, chisq_scan, chisq_new, chisq_prev, chisq_diff, ln_accept_prob, accept_rate, n0_ratio - real(dp), allocatable :: n0_new(:), n0_prev(:), eta_n0(:), eta_emissivity(:, :), eta_albedo(:, :), emissivity_new(:, :), emissivity_prev(:, :), albedo_new(:, :), albedo_prev(:, :) - logical(lgt) :: is_root, accepted, tuning, first_prop, scattering - - return - - nprop = 1000 - tuning = gibbs_iter <= 25 - is_root = cpar%myid == cpar%root - - n0_prev = [(model%comps(i)%c%n_0, i = 1, model%n_comps)] - n0_new = n0_prev - - allocate(emissivity_prev(n_samp_bands, model%n_comps)) - allocate(albedo_prev(n_samp_bands, model%n_comps)) - allocate(eta_emissivity(n_samp_bands, model%n_comps)) - allocate(eta_albedo(n_samp_bands, model%n_comps)) - do i = 1, numband - if (data(i)%tod_type == "none") cycle - do j = 1, model%n_comps - emissivity_prev(i,j) = model%comps(j)%c%emissivity(i) - albedo_prev(i,j) = model%comps(j)%c%albedo(i) - end do - end do - emissivity_new = emissivity_prev - albedo_new = albedo_prev - - n_accepted = 0 - do prop = 0, nprop - first_prop = prop == 0 - ! propose new n0s - if (.not. first_prop) then - if (is_root) then - eta_n0 = [(rand_gauss(handle), i = 1, model%n_comps)] - n0_new = n0_prev + (step_sizes_n0 * eta_n0) - do i = 1, numband - if ((data(i)%tod_type == "none") .or. (.not. data(i)%tod%sample_zodi)) cycle - if (cpar%ds_zodi_reference_band(data(i)%id_abs)) then - eta_emissivity(i, :) = 0. - else - eta_emissivity(i, :) = [(rand_gauss(handle), j = 1, model%n_comps)] - end if - eta_albedo(i, :) = [(rand_gauss(handle), j = 1, model%n_comps)] - end do - emissivity_new = emissivity_prev + (step_sizes_emissivity * eta_emissivity) - albedo_new = albedo_prev + (step_sizes_albedo * eta_albedo) - end if - call mpi_bcast(n0_new, size(n0_new), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - call mpi_bcast(emissivity_new, size(emissivity_new), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - call mpi_bcast(albedo_new, size(albedo_new), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - end if - - chisq_scan = 0. - chisq_new = 0. - ! compute chisq for new model - do i = 1, numband - if ((data(i)%tod_type == "none") .or. (.not. data(i)%tod%sample_zodi)) cycle - ndet = data(i)%tod%ndet - nscan = data(i)%tod%nscan - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) - !scattering = any(data(i)%tod%zodi_albedo > EPS) - do scan = 1, nscan - do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - ! rescale downsampled zodi comp-wise emission with newly proposed n0s - !call get_s_zodi(& - ! & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - ! & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - ! & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi, & - ! & emissivity=emissivity_new(i, :), & - ! & albedo=albedo_new(i, :) & - ! &) - write(*,*) i, "a0", n0_new, n0_prev - write(*,*) i, scan, j, data(i)%tod%scanid(scan), cpar%myid, "a", data(i)%tod%scans(scan)%d(j)%N_psd%sigma0, box_width - write(*,*) i, data(i)%tod%scanid(scan), "b", any(data(i)%tod%scans(scan)%d(j)%downsamp_tod /= data(i)%tod%scans(scan)%d(j)%downsamp_tod), minval(data(i)%tod%scans(scan)%d(j)%downsamp_tod), maxval(data(i)%tod%scans(scan)%d(j)%downsamp_tod) - write(*,*) i, data(i)%tod%scanid(scan), "c", any(data(i)%tod%scans(scan)%d(j)%downsamp_sky /= data(i)%tod%scans(scan)%d(j)%downsamp_sky), minval(data(i)%tod%scans(scan)%d(j)%downsamp_sky), maxval(data(i)%tod%scans(scan)%d(j)%downsamp_sky) - write(*,*) i, data(i)%tod%scanid(scan), "d0", allocated(data(i)%tod%scans(scan)%d(j)%downsamp_zodi), size(data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - write(*,*) i, data(i)%tod%scanid(scan), "d1", any(data(i)%tod%scans(scan)%d(j)%downsamp_zodi /= data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - write(*,*) i, data(i)%tod%scanid(scan), "d2", minval(data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - write(*,*) i, data(i)%tod%scanid(scan), "d3", maxval(data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - data(i)%tod%scans(scan)%d(j)%downsamp_zodi = data(i)%tod%scans(scan)%d(j)%downsamp_zodi * n0_new/n0_prev - - chisq_scan = chisq_scan + sum( & - & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & - &) - end do - end do - end do - call mpi_reduce(chisq_scan, chisq_new, 1, MPI_DOUBLE_PRECISION, MPI_SUM, cpar%root, MPI_COMM_WORLD, ierr) - - ! Use chisq from the first iteration where we dont draw new parameters as the base chisq - if (first_prop) then - chisq_prev = chisq_new - else - if (is_root) then - chisq_diff = max(chisq_new - chisq_prev, 0.) - ln_accept_prob = -0.5 * chisq_diff - select case (cpar%operation) - case ("sample") - accepted = ln_accept_prob > log(rand_uni(handle)) .and. & - & all (emissivity_new > 0.) .and. all (emissivity_new < 5.) .and. & - & all (albedo_new > 0.) .and. all (albedo_new < 1.) - case ("optimize") - accepted = chisq_diff < 0. .and. all (emissivity_new > 0.) .and. all (emissivity_new < 5.) .and. & - & all (albedo_new > 0.) .and. all (albedo_new < 1.) - case default - stop "Error: invalid cpar%operation in comm_zodi_samp_mod sample_n0 routine" - end select - end if - call mpi_bcast(accepted, 1, MPI_LOGICAL, cpar%root, cpar%comm_chain, ierr) - - if (accepted) then - n_accepted = n_accepted + 1 - chisq_prev = chisq_new - n0_prev = n0_new - emissivity_prev = emissivity_new - albedo_prev = albedo_new - if (is_root) then - print *, "proposal:", prop - write(*, '(a, ES12.5)') "chisq: ", chisq_new - print *, " " - end if - else - n0_new = n0_prev - emissivity_new = emissivity_prev - albedo_new = albedo_prev - end if - accept_rate = real(n_accepted)/real(prop) - end if - end do - if (tuning) then - if (accept_rate < 0.1) then - step_sizes_n0 = step_sizes_n0 / 2. - step_sizes_emissivity = step_sizes_emissivity / 2. - step_sizes_albedo = step_sizes_albedo / 2. - else if (accept_rate > 0.4) then - step_sizes_n0 = step_sizes_n0 * 2. - step_sizes_emissivity = step_sizes_emissivity * 2. - step_sizes_albedo = step_sizes_albedo * 2. - end if - end if - if (is_root) print *, "n0 accept rate: ", (real(n_accepted)/real(nprop))*100. - do i = 1, model%n_comps - model%comps(i)%c%n_0 = n0_prev(i) - end do - do i = 1, numband - if (data(i)%tod_type == "none") cycle - do j = 1, model%n_comps - model%comps(j)%c%emissivity(i) = emissivity_prev(i,j) - model%comps(j)%c%albedo(i) = albedo_prev(i,j) - end do - end do - end subroutine - - subroutine sample_zodi_group(cpar, handle, gibbs_iter, model, verbose) - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: gibbs_iter - type(ZodiModel), intent(inout) :: model - logical(lgt), intent(in), optional :: verbose - - integer(i4b) :: i, j, k, prop, group_idx, flag, ndet, nscan, ntod, n_proposals, scan, ierr, n_accepted, param_idx - real(dp) :: chisq_tod, chisq_current, chisq_prior, chisq_diff, ln_acceptance_probability, accept_rate, chisq_lnL, box_width - real(dp), allocatable :: param_vec(:) - integer(i4b), allocatable :: group_indices(:) - type(ZodiModel) :: current_model, previous_model - logical(lgt) :: accepted, verbose_, tuning, skip - type(hdf_file) :: tod_file - character(len=128), allocatable :: param_labels(:) - - if (present(verbose)) then - verbose_ = verbose - else - verbose_ = .false. - end if - if (verbose_ .and. (cpar%myid == cpar%root)) print *, "sampling interplanetary dust parameters" - - current_model = model - previous_model = model - - tuning = .true. - n_proposals = 500 - - allocate(param_vec(current_model%n_params)) - call current_model%model_to_params2(param_vec, param_labels) - - ! sample all parameters in a group jointly - do group_idx = 1, cpar%zs_num_samp_groups - if (cpar%myid == cpar%root) print *, "sampling zodi group: ", group_idx, " of ", cpar%zs_num_samp_groups - - ! Get indices of the parameters to sample in the current sampling group - call parse_samp_group_strings(cpar%zs_samp_groups(group_idx), param_labels, group_indices) - - n_accepted = 0 - do prop = 0, n_proposals - ! if propsed parameter is outside of priors we dont want to immediately reject - skip = .false. - - ! Reset chisq for current proposal - chisq_tod = 0. - chisq_current = 0. - - ! If first iteration we dont want to draw, just compute the chisq with the base model - if (prop > 0) then - call current_model%model_to_params2(param_vec) - ! Root process draws new set of zodi parameters and broadcasts to all processes - if (cpar%myid == cpar%root) then - do i = 1, size(group_indices) - param_idx = group_indices(i) - param_vec(param_idx) = param_vec(param_idx) + (step_sizes_ipd(param_idx) * rand_gauss(handle)) - end do - ! HKE: NEED TO BE FIXED - !chisq_prior = get_chisq_priors(param_vec, samp_group=0) - !chisq_prior = get_chisq_priors(param_vec, prior_vec) - if (chisq_prior >= 1.d30) skip = .true. - end if - call mpi_bcast(chisq_prior, 1, MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - call mpi_bcast(param_vec, size(param_vec), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) - call current_model%params_to_model2(param_vec) - end if - do i = 1, numband - if (skip) exit ! drop evaluation if prior is violated - if (data(i)%tod_type == "none") cycle - if (.not. data(i)%tod%sample_zodi) cycle - - ! If chisq is already too large, skip rest of the evaluation and go directly to rejection - if (chisq_tod >= 1.d30) exit - - ndet = data(i)%tod%ndet - nscan = data(i)%tod%nscan - - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) - - ! Make sure that the zodi cache is cleared before each new band - call data(i)%tod%clear_zodi_cache() - - ! Evaluate zodi model with newly proposed values for each band and calculate chisq - do scan = 1, nscan - ! Skip scan if no accepted data - do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - - call get_zodi_emission(& - & tod=data(i)%tod, & - & pix=data(i)%tod%scans(scan)%d(j)%downsamp_pix, & - & scan=scan, & - & det=j, & - & s_zodi_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & model=current_model, & - & use_lowres_pointing=.true. & - &) - call get_s_zodi(i, & - & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - &) - - chisq_tod = chisq_tod + sum( & - & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & - &) - - if (chisq_tod >= 1.d30) exit - end do - end do - end do - - ! Reduce chisq to root process - call mpi_reduce(chisq_tod, chisq_current, 1, MPI_DOUBLE_PRECISION, MPI_SUM, cpar%root, MPI_COMM_WORLD, ierr) - - ! Add prior penalty to chisq - if (prop > 0 ) chisq_current = chisq_current + chisq_prior - - ! Use chisq from the first iteration where we dont draw new parameters as the base chisq - if (prop == 0) chisq_previous = chisq_current - - if (prop > 0) then - ! Root checks if the new proposal is accepted - if (cpar%myid == cpar%root) then - chisq_diff = max(chisq_current - chisq_previous, 0.) - ln_acceptance_probability = -0.5*chisq_diff - select case (cpar%operation) - case ("sample") - accepted = ln_acceptance_probability > log(rand_uni(handle)) - case ("optimize") - accepted = chisq_diff < 0. - case default - stop "Error: invalid operation" - end select - - if (verbose_ .and. accepted) then - print *, "proposal:", prop - write(*, '(a, ES12.5)') "chisq: ", chisq_current - print *, "accept rate:", (real(n_accepted)/real(prop))*100. - print *, " " - end if - end if - - call mpi_bcast(accepted, 1, MPI_LOGICAL, cpar%root, cpar%comm_chain, ierr) - ! Update model if proposal is accepted - if (accepted) then - n_accepted = n_accepted + 1 - chisq_previous = chisq_current - previous_model = current_model - else - current_model = previous_model - end if - accept_rate = real(n_accepted)/real(prop) - end if - end do - if (accept_rate < 0.05) then - do i = 1, size(group_indices) - param_idx = group_indices(i) - step_sizes_ipd(param_idx) = step_sizes_ipd(param_idx) / 2. - end do - else if (accept_rate > 0.95) then - do i = 1, size(group_indices) - param_idx = group_indices(i) - step_sizes_ipd(param_idx) = step_sizes_ipd(param_idx) * 2. - end do - end if - model = current_model - end do - end subroutine function get_chisq_priors(params, samp_group) result(chisq_prior) implicit none @@ -643,6 +96,14 @@ function get_chisq_priors(params, samp_group) result(chisq_prior) j = j+1 end do + + if (trim(zodi_model%phasefunc_type) == 'Hong') then + ! Check that sum of weights is smaller than 1 + if (params(4)+params(5) > 1.d0) then + chisq_prior = 1.d30 + return + end if + end if end function get_chisq_priors subroutine downsamp_invariant_structs(cpar) @@ -1180,7 +641,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) ! Get chisq of old point scale = pack(zodi_model%theta_scale(:,1), zodi_model%theta_stat(:,samp_group)==0) - call model_to_params(zodi_model, theta_old, samp_group) + call zodi_model%model_to_params(theta_old, samp_group) !!$ if (cpar%myid == cpar%root) then !!$ do i = 1, npar !!$ write(*,*) i, theta_old(i) @@ -1252,7 +713,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) call mpi_bcast(theta_new, size(theta_new), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) ! update model with final parameters - call params_to_model(zodi_model, theta_new, samp_group) + call zodi_model%params_to_model(theta_new, samp_group) ! Update monopole for requested bands do i = 1, numband @@ -1321,7 +782,7 @@ function lnL_zodi(p) return end if - call params_to_model(zodi_model, theta, samp_group) + call zodi_model%params_to_model(theta, samp_group) if (cpar%myid_chain == 0) call print_zodi_model(theta, samp_group) ndof = 0 @@ -2207,136 +1668,6 @@ subroutine randomize_zodi_init(x, samp_group, cpar, handle, rms) call mpi_bcast(x, size(x), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) end subroutine randomize_zodi_init - - - subroutine model_to_params(zodi, x, samp_group) - implicit none - class(ZodiModel), intent(in) :: zodi - real(dp), dimension(:), intent(out) :: x - integer(i4b), intent(in), optional :: samp_group - - integer(i4b) :: i, j, idx - real(dp), allocatable, dimension(:) :: z - - allocate(z(zodi%npar_tot)) - - ! General parameters - z(1) = zodi%T_0 - z(2) = zodi%delta - idx = zodi%n_general_params - - ! Component parameters - do i = 1, zodi%n_comps - ! Shape parameters - call zodi%comps(i)%c%model2param(z(idx+1:idx+zodi%comps(i)%npar)) - idx = idx + zodi%comps(i)%npar - - ! Emissivity and albedo - do j = 1, numband - if (data(j)%tod_type == "none") then - z(idx +j) = 0.d0 - z(idx+numband+j) = 0.d0 - else - z(idx +j) = zodi%comps(i)%c%emissivity(j) - z(idx+numband+j) = zodi%comps(i)%c%albedo(j) - end if - end do - idx = idx + 2*numband - end do - - ! Monopoles - do i = 1, numband - idx = idx+1 - if (data(i)%tod_type /= "none") then - z(idx) = band_monopole(i) !get_monopole_amp(data(i)%label) - !write(*,*) 'get', i, trim(data(i)%label), z(idx) - else - z(idx) = 0.d0 - end if - end do - - if (present(samp_group)) then - x = pack(z, zodi%theta_stat(:,samp_group)==0) - else - x = z - end if - deallocate(z) - - end subroutine model_to_params - - subroutine params_to_model(zodi, x, samp_group) - implicit none - class(ZodiModel), intent(inout) :: zodi - real(dp), dimension(:), intent(in) :: x - integer(i4b), intent(in), optional :: samp_group - - integer(i4b) :: i, j, idx - real(dp), allocatable, dimension(:) :: z, z_prev - - allocate(z(zodi%npar_tot)) - - ! Initialize full parameter vector - if (present(samp_group)) then - allocate(z_prev(zodi%npar_tot)) - call model_to_params(zodi, z_prev) - idx = 1 - do i = 1, zodi%npar_tot - if (zodi%theta_stat(i,samp_group) == 0) then - z(i) = x(idx) - idx = idx+1 - else if (zodi%theta_stat(i,samp_group) == -1) then - z(i) = z_prev(i) - else if (zodi%theta_stat(i,samp_group) == -2) then - z(i) = 0.d0 - else if (zodi%theta_stat(i,samp_group) == -3) then - z(i) = 1.d0 - end if - end do - do i = 1, zodi%npar_tot - if (zodi%theta_stat(i,samp_group) > 0) then - z(i) = z(zodi%theta_stat(i,samp_group)) - end if - end do - deallocate(z_prev) - else - z = x - end if - - ! General parameters - zodi%T_0 = z(1) - zodi%delta = z(2) - - ! Component parameters - idx = zodi%n_general_params - do i = 1, zodi%n_comps - ! Shape parameters - call zodi%comps(i)%c%param2model(z(idx+1:idx+zodi%comps(i)%npar)) - call zodi%comps(i)%c%init() - - ! Emissivity and albedo - idx = idx + zodi%comps(i)%npar - do j = 1, numband - if (data(j)%tod_type /= "none") then - zodi%comps(i)%c%emissivity(j) = z(idx+j) - zodi%comps(i)%c%albedo(j) = z(idx+numband+j) - end if - end do - idx = idx + 2*numband - end do - - ! Monopoles - do i = 1, numband - idx = idx+1 - if (data(i)%tod_type /= "none") then - !write(*,*) 'set', i, trim(data(i)%label), z(idx) - !call set_monopole_amp(data(i)%label, z(idx)) - band_monopole(i) = z(idx) - end if - end do - - deallocate(z) - - end subroutine params_to_model subroutine sample_static_zodi_map(cpar, handle, map_id) implicit none diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 7a6a7c374..1cd60b820 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -380,8 +380,6 @@ program commander ! Sample non-stationary zodi components with geometric 3D model select case (trim(adjustl(cpar%zs_sample_method))) - case ("mh") - call sample_zodi_group(cpar, handle, iter, zodi_model, verbose=.true.) case ("powell") do i = 1, cpar%zs_num_samp_groups if (iter > 1) call minimize_zodi_with_powell(cpar, iter, handle, i) From 2c0c7e68f02642bcc737413946296dfb6827c3f6 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 11 Mar 2025 13:01:24 +0100 Subject: [PATCH 133/171] Updated filelist to include moon data --- commander3/parameter_files/param_continuous_integration.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commander3/parameter_files/param_continuous_integration.txt b/commander3/parameter_files/param_continuous_integration.txt index 89d3e1c96..9cdf849ce 100644 --- a/commander3/parameter_files/param_continuous_integration.txt +++ b/commander3/parameter_files/param_continuous_integration.txt @@ -511,7 +511,7 @@ BAND_BANDPASSFILE&&& = haslam_bp.dat BAND_LABEL&&& = 10a BAND_MAPFILE&&& = DIRBE_10a_512_prod_v1.fits BAND_NOISEFILE&&& = DIRBE_10a_SIGMA_512_prod_v1.fits -BAND_TOD_FILELIST&&& = filelist_DIRBE_10_nside512_V21.txt +BAND_TOD_FILELIST&&& = filelist_DIRBE_10_nside512_V22a.txt BAND_SAMP_GAIN&&& = .false. BAND_TOD_TYPE&&& = DIRBE BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none From 034d7632686a5b9264ec67534014ea3b07c92ff2 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Thu, 13 Mar 2025 16:52:36 +0100 Subject: [PATCH 134/171] new version of hdf file generation with fix for npipe pointing and concatenation of short + long chunks --- .../tod_tools/commander_tod.py | 8 +- .../python/commander_tools/tod_tools/hfi.py | 2 +- commander3/todscripts/hfi/hfitohdf5.py | 91 +++++++++++++------ 3 files changed, 68 insertions(+), 33 deletions(-) diff --git a/commander3/python/commander_tools/tod_tools/commander_tod.py b/commander3/python/commander_tools/tod_tools/commander_tod.py index ad99b0190..665d8d7eb 100644 --- a/commander3/python/commander_tools/tod_tools/commander_tod.py +++ b/commander3/python/commander_tools/tod_tools/commander_tod.py @@ -20,10 +20,10 @@ #================================================================================ import h5py -#import commander_tools.tod_tools.huffman as huffman -#import commander_tools.tod_tools.rice as rice -import tod_tools.huffman as huffman -import tod_tools.rice as rice +import commander_tools.tod_tools.huffman as huffman +import commander_tools.tod_tools.rice as rice +#import tod_tools.huffman as huffman +#import tod_tools.rice as rice import healpy as hp import numpy as np import multiprocessing as mp diff --git a/commander3/python/commander_tools/tod_tools/hfi.py b/commander3/python/commander_tools/tod_tools/hfi.py index e5438aa82..bcd250202 100644 --- a/commander3/python/commander_tools/tod_tools/hfi.py +++ b/commander3/python/commander_tools/tod_tools/hfi.py @@ -32,7 +32,7 @@ class hfi(object): dets = {100:['1a', '1b', '2a', '2b', '3a', '3b', '4a', '4b'], 143:['1a', '1b', '2a', '2b', '3a', '3b', '4a', '4b', '5', '6', '7'], 217:['1', '2', '3', '4', '5a', '5b', '6a', '6b', '7a', '7b', '8a', '8b'], 353:['1', '2', '3a', '3b', '4a', '4b', '5a', '5b', '6a', '6b', '7', '8'], 545:['1', '2', '4'], 857:['1', '2', '3', '4']} npsi = 4096 ntodsigma = 100 - nsides = {100:1024, 143:2048, 217:1024, 353:1024, 545:2048, 857:2048} + nsides = {100:1024, 143:2048, 217:2048, 353:2048, 545:2048, 857:2048} #compression arrays huffman = ['huffman', {'dictNum':1}] huffTod = ['huffman', {'dictNum':2}] diff --git a/commander3/todscripts/hfi/hfitohdf5.py b/commander3/todscripts/hfi/hfitohdf5.py index b2aae13db..3fb11b095 100644 --- a/commander3/todscripts/hfi/hfitohdf5.py +++ b/commander3/todscripts/hfi/hfitohdf5.py @@ -192,15 +192,39 @@ def make_od(comm_tod, freq, od, args): starttime = pointingFile[1].data['obt'][0]/1e9 endtime = pointingFile[1].data['obt'][-1]/1e9 - #per pid - for dbentry in c.execute("SELECT * FROM ring_times_hfi WHERE stop_time >= '{0}' AND start_time < '{1}'".format(starttime, endtime)): - pid = dbentry[0] + dbs = c.execute("SELECT * FROM ring_times_hfi WHERE stop_time >= '{0}' AND start_time < '{1}'".format(starttime, endtime)) + #Make a new list where the each short chunk is prepended to a long chunk + chunks = [] + + start = True + for dbentry in dbs: + pid = dbentry[0] start_time = dbentry[2] - end_time = dbentry[3] + end_time = dbentry[3] + + if(start): + curr_chunk = [] + curr_chunk.append(pid) + curr_chunk.append(start_time) + curr_chunk.append(end_time) + start = False + else: + curr_chunk.append(start_time) + curr_chunk.append(end_time) + chunks.append(curr_chunk) + start = True + + #per pid + for chunk in chunks: + pid = chunk[0] + + start_time = chunk[1] + end_time = chunk[4] startIndex = np.where(exFile[1].data['obt']/1e9 > start_time) endIndex = np.where(exFile[1].data['obt']/1e9 > end_time) + if len(startIndex[0]) > 0: pid_start = startIndex[0][0] else:#catch days with no pids @@ -212,6 +236,11 @@ def make_od(comm_tod, freq, od, args): if pid_start == pid_end:#catch chunks with no data like od 1007 continue + #There are some samples that are not included in either chunk... + garbageStart = np.where(exFile[1].data['obt']/1e9 > chunk[2])[0][0] + garbageEnd = np.where(exFile[1].data['obt']/1e9 > chunk[3])[0][0] + ngarbage = garbageEnd - garbageStart + #common fields per pid prefix = str(pid).zfill(6) + '/common' @@ -249,8 +278,9 @@ def make_od(comm_tod, freq, od, args): r_boresight = rot.from_quat(quat_arr) - extra_flags = extraFlagsFile[str(pid).zfill(6) + '/flag_extra'] - + extra_flags = extraFlagsFile[str(pid).zfill(6) + '/flag_extra'][()] + extra_flags = np.append(extra_flags, np.ones(ngarbage, dtype='uint16')) + extra_flags = np.append(extra_flags, extraFlagsFile[str(pid+1).zfill(6) + '/flag_extra'][()]) #per detector fields for det in hfi.dets[freq]: @@ -263,12 +293,18 @@ def make_od(comm_tod, freq, od, args): data_i = exFile.index_of(str(freq) + '-' + det) #make flag data - flagArray = exFile[data_i].data.field('flag')[pid_start:pid_end] + flagArray = np.array(exFile[data_i].data.field('flag')[pid_start:pid_end], dtype='uint16') #add extra flagging from txt files ex_flags = extra_flags if(det == '353-1'): - ex_flags = extraFlagsFile[str(pid).zfill(6) + '/flags_extra_353-1'] + #add extra flags and a bit for the repointing period + ex_flags = extraFlagsFile[str(pid).zfill(6) + '/flags_extra_353-1'] + 256 + #add flags for garbage data + ex_flags = np.append(ex_flags, np.zeros(ngarbage, dtype=uint16)) + + #add flags from scanning chunk + ex_flags = np.append(extraFlagsFile[str(pid+1).zfill(6) + '/flags_extra_353-1']) flagArray += ex_flags #with np.printoptions(threshold=np.inf): @@ -283,48 +319,46 @@ def make_od(comm_tod, freq, od, args): # Follows this npipe function: # https://github.com/planck-npipe/toast-npipe/blob/master/toast_planck/utilities.py#L1503-L1575 - phi = math.radians(rimo[1].data.field('phi_uv')[rimo_i]) - theta = math.radians(rimo[1].data.field('theta_uv')[rimo_i]) - psi = math.radians(rimo[1].data.field('psi_uv')[rimo_i] + rimo[1].data.field('psi_pol')[rimo_i]) - phi + phi = float(math.radians(rimo[1].data.field('phi_uv').ravel()[rimo_i])) + theta = float(math.radians(rimo[1].data.field('theta_uv').ravel()[rimo_i])) + psi = float(math.radians(rimo[1].data.field('psi_uv').ravel()[rimo_i])) + float(rimo[1].data.field('psi_pol').ravel()[rimo_i]) - phi #print(phi) #print(theta) - #print(psi) + #print(psi, float(math.radians(rimo[1].data.field('psi_uv').ravel()[rimo_i])), float(rimo[1].data.field('psi_pol').ravel()[rimo_i])) - det_s = np.cos(0.5 * theta) * np.cos(0.5 * (phi + psi)) - # vector part - det_x = -np.sin(0.5 * theta) * np.sin(0.5 * (phi - psi)) - det_y = np.sin(0.5 * theta) * np.cos(0.5 * (phi - psi)) - det_z = np.cos(0.5 * theta) * np.sin(0.5 * (phi + psi)) + #ZYZ + r_det = rot.from_euler('ZYZ', [phi, theta, psi]) - #convert from boresight pointing to per detector pointing - r_det = rot.from_quat([det_x, det_y, det_z, det_s]) - #print r_det - #print r_boresight - #print + #rotation due to spin angle + r_spin = rot.from_euler('Y', np.pi/2 - math.radians(85)) - #print("Disabling focal plane") - r_total = r_boresight * r_det + r_total = r_boresight *r_spin * r_det #convert to theta, phi, psi - angs = r_total.as_euler('ZYZ') # could also be 'ZXZ' if we are supposed to be using intrinsic rotations instead of extrinsic - # idk what the difference is + angs = r_total.as_euler('ZYZ') phi_array = angs[:,0] theta_array = angs[:,1] psi_array = angs[:,2] - + + # additional psi rotation due to ecliptic/galactic rotation r = hp.rotator.Rotator(coord=['E', 'G'], deg=False) + angle = r.angle_ref([theta_array, phi_array]) galTheta, galPhi = r(theta_array, phi_array) pixels = hp.pixelfunc.ang2pix(nside, galTheta, galPhi) + ''' if(pid == 25083): + plt.figure() x = np.arange(0, 20000) theta_, phi_ = hp.pix2ang(nside, pixels) + print('theta, phi, psi=', np.rad2deg(theta), np.rad2deg(phi), np.rad2deg(psi)) + #print('x, y, z, x=', det_x, det_y, det_z, det_s) plt.plot(x, theta_[-20000:], label='theta') plt.plot(x, phi_[-20000:], label='phi') plt.plot(x, quat_x[-20000:], label='x') @@ -335,7 +369,7 @@ def make_od(comm_tod, freq, od, args): plt.savefig('quat_test.pdf') #sys.exit() - + ''' if len(pixels > 0): #compute average outer product @@ -349,6 +383,7 @@ def make_od(comm_tod, freq, od, args): #make pol angle if(len(psi_array) > 0): + psi_array += angle psi_array = np.where(psi_array < 0, 2*np.pi + psi_array, psi_array) psi_array = np.where(psi_array >= 2*np.pi, psi_array - 2*np.pi, psi_array) compArray = None From 281574b814b0e39250a6dbe9f24f2c18e36998e3 Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Mon, 17 Mar 2025 15:19:20 +0100 Subject: [PATCH 135/171] Add HFI single horn parameter files --- .../defaults/bands/HFI/HFI_100-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_100-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_100-3_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_100-4_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-3_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-4_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-5_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-6_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_143-7_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-3_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-4_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-5_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-6_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-7_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_217-8_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-3_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-4_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-5_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-6_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-7_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_353-8_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_545-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_545-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_545-4_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_857-1_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_857-2_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_857-3_HFI.defaults | 41 +++++++++++++++++++ .../defaults/bands/HFI/HFI_857-4_HFI.defaults | 41 +++++++++++++++++++ 34 files changed, 1394 insertions(+) create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults create mode 100644 commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults new file mode 100644 index 000000000..7ed7b7c0e --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults @@ -0,0 +1,41 @@ +# 100-1 GHz map parameters +BAND_LABEL&&& = 100-1 +BAND_INSTRUMENT_LABEL&&& = 100-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_100-1_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_100-1_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_100-1_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_100-1x100-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 100 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-1_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults new file mode 100644 index 000000000..fadec4378 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults @@ -0,0 +1,41 @@ +# 100-2 GHz map parameters +BAND_LABEL&&& = 100-2 +BAND_INSTRUMENT_LABEL&&& = 100-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_100-2_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_100-2_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_100-2_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_100-2x100-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 100 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-2_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults new file mode 100644 index 000000000..9e6796bbc --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults @@ -0,0 +1,41 @@ +# 100-3 GHz map parameters +BAND_LABEL&&& = 100-3 +BAND_INSTRUMENT_LABEL&&& = 100-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_100-3_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_100-3_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_100-3_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_100-3x100-3_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 100 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-3_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults new file mode 100644 index 000000000..3930a360d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults @@ -0,0 +1,41 @@ +# 100-4 GHz map parameters +BAND_LABEL&&& = 100-4 +BAND_INSTRUMENT_LABEL&&& = 100-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_100-4_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_100-4_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_100-4_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_100-4x100-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 100 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-4_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults new file mode 100644 index 000000000..e15c420eb --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults @@ -0,0 +1,41 @@ +# 143-1 GHz map parameters +BAND_LABEL&&& = 143-1 +BAND_INSTRUMENT_LABEL&&& = 143-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-1_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-1_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-1_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-1x143-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-1_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults new file mode 100644 index 000000000..d532aa608 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults @@ -0,0 +1,41 @@ +# 143-2 GHz map parameters +BAND_LABEL&&& = 143-2 +BAND_INSTRUMENT_LABEL&&& = 143-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-2_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-2_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-2_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-2x143-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-2_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults new file mode 100644 index 000000000..3d221f35c --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults @@ -0,0 +1,41 @@ +# 143-3 GHz map parameters +BAND_LABEL&&& = 143-3 +BAND_INSTRUMENT_LABEL&&& = 143-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-3_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-3_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-3_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-3x143-3_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-3_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults new file mode 100644 index 000000000..bac570a3c --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults @@ -0,0 +1,41 @@ +# 143-4 GHz map parameters +BAND_LABEL&&& = 143-4 +BAND_INSTRUMENT_LABEL&&& = 143-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-4_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-4_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-4_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-4x143-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-4_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults new file mode 100644 index 000000000..9ac7e08d9 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults @@ -0,0 +1,41 @@ +# 143-5 GHz map parameters +BAND_LABEL&&& = 143-5 +BAND_INSTRUMENT_LABEL&&& = 143-5 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-5_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-5_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-5_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-5x143-5_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-5.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults new file mode 100644 index 000000000..cd08e90e4 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults @@ -0,0 +1,41 @@ +# 143-6 GHz map parameters +BAND_LABEL&&& = 143-6 +BAND_INSTRUMENT_LABEL&&& = 143-6 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-6_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-6_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-6_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-6x143-6_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-6.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults new file mode 100644 index 000000000..a1acb0872 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults @@ -0,0 +1,41 @@ +# 143-7 GHz map parameters +BAND_LABEL&&& = 143-7 +BAND_INSTRUMENT_LABEL&&& = 143-7 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 2048 +BAND_LMAX&&& = 6000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_143-7_npipe_02048_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_143-7_npipe_02048_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_143-7_npipe_02048_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_143-7x143-7_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n2048.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 143 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-7.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults new file mode 100644 index 000000000..7166bcce3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults @@ -0,0 +1,41 @@ +# 217-1 GHz map parameters +BAND_LABEL&&& = 217-1 +BAND_INSTRUMENT_LABEL&&& = 217-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-1_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-1_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-1_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-1x217-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults new file mode 100644 index 000000000..c9acf759d --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults @@ -0,0 +1,41 @@ +# 217-2 GHz map parameters +BAND_LABEL&&& = 217-2 +BAND_INSTRUMENT_LABEL&&& = 217-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-2_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-2_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-2_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-2x217-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults new file mode 100644 index 000000000..b01768a2f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults @@ -0,0 +1,41 @@ +# 217-3 GHz map parameters +BAND_LABEL&&& = 217-3 +BAND_INSTRUMENT_LABEL&&& = 217-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-3_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-3_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-3_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-3x217-3_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-3.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults new file mode 100644 index 000000000..0d9a4c4d8 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults @@ -0,0 +1,41 @@ +# 217-4 GHz map parameters +BAND_LABEL&&& = 217-4 +BAND_INSTRUMENT_LABEL&&& = 217-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-4_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-4_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-4_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-4x217-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-4.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults new file mode 100644 index 000000000..8746bb6a9 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults @@ -0,0 +1,41 @@ +# 217-5 GHz map parameters +BAND_LABEL&&& = 217-5 +BAND_INSTRUMENT_LABEL&&& = 217-5 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-5_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-5_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-5_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-5x217-5_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-5_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults new file mode 100644 index 000000000..8e8bcb262 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults @@ -0,0 +1,41 @@ +# 217-6 GHz map parameters +BAND_LABEL&&& = 217-6 +BAND_INSTRUMENT_LABEL&&& = 217-6 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-6_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-6_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-6_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-6x217-6_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-6_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults new file mode 100644 index 000000000..b4bc26885 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults @@ -0,0 +1,41 @@ +# 217-7 GHz map parameters +BAND_LABEL&&& = 217-7 +BAND_INSTRUMENT_LABEL&&& = 217-7 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-7_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-7_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-7_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-7x217-7_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-7_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults new file mode 100644 index 000000000..c85bb1b1f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults @@ -0,0 +1,41 @@ +# 217-8 GHz map parameters +BAND_LABEL&&& = 217-8 +BAND_INSTRUMENT_LABEL&&& = 217-8 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_217-8_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_217-8_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_217-8_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_217-8x217-8_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 217 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-8_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults new file mode 100644 index 000000000..653a36452 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults @@ -0,0 +1,41 @@ +# 353-1 GHz map parameters +BAND_LABEL&&& = 353-1 +BAND_INSTRUMENT_LABEL&&& = 353-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-1_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-1_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-1_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-1x353-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults new file mode 100644 index 000000000..659037c3e --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults @@ -0,0 +1,41 @@ +# 353-2 GHz map parameters +BAND_LABEL&&& = 353-2 +BAND_INSTRUMENT_LABEL&&& = 353-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-2_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-2_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-2_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-2x353-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults new file mode 100644 index 000000000..1484602b3 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults @@ -0,0 +1,41 @@ +# 353-3 GHz map parameters +BAND_LABEL&&& = 353-3 +BAND_INSTRUMENT_LABEL&&& = 353-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-3_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-3_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-3_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-3x353-3_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-3_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults new file mode 100644 index 000000000..54d2f08cc --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults @@ -0,0 +1,41 @@ +# 353-4 GHz map parameters +BAND_LABEL&&& = 353-4 +BAND_INSTRUMENT_LABEL&&& = 353-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-4_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-4_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-4_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-4x353-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-4_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults new file mode 100644 index 000000000..6f22a6ca2 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults @@ -0,0 +1,41 @@ +# 353-5 GHz map parameters +BAND_LABEL&&& = 353-5 +BAND_INSTRUMENT_LABEL&&& = 353-5 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-5_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-5_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-5_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-5x353-5_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-5_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults new file mode 100644 index 000000000..0d15ef1ba --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults @@ -0,0 +1,41 @@ +# 353-6 GHz map parameters +BAND_LABEL&&& = 353-6 +BAND_INSTRUMENT_LABEL&&& = 353-6 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-6_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-6_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-6_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-6x353-6_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-6_SHORN.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults new file mode 100644 index 000000000..c0d389109 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults @@ -0,0 +1,41 @@ +# 353-7 GHz map parameters +BAND_LABEL&&& = 353-7 +BAND_INSTRUMENT_LABEL&&& = 353-7 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-7_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-7_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-7_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-7x353-7_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-7.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults new file mode 100644 index 000000000..5990448bd --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults @@ -0,0 +1,41 @@ +# 353-8 GHz map parameters +BAND_LABEL&&& = 353-8 +BAND_INSTRUMENT_LABEL&&& = 353-8 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_353-8_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_353-8_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_353-8_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_353-8x353-8_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 353 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-8.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults new file mode 100644 index 000000000..6fb6e31c0 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults @@ -0,0 +1,41 @@ +# 545-1 GHz map parameters +BAND_LABEL&&& = 545-1 +BAND_INSTRUMENT_LABEL&&& = 545-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_545-1_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_545-1_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_545-1_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_545-1x545-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 545 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults new file mode 100644 index 000000000..ff3940e8f --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults @@ -0,0 +1,41 @@ +# 545-2 GHz map parameters +BAND_LABEL&&& = 545-2 +BAND_INSTRUMENT_LABEL&&& = 545-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_545-2_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_545-2_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_545-2_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_545-2x545-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 545 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults new file mode 100644 index 000000000..fe57cf01b --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults @@ -0,0 +1,41 @@ +# 545-4 GHz map parameters +BAND_LABEL&&& = 545-4 +BAND_INSTRUMENT_LABEL&&& = 545-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_545-4_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_545-4_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_545-4_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_545-4x545-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 545 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-4.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults new file mode 100644 index 000000000..c1d6e0547 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults @@ -0,0 +1,41 @@ +# 857-1 GHz map parameters +BAND_LABEL&&& = 857-1 +BAND_INSTRUMENT_LABEL&&& = 857-1 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_857-1_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_857-1_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_857-1_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_857-1x857-1_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 857 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-1.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults new file mode 100644 index 000000000..eea68e6bd --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults @@ -0,0 +1,41 @@ +# 857-2 GHz map parameters +BAND_LABEL&&& = 857-2 +BAND_INSTRUMENT_LABEL&&& = 857-2 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_857-2_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_857-2_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_857-2_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_857-2x857-2_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 857 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-2.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults new file mode 100644 index 000000000..ddcd233bc --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults @@ -0,0 +1,41 @@ +# 857-3 GHz map parameters +BAND_LABEL&&& = 857-3 +BAND_INSTRUMENT_LABEL&&& = 857-3 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_857-3_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_857-3_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_857-3_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_857-3x857-3_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 857 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-3.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults new file mode 100644 index 000000000..5c01d6cb6 --- /dev/null +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults @@ -0,0 +1,41 @@ +# 857-4 GHz map parameters +BAND_LABEL&&& = 857-4 +BAND_INSTRUMENT_LABEL&&& = 857-4 +BAND_OBS_PERIOD&&& = 1 +BAND_POLARIZATION&&& = .false. +BAND_NSIDE&&& = 4096 +BAND_LMAX&&& = 10000 +BAND_UNIT&&& = uK_cmb +BAND_NOISE_FORMAT&&& = rms +BAND_MAPFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/map/map_planck_857-4_npipe_04096_fullres_full_T.fits +BAND_NOISEFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/rms/rms_planck_857-4_npipe_04096_fullres_full_T.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.01 +BAND_MASKFILE&&& = /mn/stornext/d23/cmbco/globe/fullres/planck/mask/hitmask_planck_857-4_npipe_04096_fullres_full_T.fits +BAND_MASKFILE_CALIB&&& = fullsky +BAND_BEAMTYPE&&& = b_l +BAND_BEAM_B_L_FILE&&& = Bl_npipe6v20_857-4x857-4_extended.fits +BAND_BEAM_B_PTSRC_FILE&&& = none +BAND_PIXEL_WINDOW&&& = pixel_window_n4096.fits +BAND_SAMP_NOISE_AMP&&& = .false. +BAND_BANDPASS_TYPE&&& = HFI_cmb +BAND_BANDPASS_MODEL&&& = additive_shift +BAND_NOMINAL_FREQ&&& = 857 +BAND_SAMP_BANDPASS&&& = .false +BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-4.dat +BAND_SAMP_GAIN&&& = .false. +BAND_GAIN_PRIOR_MEAN&&& = 1. +BAND_GAIN_PRIOR_RMS&&& = 1. +BAND_GAIN_CALIB_COMP&&& = all +BAND_GAIN_LMIN&&& = 25 +BAND_GAIN_LMAX&&& = 100 +BAND_GAIN_APOD_MASK&&& = fullsky +BAND_GAIN_APOD_FWHM&&& = 120. +BAND_DEFAULT_GAIN&&& = 1. +BAND_DEFAULT_BP_DELTA&&& = 0. +BAND_DEFAULT_NOISEAMP&&& = 1. +BAND_COMPONENT_SENSITIVITY&&& = broadband +BAND_TOD_TYPE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none From 4f73c338065e8a42aaf008d9a8df00eaa97c0773 Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Mon, 17 Mar 2025 15:23:19 +0100 Subject: [PATCH 136/171] CO default parameter files for HFI single horn runs --- .../defaults/components/co/co100_HFI.defaults | 39 +++++++++++++++++++ .../defaults/components/co/co217_HFI.defaults | 39 +++++++++++++++++++ .../defaults/components/co/co353_HFI.defaults | 39 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 commander3/parameter_files/defaults/components/co/co100_HFI.defaults create mode 100644 commander3/parameter_files/defaults/components/co/co217_HFI.defaults create mode 100644 commander3/parameter_files/defaults/components/co/co353_HFI.defaults diff --git a/commander3/parameter_files/defaults/components/co/co100_HFI.defaults b/commander3/parameter_files/defaults/components/co/co100_HFI.defaults new file mode 100644 index 000000000..b3b74327b --- /dev/null +++ b/commander3/parameter_files/defaults/components/co/co100_HFI.defaults @@ -0,0 +1,39 @@ +# CO component +COMP_LABEL&& = co100 +COMP_TYPE&& = line +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 2048 +COMP_L_APOD&& = 6000 +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_OUTPUT_FWHM&& = 9.5 # arcmin +COMP_UNIT&& = Kkm/s +COMP_NU_REF_T&& = 115.27 +COMP_NU_REF_P&& = 115.27 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_BAND_REF&& = 100-1 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_co_lineratio_v3_n2048.fits +COMP_MONOPOLE_PRIOR&& = none +COMP_CL_TYPE&& = gauss # {none, single_l, binned, power_law} +COMP_CL_POLTYPE&& = 1 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.5 +COMP_CL_BETA_PRIOR_RMS&& = 0.1 +COMP_CL_L_PIVOT&& = 100 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 10000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 1.d0 +COMP_CL_DEFAULT_AMP_B&& = 1.d0 +COMP_CL_DEFAULT_BETA_T&& = 9.5d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_LINE_TEMPLATE&& = /mn/stornext/d23/cmbco/cg/hfi/compsep/co100_line_template_HFI_v1.dat +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_AMP_INPUT_MAP&& = lambda_wco_dht2001_n2048.fits +COMP_AMP_PRIOR_MAP&& = none +COMP_INIT_FROM_HDF&& = default diff --git a/commander3/parameter_files/defaults/components/co/co217_HFI.defaults b/commander3/parameter_files/defaults/components/co/co217_HFI.defaults new file mode 100644 index 000000000..6b58918f1 --- /dev/null +++ b/commander3/parameter_files/defaults/components/co/co217_HFI.defaults @@ -0,0 +1,39 @@ +# CO component +COMP_LABEL&& = co217 +COMP_TYPE&& = line +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 2048 +COMP_L_APOD&& = 6000 +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_OUTPUT_FWHM&& = 5.0 # arcmin +COMP_UNIT&& = Kkm/s +COMP_NU_REF_T&& = 230.54 +COMP_NU_REF_P&& = 230.54 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_BAND_REF&& = 217-1 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_co_lineratio_v3_n2048.fits +COMP_MONOPOLE_PRIOR&& = none +COMP_CL_TYPE&& = gauss # {none, single_l, binned, power_law} +COMP_CL_POLTYPE&& = 1 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.5 +COMP_CL_BETA_PRIOR_RMS&& = 0.1 +COMP_CL_L_PIVOT&& = 100 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 10000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 1.d0 +COMP_CL_DEFAULT_AMP_B&& = 1.d0 +COMP_CL_DEFAULT_BETA_T&& = 9.5d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_LINE_TEMPLATE&& = /mn/stornext/d23/cmbco/cg/hfi/compsep/co217_line_template_HFI_v1.dat +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_AMP_INPUT_MAP&& = COM_CompMap_CO21-commander_2048_R2.00.fits +COMP_AMP_PRIOR_MAP&& = none +COMP_INIT_FROM_HDF&& = default diff --git a/commander3/parameter_files/defaults/components/co/co353_HFI.defaults b/commander3/parameter_files/defaults/components/co/co353_HFI.defaults new file mode 100644 index 000000000..4b8408ac2 --- /dev/null +++ b/commander3/parameter_files/defaults/components/co/co353_HFI.defaults @@ -0,0 +1,39 @@ +# CO component +COMP_LABEL&& = co353 +COMP_TYPE&& = line +COMP_CLASS&& = diffuse # {diffuse, ptsrc} +COMP_POLARIZATION&& = .false. +COMP_CG_SCALE_T&& = 1.d0 +COMP_CG_SCALE_P&& = 1.d0 +COMP_CG_SAMPLE_GROUP&& = 1 +COMP_CG_SAMP_GROUP_MAXITER&& = 35 +COMP_NSIDE&& = 2048 +COMP_L_APOD&& = 6000 +COMP_AMP_LMIN&& = 0 +COMP_AMP_LMAX&& = 6000 +COMP_OUTPUT_FWHM&& = 5.0 # arcmin +COMP_UNIT&& = Kkm/s +COMP_NU_REF_T&& = 345.81 +COMP_NU_REF_P&& = 345.81 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_BAND_REF&& = 353-1 +COMP_MASK&& = fullsky +COMP_INDMASK&& = mask_co_lineratio_v3_n2048.fits +COMP_MONOPOLE_PRIOR&& = none +COMP_CL_TYPE&& = gauss # {none, single_l, binned, power_law} +COMP_CL_POLTYPE&& = 1 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} +COMP_CL_BETA_PRIOR_MEAN&& = -0.5 +COMP_CL_BETA_PRIOR_RMS&& = 0.1 +COMP_CL_L_PIVOT&& = 100 # Pivot multipole +COMP_CL_DEFAULT_AMP_T&& = 10000 # D_l = amp * (l/lpivot)**beta +COMP_CL_DEFAULT_AMP_E&& = 1.d0 +COMP_CL_DEFAULT_AMP_B&& = 1.d0 +COMP_CL_DEFAULT_BETA_T&& = 9.5d0 +COMP_CL_DEFAULT_BETA_E&& = -0.5d0 +COMP_CL_DEFAULT_BETA_B&& = -0.5d0 +COMP_LINE_TEMPLATE&& = /mn/stornext/d23/cmbco/cg/hfi/compsep/co353_line_template_HFI_v1.dat +COMP_APPLY_JEFFREYS_PRIOR&& = .false. +COMP_AMP_INPUT_MAP&& = none +COMP_AMP_PRIOR_MAP&& = none +COMP_INIT_FROM_HDF&& = default From 144da5dcd1a992461045fc96d5bff58be02302bc Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Mon, 17 Mar 2025 15:28:00 +0100 Subject: [PATCH 137/171] relquad defaults for single horns --- .../components/cmb/cmb_relquad_rs.defaults | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 commander3/parameter_files/defaults/components/cmb/cmb_relquad_rs.defaults diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_relquad_rs.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_rs.defaults new file mode 100644 index 000000000..eec91af2a --- /dev/null +++ b/commander3/parameter_files/defaults/components/cmb/cmb_relquad_rs.defaults @@ -0,0 +1,14 @@ +# CMB relativistic quadrupole correction +COMP_LABEL&& = relquad +COMP_TYPE&& = cmb_relquad +COMP_CLASS&& = template +COMP_POLARIZATION&& = .false. +#COMP_CG_SCALE&& = 1.d0 +COMP_NU_MIN&& = 0.d0 +COMP_NU_MAX&& = 1d30 +COMP_CG_SAMPLE_GROUP&& = 0 +COMP_PRIOR_GAUSS_MEAN&& = 1.d0 +COMP_PRIOR_GAUSS_RMS&& = 0.d0 +COMP_DEFAULT_AMPLITUDE&& = 1.d0 +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def_rs.txt +COMP_INIT_FROM_HDF&& = none \ No newline at end of file From 18275cd38fe1b11075d24dd4de028231c4d46526 Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Mon, 17 Mar 2025 15:28:52 +0100 Subject: [PATCH 138/171] Line comp mod with faster mixing matrix updates --- commander3/src/comm_line_comp_mod.f90 | 803 +++++++++++++++----------- 1 file changed, 465 insertions(+), 338 deletions(-) diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index dbf25b1ca..b102f7e6c 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -19,341 +19,468 @@ ! !================================================================================ module comm_line_comp_mod - use comm_comp_interface_mod - implicit none - - private - public comm_line_comp - - !************************************************** - ! Line emission component - !************************************************** - type, extends (comm_diffuse_comp) :: comm_line_comp - integer(i4b) :: ref_band - real(dp) :: line2RJ_ref - integer(i4b), allocatable, dimension(:) :: ind2band - real(dp), allocatable, dimension(:) :: line2RJ - contains - procedure :: S => evalSED_line - procedure :: sampleSpecInd => sampleLineRatios - end type comm_line_comp - - interface comm_line_comp - procedure constructor_line - end interface comm_line_comp - -contains - - !************************************************** - ! Routine definitions - !************************************************** - function constructor_line(cpar, id, id_abs) result(c) - implicit none - type(comm_params), intent(in) :: cpar - integer(i4b), intent(in) :: id, id_abs - class(comm_line_comp), pointer :: c - - integer(i4b) :: i, j, k, l, m, nline, b, n, ierr - real(dp) :: f - logical(lgt) :: ref_exist - character(len=512), allocatable, dimension(:) :: label - real(dp), allocatable, dimension(:) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:) :: poltype - type(comm_mapinfo), pointer :: info - - ! General parameters - allocate(c) - c%npar = 0 !temporary value so that lmax_ind is correcty set (to 0) in initDiffuse - call c%initDiffuse(cpar, id, id_abs) - - ! Read line template file - call read_line_template(trim(cpar%cs_SED_template(1,id_abs)), & - & nline, label, mu, sigma, line2RJ, poltype) - - ! Check how many lines are included in current run - n = 0 - ref_exist = .false. - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) n = n+1 - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) ref_exist = .true. - end do - if (.not. ref_exist) call report_error("Line component reference band does not exist, need "//trim(cpar%cs_band_ref(id_abs))) - - allocate(c%ind2band(n)) - c%npar = n - - allocate(c%lmax_ind_pol(3,c%npar)) - c%lmax_ind_pol = 0 !always fullsky (lmax=0) for line component - if (allocated(c%lmax_ind_mix)) deallocate(c%lmax_ind_mix) - allocate(c%lmax_ind_mix(3,c%npar)) - c%lmax_ind_mix = 0 !always fullsky (lmax=0) for line component - allocate(c%pol_pixreg_type(3,c%npar)) - c%pol_pixreg_type = 0 - - allocate(c%theta_def(n), c%p_gauss(2,n), c%p_uni(2,n)) - allocate(c%poltype(n), c%indlabel(n), c%line2RJ(n)) - n = 0 - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) then - n = n+1 - c%ind2band(n) = i - c%theta_def(n) = mu(j) - c%p_gauss(1,n) = mu(j) - c%p_gauss(2,n) = sigma(j) - c%p_uni(1,n) = -100.d30 !mu(j)-5*sigma(j) - c%p_uni(2,n) = 100.d30 !mu(j)+5*sigma(j) - c%poltype(n) = poltype(j) - c%indlabel(n) = label(j) - c%line2RJ(n) = line2RJ(j) - exit - end if - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) then - c%ref_band = i - c%line2RJ_ref = c%line2RJ(n) - end if - end do - - ! Update reference band unit conversion - do i = 1, c%x%info%nmaps - c%RJ2unit_(i) = 1.d0 / c%line2RJ_ref - c%x%map(:,i) = c%x%map(:,i) / c%RJ2unit_(i) - c%x%alm(:,i) = c%x%alm(:,i) / c%RJ2unit_(i) - end do - - ! Initialize spectral index maps - info => comm_mapinfo(cpar%comm_chain, c%nside, c%lmax_ind, & - & c%nmaps, c%pol) - - allocate(c%theta(n)) - do i = 1, n - c%theta(i)%p => comm_map(info) - c%theta(i)%p%map = c%theta_def(i) - if (c%lmax_ind >= 0) call c%theta(i)%p%YtW_scalar - end do - - - ! Precompute mixmat integrator for each band - allocate(c%F_int(3,numband,0:c%ndet)) - j = 1 - do l = 1, 3 - do i = 1, numband - if (l > 1) then - do m = 0,c%ndet - c%F_int(l,i,m)%p => c%F_int(l-1,i,m)%p - end do - cycle - end if - if (any(c%ind2band == i)) then - do k = 0, data(i)%ndet -! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & - & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) - end do - j = j+1 - else - do k = 0, data(i)%ndet -! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .false., 0.d0, j) - end do - end if - end do - end do - - ! Initialize mixing matrix - if (trim(cpar%init_chain_prefix) == 'none' & - & .or. trim(c%init_from_HDF) == 'none') & - & call c%updateMixmat - - deallocate(label, mu, sigma, line2RJ, poltype) - - end function constructor_line - - ! Definition: - ! SED = delta_{band, - function evalSED_line(self, nu, band, pol, theta) - class(comm_line_comp), intent(in) :: self - real(dp), intent(in), optional :: nu - integer(i4b), intent(in), optional :: band - integer(i4b), intent(in), optional :: pol - real(dp), dimension(1:), intent(in), optional :: theta - real(dp) :: evalSED_line - - integer(i4b) :: i, ind - - if (band == self%ref_band) then - evalSED_line = 1.d0 - else - do i = 1, self%npar - if (band == self%ind2band(i)) exit - end do - if (i > self%npar) then - evalSED_line = 0.d0 - else - evalSED_line = theta(i) * self%line2RJ(i) / self%line2RJ_ref - end if - end if - - end function evalSED_line - - subroutine read_line_template(filename, nline, label, mu, sigma, line2RJ, poltype) - implicit none - character(len=*), intent(in) :: filename - integer(i4b), intent(out) :: nline - character(len=512), allocatable, dimension(:), intent(out) :: label - real(dp), allocatable, dimension(:), intent(out) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:), intent(out) :: poltype - - integer(i4b) :: i, unit - character(len=1024) :: line - - unit = getlun() - - ! Find number of lines - nline = 0 - open(unit, file=trim(filename), recl=1024) - do while (.true.) - read(unit,'(a)', end=1) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - end do -1 close(unit) - - allocate(label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline)) - open(unit, file=trim(filename), recl=1024) - nline = 0 - do while (.true.) - read(unit,'(a)', end=2) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - read(line,*) label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline) - end do -2 close(unit) - - end subroutine read_line_template - - ! Sample line ratios - subroutine sampleLineRatios(self, cpar, handle, id, iter) - implicit none - class(comm_line_comp), intent(inout) :: self - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: id - integer(i4b), intent(in) :: iter !Gibbs iteration - - integer(i4b) :: i, j, l, n, m, band, ierr - real(dp) :: A, b, mu, sigma, par, sigma_p, scale, w - class(comm_map), pointer :: invN_amp, amp - character(len=2) :: id_text - - band = self%ind2band(id) - !if (band == self%ref_band) return - - - ! Compute likelihood term - w = self%theta(id)%p%map(1,1) - amp => comm_map(data(band)%info) - invN_amp => comm_map(data(band)%info) - amp%map = self%getBand(band)/w - invN_amp%map = amp%map - call data(band)%N%invN(invN_amp) ! Inverse noise variance weighted amplitude map - -!!$ call int2string(id, id_text) -!!$ call mask%writeFITS('co_mask'//id_text//'.fits') -!!$ call amp%writeFITS('co_amp'//id_text//'.fits') -!!$ call data(band)%res%writeFITS('co_res'//id_text//'.fits') -!!$ call data(band)%N%invN_diag%writeFITS('co_invN'//id_text//'.fits') - - ! Reduce across processors - if (associated(self%indmask(band)%p)) then - A = sum(invN_amp%map * self%indmask(band)%p%map * amp%map) - b = sum(invN_amp%map * self%indmask(band)%p%map * data(band)%res%map) - else - A = sum(invN_amp%map * amp%map) - b = sum(invN_amp%map * data(band)%res%map) - end if - call mpi_allreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - call mpi_allreduce(MPI_IN_PLACE, b, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - - call amp%dealloc(); deallocate(amp) - call invN_amp%dealloc(); deallocate(invN_amp) - - ! Compute new line ratio; just root processor - if (self%x%info%myid == 0) then - - if (A > 0.d0) then - mu = b / A - sigma = sqrt(1.d0 / A) - else if (self%p_gauss(2,id) > 0.d0) then - mu = 0.d0 - sigma = 1.d30 - else - mu = self%p_uni(1,id) + (self%p_uni(2,id)-self%p_uni(1,id))*rand_uni(handle) - sigma = 0.d0 - end if - - ! Add prior - if (self%p_gauss(2,id) > 0.d0) then - sigma_p = self%p_gauss(2,id) !/ sqrt(real(npix_reg,dp)) - mu = (mu*sigma_p**2 + self%p_gauss(1,id) * sigma**2) / (sigma_p**2 + sigma**2) - sigma = sqrt(sigma**2 * sigma_p**2 / (sigma**2 + sigma_p**2)) - end if - - ! Draw sample - par = -1.d300 - if (trim(self%operation) == 'optimize') then - if (mu < self%p_uni(1,id)) then - par = self%p_uni(1,id) - else if (mu > self%p_uni(2,id)) then - par = self%p_uni(2,id) - else - par = mu - end if - else - do while (par < self%p_uni(1,id) .or. par > self%p_uni(2,id)) - if (mu < self%p_uni(1,id)) then - par = rand_trunc_gauss(handle, mu, self%p_uni(1,id), sigma) - else if (mu > self%p_uni(2,id)) then - par = 2.d0*mu-rand_trunc_gauss(handle, mu, 2.d0*mu-self%p_uni(2,id), sigma) - else - par = mu + sigma * rand_gauss(handle) - end if - end do - end if - - if (band == self%ref_band) then - write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' - else - write(*,*) ' Line ratio i = ', id, ' = ', par - end if - end if - - ! Distribute new relative line ratio, and update - call mpi_bcast(par, 1, MPI_DOUBLE_PRECISION, 0, self%x%info%comm, ierr) - - if (band == self%ref_band) then - self%x%map = self%x%map * par ! Rescale amplitude map, but leave mixing matrix - self%x%alm = self%x%alm * par - do i = 1, self%npar ! Rescale line ratios at other frequencies - if (self%ind2band(i) == self%ref_band) cycle - self%theta(i)%p%map = self%theta(i)%p%map / par - if (self%lmax_ind >= 0) then - self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) / par - end if - end do - else - self%theta(id)%p%map = par - if (self%lmax_ind >= 0) then - self%theta(id)%p%alm(:,1) = par * sqrt(4.d0*pi) - end if - end if - call self%updateMixmat() - - end subroutine sampleLineRatios - -end module comm_line_comp_mod + use comm_comp_interface_mod + implicit none + + private + public comm_line_comp + + !************************************************** + ! Line emission component + !************************************************** + type, extends (comm_diffuse_comp) :: comm_line_comp + integer(i4b) :: ref_band + real(dp) :: line2RJ_ref + integer(i4b), allocatable, dimension(:) :: ind2band + real(dp), allocatable, dimension(:) :: line2RJ + contains + procedure :: S => evalSED_line + procedure :: sampleSpecInd => sampleLineRatios + procedure :: updateMixmat => updateMixmatLineRatios + end type comm_line_comp + + interface comm_line_comp + procedure constructor_line + end interface comm_line_comp + + contains + + !************************************************** + ! Routine definitions + !************************************************** + function constructor_line(cpar, id, id_abs) result(c) + implicit none + type(comm_params), intent(in) :: cpar + integer(i4b), intent(in) :: id, id_abs + class(comm_line_comp), pointer :: c + + integer(i4b) :: i, j, k, l, m, nline, b, n, ierr + real(dp) :: f + logical(lgt) :: ref_exist + character(len=512), allocatable, dimension(:) :: label + real(dp), allocatable, dimension(:) :: mu, sigma, line2RJ + integer(i4b), allocatable, dimension(:) :: poltype + type(comm_mapinfo), pointer :: info + + ! General parameters + allocate(c) + c%npar = 0 !temporary value so that lmax_ind is correcty set (to 0) in initDiffuse + call c%initDiffuse(cpar, id, id_abs) + + ! Read line template file + call read_line_template(trim(cpar%cs_SED_template(1,id_abs)), & + & nline, label, mu, sigma, line2RJ, poltype) + + ! Check how many lines are included in current run + n = 0 + ref_exist = .false. + do i = 1, numband + do j = 1, nline + if (trim(label(j)) == trim(data(i)%label)) n = n+1 + end do + if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) ref_exist = .true. + end do + if (.not. ref_exist) call report_error("Line component reference band does not exist, need "//trim(cpar%cs_band_ref(id_abs))) + + allocate(c%ind2band(n)) + c%npar = n + + allocate(c%lmax_ind_pol(3,c%npar)) + c%lmax_ind_pol = 0 !always fullsky (lmax=0) for line component + if (allocated(c%lmax_ind_mix)) deallocate(c%lmax_ind_mix) + allocate(c%lmax_ind_mix(3,c%npar)) + c%lmax_ind_mix = 0 !always fullsky (lmax=0) for line component + allocate(c%pol_pixreg_type(3,c%npar)) + c%pol_pixreg_type = 0 + + allocate(c%theta_def(n), c%p_gauss(2,n), c%p_uni(2,n)) + allocate(c%poltype(n), c%indlabel(n), c%line2RJ(n)) + n = 0 + do i = 1, numband + do j = 1, nline + if (trim(label(j)) == trim(data(i)%label)) then + n = n+1 + c%ind2band(n) = i + c%theta_def(n) = mu(j) + c%p_gauss(1,n) = mu(j) + c%p_gauss(2,n) = sigma(j) + c%p_uni(1,n) = -100.d30 !mu(j)-5*sigma(j) + c%p_uni(2,n) = 100.d30 !mu(j)+5*sigma(j) + c%poltype(n) = poltype(j) + c%indlabel(n) = label(j) + c%line2RJ(n) = line2RJ(j) + exit + end if + end do + if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) then + c%ref_band = i + c%line2RJ_ref = c%line2RJ(n) + end if + end do + + ! Update reference band unit conversion + do i = 1, c%x%info%nmaps + c%RJ2unit_(i) = 1.d0 / c%line2RJ_ref + c%x%map(:,i) = c%x%map(:,i) / c%RJ2unit_(i) + c%x%alm(:,i) = c%x%alm(:,i) / c%RJ2unit_(i) + end do + + ! Initialize spectral index maps + info => comm_mapinfo(cpar%comm_chain, c%nside, c%lmax_ind, & + & c%nmaps, c%pol) + + allocate(c%theta(n)) + do i = 1, n + c%theta(i)%p => comm_map(info) + c%theta(i)%p%map = c%theta_def(i) + if (c%lmax_ind >= 0) call c%theta(i)%p%YtW_scalar + end do + + + ! Precompute mixmat integrator for each band + allocate(c%F_int(3,numband,0:c%ndet)) + j = 1 + do l = 1, 3 + do i = 1, numband + if (l > 1) then + do m = 0,c%ndet + c%F_int(l,i,m)%p => c%F_int(l-1,i,m)%p + end do + cycle + end if + if (any(c%ind2band == i)) then + do k = 0, data(i)%ndet + ! write(*,*) 'line disabled' + c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & + & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) + end do + j = j+1 + else + do k = 0, data(i)%ndet + ! write(*,*) 'line disabled' + c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .false., 0.d0, j) + end do + end if + end do + end do + + ! Initialize mixing matrix + if (trim(cpar%init_chain_prefix) == 'none' & + & .or. trim(c%init_from_HDF) == 'none') & + & call c%updateMixmat + + deallocate(label, mu, sigma, line2RJ, poltype) + + end function constructor_line + + ! Definition: + ! SED = delta_{band, + function evalSED_line(self, nu, band, pol, theta) + class(comm_line_comp), intent(in) :: self + real(dp), intent(in), optional :: nu + integer(i4b), intent(in), optional :: band + integer(i4b), intent(in), optional :: pol + real(dp), dimension(1:), intent(in), optional :: theta + real(dp) :: evalSED_line + + integer(i4b) :: i, ind + + if (band == self%ref_band) then + evalSED_line = 1.d0 + else + do i = 1, self%npar + if (band == self%ind2band(i)) exit + end do + if (i > self%npar) then + evalSED_line = 0.d0 + else + evalSED_line = theta(i) * self%line2RJ(i) / self%line2RJ_ref + end if + end if + + end function evalSED_line + + subroutine read_line_template(filename, nline, label, mu, sigma, line2RJ, poltype) + implicit none + character(len=*), intent(in) :: filename + integer(i4b), intent(out) :: nline + character(len=512), allocatable, dimension(:), intent(out) :: label + real(dp), allocatable, dimension(:), intent(out) :: mu, sigma, line2RJ + integer(i4b), allocatable, dimension(:), intent(out) :: poltype + + integer(i4b) :: i, unit + character(len=1024) :: line + + unit = getlun() + + ! Find number of lines + nline = 0 + open(unit, file=trim(filename), recl=1024) + do while (.true.) + read(unit,'(a)', end=1) line + line = trim(adjustl(line)) + if (line(1:1) == '#') cycle + nline = nline+1 + end do + 1 close(unit) + + allocate(label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline)) + open(unit, file=trim(filename), recl=1024) + nline = 0 + do while (.true.) + read(unit,'(a)', end=2) line + line = trim(adjustl(line)) + if (line(1:1) == '#') cycle + nline = nline+1 + read(line,*) label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline) + end do + 2 close(unit) + + end subroutine read_line_template + + ! Sample line ratios + subroutine sampleLineRatios(self, cpar, handle, id, iter) + implicit none + class(comm_line_comp), intent(inout) :: self + type(comm_params), intent(in) :: cpar + type(planck_rng), intent(inout) :: handle + integer(i4b), intent(in) :: id + integer(i4b), intent(in) :: iter !Gibbs iteration + + integer(i4b) :: i, j, l, n, m, band, ierr + real(dp) :: A, b, mu, sigma, par, sigma_p, scale, w + class(comm_map), pointer :: invN_amp, amp + character(len=2) :: id_text + + band = self%ind2band(id) + !if (band == self%ref_band) return + + + ! Compute likelihood term + w = self%theta(id)%p%map(1,1) + amp => comm_map(data(band)%info) + invN_amp => comm_map(data(band)%info) + amp%map = self%getBand(band)/w + invN_amp%map = amp%map + call data(band)%N%invN(invN_amp) ! Inverse noise variance weighted amplitude map + + !!$ call int2string(id, id_text) + !!$ call mask%writeFITS('co_mask'//id_text//'.fits') + !!$ call amp%writeFITS('co_amp'//id_text//'.fits') + !!$ call data(band)%res%writeFITS('co_res'//id_text//'.fits') + !!$ call data(band)%N%invN_diag%writeFITS('co_invN'//id_text//'.fits') + + ! Reduce across processors + if (associated(self%indmask(band)%p)) then + A = sum(invN_amp%map * self%indmask(band)%p%map * amp%map) + b = sum(invN_amp%map * self%indmask(band)%p%map * data(band)%res%map) + else + A = sum(invN_amp%map * amp%map) + b = sum(invN_amp%map * data(band)%res%map) + end if + call mpi_allreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) + call mpi_allreduce(MPI_IN_PLACE, b, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) + + call amp%dealloc(); deallocate(amp) + call invN_amp%dealloc(); deallocate(invN_amp) + + ! Compute new line ratio; just root processor + if (self%x%info%myid == 0) then + + if (A > 0.d0) then + mu = b / A + sigma = sqrt(1.d0 / A) + else if (self%p_gauss(2,id) > 0.d0) then + mu = 0.d0 + sigma = 1.d30 + else + mu = self%p_uni(1,id) + (self%p_uni(2,id)-self%p_uni(1,id))*rand_uni(handle) + sigma = 0.d0 + end if + + ! Add prior + if (self%p_gauss(2,id) > 0.d0) then + sigma_p = self%p_gauss(2,id) !/ sqrt(real(npix_reg,dp)) + mu = (mu*sigma_p**2 + self%p_gauss(1,id) * sigma**2) / (sigma_p**2 + sigma**2) + sigma = sqrt(sigma**2 * sigma_p**2 / (sigma**2 + sigma_p**2)) + end if + + ! Draw sample + par = -1.d300 + if (trim(self%operation) == 'optimize') then + if (mu < self%p_uni(1,id)) then + par = self%p_uni(1,id) + else if (mu > self%p_uni(2,id)) then + par = self%p_uni(2,id) + else + par = mu + end if + else + do while (par < self%p_uni(1,id) .or. par > self%p_uni(2,id)) + if (mu < self%p_uni(1,id)) then + par = rand_trunc_gauss(handle, mu, self%p_uni(1,id), sigma) + else if (mu > self%p_uni(2,id)) then + par = 2.d0*mu-rand_trunc_gauss(handle, mu, 2.d0*mu-self%p_uni(2,id), sigma) + else + par = mu + sigma * rand_gauss(handle) + end if + end do + end if + + if (band == self%ref_band) then + write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' + else + write(*,*) ' Line ratio i = ', id, ' = ', par + end if + end if + + ! Distribute new relative line ratio, and update + call mpi_bcast(par, 1, MPI_DOUBLE_PRECISION, 0, self%x%info%comm, ierr) + + if (band == self%ref_band) then + self%x%map = self%x%map * par ! Rescale amplitude map, but leave mixing matrix + self%x%alm = self%x%alm * par + do i = 1, self%npar ! Rescale line ratios at other frequencies + if (self%ind2band(i) == self%ref_band) cycle + self%theta(i)%p%map = self%theta(i)%p%map / par + if (self%lmax_ind >= 0) then + self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) / par + end if + end do + else + self%theta(id)%p%map = par + if (self%lmax_ind >= 0) then + self%theta(id)%p%alm(:,1) = par * sqrt(4.d0*pi) + end if + end if + call self%updateMixmat() + + end subroutine sampleLineRatios + + + ! update the mixing matrix, assumes only temperature and constant across the whole map + + subroutine updateMixmatLineRatios(self, theta, beta, band, df, par) + implicit none + class(comm_line_comp), intent(inout) :: self + class(comm_map), dimension(:), intent(in), optional :: theta + real(dp), dimension(:,:,:), intent(in), optional :: beta ! Not used here + integer(i4b), intent(in), optional :: band + class(map_ptr), dimension(:), intent(inout), optional :: df ! Derivative of mixmat with respect to parameter par; for Jeffreys prior + integer(i4b), intent(in), optional :: par ! Parameter ID for derivative + + + integer(i4b) :: i, j, l, p, nmaps, ierr !,checkv, p_min, p_max, n, k, + real(dp) :: t1, t2 !lat, lon, + logical(lgt) :: mixmatnull ! NEW ,only_pol, , bad, precomp, + ! character(len=2) :: ctext + real(dp), allocatable, dimension(:) :: buffer, buff2, theta_p_v ! s, nu, + class(comm_mapinfo), pointer :: info => null() !, info_tp => null() + ! class(map_ptr), allocatable, dimension(:) :: theta_prev + + ! call wall_time(t1) + if (trim(self%type) == 'md') return + + call update_status(status, "mixupdate1 " // trim(self%label)) + + ! Copy over alms from input structure, and compute pixel-space parameter maps + if (present(theta)) then + do i = 1, self%npar + ! write(*,*) 'Check 1' + self%theta(i)%p%alm = theta(i)%alm + end do + end if + + + ! Compute mixing matrix + do i = 1, numband + + ! Only update requested band if present + if (present(band)) then + if (i /= band) cycle + end if + + ! Compute spectral parameters at the correct resolution for this channel + ! only temperature can have a monopole, doesn't make sense for polarization - check with HKE and others about + ! procedure going forwards + if (self%npar > 0) then + nmaps = min(data(i)%info%nmaps, self%theta(1)%p%info%nmaps) + allocate(theta_p_v(self%npar)) + do j = 1,self%npar + ! if self%theta(j)%p%info%lmax=0 constant on the sky + theta_p_v(j) = self%theta(j)%p%alm(0,1)/sqrt(4.0d0*pi) + end do + end if + ! write(*,*) 'id', self%x%info%myid + + call mpi_bcast(theta_p_v,size(theta_p_v),MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr) + + do l = 0, data(i)%ndet + if (self%F_null(i,l)) then + if (present(df)) df(i)%p%map = 0.d0 + cycle + end if + + if (data(i)%comp_sens == "broadband") then + ! If broadband, calculate mixing matrix + mixmatnull = .false. + else + ! If component sensitivity, only calculate mixmat on that component. + mixmatnull = .true. + If (data(i)%comp_sens == self%label) then + mixmatnull = .false. + end if + end if + + ! Temperature + if (self%npar > 0) then + if (mixmatnull) then + self%F(i,l)%p%map(:,1) = 0.0 + else + self%F(i,l)%p%map(:,1) = self%F_int(1,i,l)%p%eval(theta_p_v(:)) * data(i)%gain * self%cg_scale(1) + ! if (self%x%info%myid==0 .or. self%x%info%myid==1) then + ! write(*,*) 'Check inside core', self%x%info%myid + ! end if + end if + else + if (mixmatnull) then + self%F(i,l)%p%map(:,1) = 0.0 + else + self%F(i,l)%p%map(:,1) = self%F_int(1,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(1) + end if + end if + + + + allocate(buffer(self%nmaps), buff2(self%nmaps)) + do j = 1, min(self%nmaps, data(i)%info%nmaps) + self%F_mean(i,l,j) = sum(self%F(i,l)%p%map(:,j)) + end do + buff2 = self%F_mean(i,l,:) + !call mpi_barrier(mpi_comm_world, ierr) + call mpi_allreduce(buff2, buffer, self%nmaps, & + & MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) + self%F_mean(i,l,:) = buffer / self%F(i,l)%p%info%npix + deallocate(buffer,buff2) + + end do + if (allocated(theta_p_v)) deallocate(theta_p_v) + end do + + call update_status(status, "mixupdate2 " // trim(self%label)) + + ! Request preconditioner update + recompute_diffuse_precond = .true. + + ! call wall_time(t2) + ! if (self%x%info%myid == 0) write(*,*) ' Update line ratio mixing matrix time = ', t2-t1 + + end subroutine updateMixmatLineRatios + + + + + end module comm_line_comp_mod + + + \ No newline at end of file From 2188fac0716f8b8fce277b7c391d3af71b416150 Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Tue, 18 Mar 2025 10:20:24 +0100 Subject: [PATCH 139/171] Python files to extend HFI beams and produce HFI comp. separation default files (not TOD) --- commander3/python/HFIDefaultsGenerator.py | 241 ++++++++++++++++++++++ commander3/python/extend_beams.py | 53 +++++ 2 files changed, 294 insertions(+) create mode 100644 commander3/python/HFIDefaultsGenerator.py create mode 100644 commander3/python/extend_beams.py diff --git a/commander3/python/HFIDefaultsGenerator.py b/commander3/python/HFIDefaultsGenerator.py new file mode 100644 index 000000000..3eb869c7f --- /dev/null +++ b/commander3/python/HFIDefaultsGenerator.py @@ -0,0 +1,241 @@ +import os + +### Function definitions +def checkFileExists(files, folder=''): + """Check if a single file or a list of files exist in the specified folder.""" + if isinstance(files, str): + files = [files] + for file in files: + if not os.path.isfile(f"{folder}{file}"): + print(f"File {file} is not in {folder}") + +def write2v(f, textv, val, dim, i, j): + """Write formatted parameter values to a file.""" + if dim == 0: + f.write(f"{textv.ljust(35)}= {val}\n") + elif dim == 1: + f.write(f"{textv.ljust(35)}= {val[i]}\n") + elif dim == 2: + f.write(f"{textv.ljust(35)}= {val[i][j]}\n") + else: + print("Error: Dim should be 1, 2, or 3") + + +# Parameters that are the same for all the HFI bands (across frequency and horns) should have +# param_name_v=0 to tell the file generator that there is a single value for all bands, if +# there are different values for different frequencies change to param_name_v=1 and if +# it is unique for each horn param_name_v=2 +# This is used for 'dim' (dimension) in write2v + + +# Formatting parameters +data_folder = '/mn/stornext/d23/cmbco/cg/hfi/data/' +eqsig = "&&&" +debug = True # Enable file existence checks + +# Save folder for default files +homedir='/mn/stornext/u3/raelynsu/code/' +param_folder = homedir+"Commander/commander3/parameter_files/defaults/bands/HFI/" + +# Frequency-related parameters +## BAND_NOMINAL_FREQ +nomfreqs = [100, 143, 217, 353, 545, 857] +nomfreqs_v = 1 +##BAND_NSIDE +nsides = [2048, 2048, 4096, 4096, 4096, 4096] +nsides_v = 1 +##BAND_LMAX +lmaxs = [6000, 6000, 10000, 10000, 10000, 10000] +lmaxs_v = 1 + + +# File names for pixel window functions +band_pixel_window = [f"pixel_window_n{n}.fits" for n in nsides] +band_pixel_window_v = 1 + +if debug: + checkFileExists(band_pixel_window,folder=data_folder) + # checkFileExists(band_beam_b_l_file,folder=data_folder) + + +# Data paths for individual horns +common_folder = "/mn/stornext/d23/cmbco/globe/fullres/planck/" +maps_folder, rms_folder, hit_folder = "map/map_", "rms/rms_", "mask/hitmask_" +common_string3 = "_fullres_full_T.fits" + +band_label_v=2 +band_mapfile_v=2 +band_noisefile_v=2 +band_bandpassfile_v=2 +band_maskfile_v=2 + +# Horn configurations +band_arr = [ + ['-1', '-2', '-3', '-4'], # 100 GHz + ['-1', '-2', '-3', '-4', '-5', '-6', '-7'], # 143 GHz + ['-1', '-2', '-3', '-4', '-5', '-6', '-7', '-8'], # 217 GHz + ['-1', '-2', '-3', '-4', '-5', '-6', '-7', '-8'], # 353 GHz + ['-1', '-2', '-4'], # 545 GHz + ['-1', '-2', '-3', '-4'] # 857 GHz +] + + +# Initialize band-specific lists +band_label, band_mapfile, band_noisefile, band_bandpassfile, band_maskfile,band_beam_b_l_file = [], [], [], [], [], [] + +##bandpass name changes for different horns +v1='_SHORN.dat' +v2='.dat' +bp_extra=[[v1,v1,v1,v1], + [v1,v1,v1,v1,v2,v2,v2], + [v2,v2,v2,v2,v1,v1,v1,v1], + [v2,v2,v1,v1,v1,v1,v2,v2], + [v2,v2,v2], + [v2,v2,v2,v2]] + +for i in range(len(nomfreqs)): + b_lab = [str(nomfreqs[i]) + h for h in band_arr[i]] + band_label.append(b_lab) + + common_string2 = f"_npipe_0{nsides[i]}" + map_file = [f"{common_folder}{maps_folder}planck_{b}{common_string2}{common_string3}" for b in b_lab] + rms_file = [f"{common_folder}{rms_folder}planck_{b}{common_string2}{common_string3}" for b in b_lab] + hit_file = [f"{common_folder}{hit_folder}planck_{b}{common_string2}{common_string3}" for b in b_lab] + band_mapfile.append(map_file) + band_noisefile.append(rms_file) + band_maskfile.append(hit_file) + + bpfile = [f"bp_RIMO_v2.0_{b}{bp}" for b, bp in zip(b_lab, bp_extra[i])] + band_bandpassfile.append(bpfile) + + band_beam_b_l= [f"Bl_npipe6v20_{f}x{f}_extended.fits" for f in b_lab] + band_beam_b_l_file.append(band_beam_b_l) + + if debug: + checkFileExists(map_file) + checkFileExists(rms_file) + checkFileExists(hit_file) + checkFileExists(bpfile,folder=data_folder) + checkFileExists(band_beam_b_l_file,folder=data_folder) + + + +band_instrument_label=band_label +band_instrument_label_v=2 +band_beam_b_l_file_v = 2 + +###constant for all HFI currently +band_obs_period='1' +band_obs_period_v=0 +band_polarization='.false.' +band_polarization_v=0 + +band_unit='uK_cmb' +band_unit_v=0 +band_noise_format='rms' +band_noise_format_v=0 +band_reg_noisefile='none' +band_reg_noisefile_v=0 +band_noise_uniformize_fsky='0.01' +band_noise_uniformize_fsky_v=0 +band_maskfile_calib='fullsky' +band_maskfile_calib_v=0 +band_beamtype='b_l' # {b_l, febecop} +band_beamtype_v=0 +band_beam_b_ptsrc_file='none' +band_beam_b_ptsrc_file_v=0 +band_sample_noise_amp='.false.' +band_sample_noise_amp_v=0 + +band_bandpass_type='HFI_cmb' +band_bandpass_type_v=0 +band_bandpass_model='additive_shift' # {powlaw_tilt, additive_shift} +band_bandpass_model_v=0 + +band_samp_bandpass='.false' +band_samp_bandpass_v=0 +band_samp_gain='.false.' +band_samp_gain_v=0 +band_gain_prior_mean='1.' +band_gain_prior_mean_v=0 +band_gain_prior_rms='0.' +band_gain_prior_rms_v=0 +band_gain_calib_comp='all' #all or cmb +band_gain_calib_comp_v=0 +band_gain_lmin='25' +band_gain_lmin_v=0 +band_gain_lmax='100' +band_gain_lmax_v=0 +band_gain_apod_mask='fullsky' +band_gain_apod_mask_v=0 +band_gain_apod_fwhm='120.' +band_gain_apod_fwhm_v=0 +band_default_gain='1.' +band_default_gain_v=0 +band_default_bp_delta='0.' +band_default_bp_delta_v=0 +band_default_noiseamp='1.' +band_default_noiseamp_v=0 +band_component_sensitivity='broadband' +band_component_sensitivity_v=0 +band_tod_type='none' +band_tod_type_v=0 +band_noise_rms_sm1='none' +band_noise_rms_sm1_v=0 +band_noise_rms_sm2='none' +band_noise_rms_sm2_v=0 +band_noise_rms_sm3='none' +band_noise_rms_sm3_v=0 + +# band= +# band_v= +# '' + + +for i in range(len(nomfreqs)): + for j in range(len(band_arr[i])): + f = open(f"{param_folder}HFI_{nomfreqs[i]}{band_arr[i][j]}_HFI.defaults",'w') ##will overwrite exiting files + f.write(f"# {nomfreqs[i]}{band_arr[i][j]} GHz map parameters \n") + write2v(f,'BAND_LABEL'+eqsig,band_label,band_label_v,i,j) + write2v(f,'BAND_INSTRUMENT_LABEL'+eqsig,band_instrument_label,band_instrument_label_v,i,j) + write2v(f,'BAND_OBS_PERIOD'+eqsig,band_obs_period,band_obs_period_v,i,j) + write2v(f,'BAND_POLARIZATION'+eqsig,band_polarization,band_polarization_v,i,j) + write2v(f,'BAND_NSIDE'+eqsig,nsides,nsides_v,i,j) + write2v(f,'BAND_LMAX'+eqsig,lmaxs,lmaxs_v,i,j) + write2v(f,'BAND_UNIT'+eqsig,band_unit,band_unit_v,i,j) + write2v(f,'BAND_NOISE_FORMAT'+eqsig,band_noise_format,band_noise_format_v,i,j) + write2v(f,'BAND_MAPFILE'+eqsig,band_mapfile,band_mapfile_v,i,j) + write2v(f,'BAND_NOISEFILE'+eqsig,band_noisefile,band_noisefile_v,i,j) + write2v(f,'BAND_REG_NOISEFILE'+eqsig,band_reg_noisefile,band_reg_noisefile_v,i,j) + write2v(f,'BAND_NOISE_UNIFORMIZE_FSKY'+eqsig,band_noise_uniformize_fsky,band_noise_uniformize_fsky_v,i,j) + write2v(f,'BAND_MASKFILE'+eqsig,band_maskfile,band_maskfile_v,i,j) + write2v(f,'BAND_MASKFILE_CALIB'+eqsig,band_maskfile_calib,band_maskfile_calib_v,i,j) + write2v(f,'BAND_BEAMTYPE'+eqsig,band_beamtype,band_beamtype_v,i,j) + write2v(f,'BAND_BEAM_B_L_FILE'+eqsig,band_beam_b_l_file,band_beam_b_l_file_v,i,j) + write2v(f,'BAND_BEAM_B_PTSRC_FILE'+eqsig,band_beam_b_ptsrc_file,band_beam_b_ptsrc_file_v,i,j) + write2v(f,'BAND_PIXEL_WINDOW'+eqsig,band_pixel_window,band_pixel_window_v,i,j) + write2v(f,'BAND_SAMP_NOISE_AMP'+eqsig,band_sample_noise_amp,band_sample_noise_amp_v,i,j) + write2v(f,'BAND_BANDPASS_TYPE'+eqsig,band_bandpass_type,band_bandpass_type_v,i,j) + write2v(f,'BAND_BANDPASS_MODEL'+eqsig,band_bandpass_model,band_bandpass_model_v,i,j) + write2v(f,'BAND_NOMINAL_FREQ'+eqsig,nomfreqs,nomfreqs_v,i,j) + write2v(f,'BAND_SAMP_BANDPASS'+eqsig,band_samp_bandpass,band_samp_bandpass_v,i,j) + write2v(f,'BAND_BANDPASSFILE'+eqsig,band_bandpassfile,band_bandpassfile_v,i,j) + write2v(f,'BAND_SAMP_GAIN'+eqsig,band_samp_gain,band_samp_gain_v,i,j) + write2v(f,'BAND_GAIN_PRIOR_MEAN'+eqsig,band_gain_prior_mean,band_gain_prior_mean_v,i,j) + write2v(f,'BAND_GAIN_PRIOR_RMS'+eqsig,band_gain_prior_mean,band_gain_prior_mean_v,i,j) + write2v(f,'BAND_GAIN_CALIB_COMP'+eqsig,band_gain_calib_comp,band_gain_calib_comp_v,i,j) + write2v(f,'BAND_GAIN_LMIN'+eqsig,band_gain_lmin,band_gain_lmin_v,i,j) + write2v(f,'BAND_GAIN_LMAX'+eqsig,band_gain_lmax,band_gain_lmax_v,i,j) + write2v(f,'BAND_GAIN_APOD_MASK'+eqsig,band_gain_apod_mask,band_gain_apod_mask_v,i,j) + write2v(f,'BAND_GAIN_APOD_FWHM'+eqsig,band_gain_apod_fwhm,band_gain_apod_fwhm_v,i,j) + write2v(f,'BAND_DEFAULT_GAIN'+eqsig,band_default_gain,band_default_gain_v,i,j) + write2v(f,'BAND_DEFAULT_BP_DELTA'+eqsig,band_default_bp_delta,band_default_bp_delta_v,i,j) + write2v(f,'BAND_DEFAULT_NOISEAMP'+eqsig,band_default_noiseamp,band_default_noiseamp_v,i,j) + write2v(f,'BAND_COMPONENT_SENSITIVITY'+eqsig,band_component_sensitivity,band_component_sensitivity_v,i,j) + write2v(f,'BAND_TOD_TYPE'+eqsig,band_tod_type,band_tod_type_v,i,j) + write2v(f,'BAND_NOISE_RMS'+eqsig+'_SMOOTH01',band_noise_rms_sm1,band_noise_rms_sm1_v,i,j) + write2v(f,'BAND_NOISE_RMS'+eqsig+'_SMOOTH02',band_noise_rms_sm2,band_noise_rms_sm2_v,i,j) + write2v(f,'BAND_NOISE_RMS'+eqsig+'_SMOOTH03',band_noise_rms_sm3,band_noise_rms_sm3_v,i,j) + f.close() + + \ No newline at end of file diff --git a/commander3/python/extend_beams.py b/commander3/python/extend_beams.py new file mode 100644 index 000000000..f3d16f281 --- /dev/null +++ b/commander3/python/extend_beams.py @@ -0,0 +1,53 @@ +import healpy as hp +import numpy as np + + + +def extend_beam(bl,fwhm,lmax_bl,lmax_trans,lmax_gauss): + ''' + bl - the original beam function + fwhm - the fwhm of the extended beam Gaussian in arcmin + lmax_bl - the lmax from the original beam + lmax_trans - the lmax of the transition from the original beam to the Gaussian beam + lmax_gauss - the lmax of the extended beam + ''' + #generate the gaussian beam and empty array for the extended beam + gl=hp.gauss_beam(np.deg2rad(fwhm/60),lmax=lmax_gauss) + bl_ext=np.zeros(lmax_gauss+1) + #rescale so that the start of the Gaussian beam is the same value as the end of the original beam + gl=(gl/(gl[lmax_bl]))*bl[lmax_bl] + #set the lowest ell equal to the original beam, and the highest ell to a pure gaussian beam + bl_ext[0:lmax_bl]=bl[0:lmax_bl] + bl_ext[lmax_trans:]=gl[lmax_trans:] + #calculate and apply apodization function between orginal and fully Gaussian beams + ell=np.arange(lmax_bl,lmax_trans) + apod=0.5*(1+np.cos(np.pi*(lmax_trans-ell)/(lmax_trans-lmax_bl))) + bl_ext[lmax_bl:lmax_trans]=gl[lmax_bl:lmax_trans]*apod+bl[lmax_bl:lmax_trans]*(1-apod) + + bl_ext/=bl_ext[0] + return bl_ext + +freq=np.array([100,143,217,353,545,857]) +freq_arr=[[1,2,3,4], + [1,2,3,4,5,6,7], + [1,2,3,4,5,6,7,8], + [1,2,3,4,5,6,7,8], + [1,2,4], + [1,2,3,4]] + +fwhm=np.array([9.659, 7.22, 4.9, 4.916, 4.675, 4.216]) ##from the FWHMGAUS in the HFI_RIMO_R3.00.fits +lmax_trans=np.array([2200,3000,5200,5500,4300,4300]) ##chosen by eye such that the original beam is still smooth +lmax_bl=lmax_trans-100 +lmax_gauss=10000 + +folder='/mn/stornext/u3/raelynsu/d23hfi/data/Bl_npipe6v20_' +#353-7x353-7.fits' + +for i in range(len(freq)): + for j in range(len(freq_arr[i])): + strv=str(freq[i])+'-'+str(freq_arr[i][j]) + bl=hp.read_cl(folder+strv+'x'+strv+'.fits') + bl_ext=extend_beam(bl,fwhm[i],lmax_bl[i],lmax_trans[i],lmax_gauss) + hp.write_cl(folder+strv+'x'+strv+'_extended.fits',bl_ext,overwrite=True) + + From 5f43bd584d3861e10e8ac9f5b3d625fd75fbf696 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Tue, 18 Mar 2025 16:00:03 +0100 Subject: [PATCH 140/171] first running polarized HFI 100 GHz maps --- commander3/src/comm_tod_driver_mod.f90 | 15 +- commander3/src/comm_tod_hfi_mod.f90 | 1 + commander3/src/comm_tod_mapmaking_mod.f90 | 169 ++++++++++++++++++++-- commander3/src/comm_tod_mod.f90 | 68 ++++++--- 4 files changed, 214 insertions(+), 39 deletions(-) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 3ad8ae87b..e706ed6cc 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -629,7 +629,6 @@ subroutine dealloc_det_data(dd) if (allocated(dd%scans)) deallocate(dd%scans) if (allocated(dd%ntod)) deallocate(dd%ntod) if (allocated(dd%tod)) deallocate(dd%tod) - end subroutine dealloc_det_data ! initializes a det_data structure for a single detector over the entire flight @@ -640,7 +639,15 @@ subroutine init_det_data_singlehorn(dd, tod, det) class(comm_tod), intent(inout) :: tod integer(i4b), intent(in) :: det + integer(i4b) :: i + + dd%nscan = tod%nscan + allocate(dd%ntod(dd%nscan)) + do i = 1, tod%nscan + ! decompress tod into dd%tod array + dd%ntod(i) = tod%scans(i)%ntod + end do end subroutine init_det_data_singlehorn @@ -656,6 +663,8 @@ subroutine populate_sd_from_dd(sd, dd, scan, det) integer(i4b), intent(in) :: scan integer(i4b), intent(in) :: det + allocate(sd%tod(det, dd%ntod(scan))) + allocate(sd%s_inst(det, dd%ntod(scan))) end subroutine populate_sd_from_dd @@ -940,12 +949,12 @@ subroutine remove_bad_data(tod, scan, flag) if (.not. tod%scans(scan)%d(j)%accept) cycle if (count(iand(flag(:,j),tod%flag0) .ne. 0) > tod%accept_threshold*ntod) then ! Discard scans with less than 20% good data tod%scans(scan)%d(j)%accept = .false. - write(*, fmt='(a, i4, a, i8, a, i8)') ' | Reject scan = ', & + write(*, fmt='(a, i, a, i8, a, i8)') ' | Reject scan = ', & & tod%scanid(scan), ': ', count(iand(flag(:,j),tod%flag0) .ne. 0), & & ' flagged data out of', ntod else if (abs(tod%scans(scan)%d(j)%chisq) > tod%chisq_threshold .or. & ! Discard scans with high chisq or NaNs & isNaN(tod%scans(scan)%d(j)%chisq)) then - write(*,fmt='(a,i8,i5,a,f12.1)') ' | Reject scan, det = ', & + write(*,fmt='(a,i,i5,a,f12.1)') ' | Reject scan, det = ', & & tod%scanid(scan), j, ', chisq = ', tod%scans(scan)%d(j)%chisq tod%scans(scan)%d(j)%accept = .false. end if diff --git a/commander3/src/comm_tod_hfi_mod.f90 b/commander3/src/comm_tod_hfi_mod.f90 index b0f1724e9..8064d48de 100644 --- a/commander3/src/comm_tod_hfi_mod.f90 +++ b/commander3/src/comm_tod_hfi_mod.f90 @@ -149,6 +149,7 @@ end subroutine process_hfi_tod module subroutine sample_hfi_baselines(self, tod, scan, handle, subtract_s_tot) + ! ! Estimates baselines for MODULATED data, separate for odd and even samples ! diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index 03ec0d14e..d1e1dfd52 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -26,7 +26,7 @@ module comm_tod_mapmaking_mod type comm_binmap integer(i4b) :: ncol, n_A, nout, nobs, npix, numprocs_shared, chunk_size - logical(lgt) :: shared, solve_S + logical(lgt) :: shared, solve_S, solve_nplus2 type(shared_2d_dp) :: sA_map type(shared_3d_dp) :: sb_map class(map_ptr), allocatable, dimension(:) :: outmaps @@ -40,11 +40,12 @@ module comm_tod_mapmaking_mod contains - subroutine init_binmap(self, tod, shared, solve_S) + subroutine init_binmap(self, tod, shared, solve_S, nplus2) implicit none - class(comm_binmap), intent(inout) :: self - class(comm_tod), intent(in) :: tod - logical(lgt), intent(in) :: shared, solve_S + class(comm_binmap), intent(inout) :: self + class(comm_tod), intent(in) :: tod + logical(lgt), intent(in) :: shared, solve_S + logical(lgt), optional, intent(in) :: nplus2 integer(i4b) :: i, ierr @@ -55,11 +56,26 @@ subroutine init_binmap(self, tod, shared, solve_S) self%npix = tod%info%npix self%numprocs_shared = tod%numprocs_shared self%chunk_size = self%npix/self%numprocs_shared + self%solve_nplus2 = .false. + if(present(nplus2)) self%solve_nplus2 = nplus2 + if (solve_S) then + if(self%solve_nplus2) then + write(*,*) "Cannot solve for spurious maps and n+2 mapmaking" + stop + end if self%ncol = tod%nmaps + tod%ndet - 1 self%n_A = tod%nmaps*(tod%nmaps+1)/2 + 4*(tod%ndet-1) self%nout = tod%output_n_maps + tod%n_bp_prop !write(*,*) 'hei!', size(tod%bp_delta,2) + else if(self%solve_nplus2) then + if(tod%nmaps /= 3) then + write(*,*) "Cannot use n+2 mapmaking for nmaps=", tod%nmaps + stop + end if + self%ncol = tod%nmaps + tod%ndet - 1 + self%n_A = 3*tod%ndet + 3 + self%nout = tod%output_n_maps + tod%ndet-1 else self%ncol = tod%nmaps self%n_A = tod%nmaps*(tod%nmaps+1)/2 @@ -186,7 +202,8 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) nout = size(data,1) do det = 1, size(pix,2) ! loop over all the detectors if (.not. tod%scans(scan)%d(det)%accept) cycle - off = 6 + 4*(det-1) + off = tod%output_n_maps + 4*(det-1) + if(binmap%solve_nplus2) off = tod%output_n_maps *(det-1) inv_sigmasq = (tod%scans(scan)%d(det)%gain/tod%scans(scan)%d(det)%N_psd%sigma0)**2 do t = 1, size(pix,1) @@ -195,18 +212,27 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) pix_ = tod%pix2ind(pix(t,det)) ! pixel index for pix t and detector det psi_ = psi(t,det) - binmap%A_map(1,pix_) = binmap%A_map(1,pix_) + 1.d0 * inv_sigmasq + if((.not. binmap%solve_nplus2) .or. det == 1) then + binmap%A_map(1,pix_) = binmap%A_map(1,pix_) + 1.d0 * inv_sigmasq + end if if(tod%nmaps > 1) then - binmap%A_map(2,pix_) = binmap%A_map(2,pix_) + tod%cos2psi(psi_) * inv_sigmasq + if((.not. binmap%solve_nplus2) .or. det == 1) then + binmap%A_map(2,pix_) = binmap%A_map(2,pix_) + tod%cos2psi(psi_) * inv_sigmasq + binmap%A_map(4,pix_) = binmap%A_map(4,pix_) + tod%sin2psi(psi_) * inv_sigmasq + end if + binmap%A_map(3,pix_) = binmap%A_map(3,pix_) + tod%cos2psi(psi_)**2 * inv_sigmasq - binmap%A_map(4,pix_) = binmap%A_map(4,pix_) + tod%sin2psi(psi_) * inv_sigmasq binmap%A_map(5,pix_) = binmap%A_map(5,pix_) + tod%cos2psi(psi_)*tod%sin2psi(psi_) * inv_sigmasq binmap%A_map(6,pix_) = binmap%A_map(6,pix_) + tod%sin2psi(psi_)**2 * inv_sigmasq !binmap%A_map(1,pix_) = binmap%A_map(8,pix_) + 1.d0 end if do i = 1, nout - binmap%b_map(i,1,pix_) = binmap%b_map(i,1,pix_) + data(i,t,det) * inv_sigmasq + if((.not. binmap%solve_nplus2) .or. det == 1) then + binmap%b_map(i,1,pix_) = binmap%b_map(i,1,pix_) + data(i,t,det) * inv_sigmasq + else + binmap%b_map(i,det+2,pix_) = binmap%b_map(i,det+2,pix_) + data(i,t,det) * inv_sigmasq + end if if(tod%nmaps > 1) then binmap%b_map(i,2,pix_) = binmap%b_map(i,2,pix_) + data(i,t,det) * tod%cos2psi(psi_) * inv_sigmasq binmap%b_map(i,3,pix_) = binmap%b_map(i,3,pix_) + data(i,t,det) * tod%sin2psi(psi_) * inv_sigmasq @@ -223,8 +249,11 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) do i = 1, nout binmap%b_map(i,det+3,pix_) = binmap%b_map(i,det+3,pix_) + data(i,t,det) * inv_sigmasq end do - end if - + else if(binmap%solve_nplus2) then + binmap%A_map(off+1,pix_) = binmap%A_map(off+1,pix_) + 1.d0 *inv_sigmasq + binmap%A_map(off+2,pix_) = binmap%A_map(off+2,pix_) + tod%cos2psi(psi_) * inv_sigmasq + binmap%A_map(off+3,pix_) = binmap%A_map(off+3,pix_) + tod%sin2psi(psi_) * inv_sigmasq + end if end do end do @@ -633,10 +662,126 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co logical(lgt), intent(in), optional :: correct_transfer logical(lgt) :: correct_transfer_ + integer(i4b) :: i, j, k, nmaps, ierr, ndet, ncol, n_A, off, ndelta + integer(i4b) :: det, nout, np0, comm, myid, nprocs + real(dp), allocatable, dimension(:,:) :: A_inv, As_inv + real(dp), allocatable, dimension(:,:,:) :: b_tot, bs_tot + real(dp), allocatable, dimension(:) :: W, eta + real(dp), allocatable, dimension(:,:) :: A_tot correct_transfer_ = .false. if(present(correct_transfer)) correct_transfer_ = correct_transfer + myid = tod%myid + nprocs= tod%numprocs + comm = tod%comm + np0 = tod%info%np + nout = size(binmap%sb_map%a,dim=1) + nmaps = tod%info%nmaps + ndet = tod%ndet + n_A = size(binmap%sA_map%a,dim=1) + ncol = size(binmap%sb_map%a,dim=2) + ndelta = 0; if (present(chisq_S)) ndelta = size(chisq_S,dim=2) + + ! Collect contributions from all nodes + call mpi_win_fence(0, binmap%sA_map%win, ierr) + if (binmap%sA_map%myid_shared == 0) then + do i = 1, size(binmap%sA_map%a, 1) + call mpi_allreduce(MPI_IN_PLACE, binmap%sA_map%a(i, :), size(binmap%sA_map%a, 2), & + & MPI_DOUBLE_PRECISION, MPI_SUM, binmap%sA_map%comm_inter, ierr) + end do + end if + call mpi_win_fence(0, binmap%sA_map%win, ierr) + call mpi_win_fence(0, binmap%sb_map%win, ierr) + if (binmap%sb_map%myid_shared == 0) then + do i = 1, size(binmap%sb_map%a, 1) + call mpi_allreduce(mpi_in_place, binmap%sb_map%a(i, :, :), size(binmap%sb_map%a(1, :, :)), & + & MPI_DOUBLE_PRECISION, MPI_SUM, binmap%sb_map%comm_inter, ierr) + end do + end if + call mpi_win_fence(0, binmap%sb_map%win, ierr) + + allocate (A_tot(n_A, 0:np0 - 1), b_tot(nout, nmaps, 0:np0 - 1), bs_tot(nout, ncol, 0:np0 - 1), W(nmaps), eta(nmaps)) + A_tot = binmap%sA_map%a(:, tod%info%pix + 1) + b_tot = binmap%sb_map%a(:, 1:nmaps, tod%info%pix + 1) + bs_tot = binmap%sb_map%a(:, :, tod%info%pix + 1) + + ! Solve for local map and rms + allocate (A_inv(ndet+2, ndet+2), As_inv(ncol, ncol)) + if (present(chisq_S)) chisq_S = 0.d0 + do i = 0, np0 - 1 + if (all(b_tot(1, :, i) == 0.d0)) then + if (.not. present(chisq_S)) then + rms%map(i, :) = 0.d0 + do k = 1, nout + binmap%outmaps(k)%p%map(i, :) = 0.d0 + end do + end if + cycle + end if + + A_inv = 0.d0 + ! First detector T + A_inv(1, 1) = A_tot(1, i) + A_inv(1, ndet+1) = A_tot(2,i) + A_inv(1, ndet+2) = A_tot(4,i) + A_inv(ndet+1, 1) = A_tot(2,i) + A_inv(ndet+2, 1) = A_tot(4,i) + ! Other detectors T + do j=2, ndet + A_inv(j,j) = A_tot(7+3*(ndet-1), i) + A_inv(j,ndet+1) = A_tot(8+3*(ndet-1), i) + A_inv(j,ndet+2) = A_tot(9+3*(ndet-1), i) + A_inv(ndet+1,j) = A_inv(j,ndet+1) + A_inv(ndet+2,j) = A_inv(j,ndet+2) + end do + + ! Polarization + A_inv(ndet+1,ndet+1) = A_tot(3, i) + A_inv(ndet+2,ndet+2) = A_tot(6, i) + A_inv(ndet+1,ndet+2) = A_tot(5, i) + A_inv(ndet+2,ndet+1) = A_tot(5, i) + + ! Can I return the condition number? + call invert_singular_matrix(A_inv, 1d-12) + do k = 1, tod%ndet+2 + b_tot(k, 1:nmaps, i) = matmul(A_inv, b_tot(k, 1:nmaps, i)) + end do + + ! Store map in correct units + do j = 1, nmaps + do k = 1, tod%output_n_maps + binmap%outmaps(k)%p%map(i, j) = b_tot(k, j, i)*scale + end do + end do + + ! Store N in correct units + if (rms%info%nmaps == 3) then + ! Diagonal matrix; store RMS + do j = 1, nmaps + rms%map(i,j) = sqrt(A_inv(j, j))*scale + end do + else if (rms%info%nmaps == 4) then + ! Block-diagonal T + QU; store N + rms%map(i,1) = A_inv(1,1)*scale**2 + rms%map(i,2) = A_inv(2,2)*scale**2 + rms%map(i,3) = A_inv(3,3)*scale**2 + rms%map(i,4) = A_inv(2,3)*scale**2 + end if + end do + + if (present(chisq_S)) then + if (myid == 0) then + call mpi_reduce(mpi_in_place, chisq_S, size(chisq_S), & + & MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + else + call mpi_reduce(chisq_S, chisq_S, size(chisq_S), & + & MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + end if + end if + + deallocate (A_inv, As_inv, A_tot, b_tot, bs_tot, W, eta) + end subroutine finalize_binned_map_nplus2 diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 8f72f295a..c310744cd 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -949,7 +949,9 @@ subroutine read_tod(self, detlabels, datadir) & MPI_DOUBLE_PRECISION, MPI_SUM, self%comm, ierr) call mpi_allreduce(MPI_IN_PLACE, ns, self%ndet+1, & & MPI_INTEGER, MPI_SUM, self%comm, ierr) + self%gain0(0) = sum(self%gain0)/sum(ns) + where (ns > 0) self%gain0 = self%gain0 / ns - self%gain0(0) end where @@ -1630,13 +1632,17 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) real(dp) :: mu character(len=6) :: itext character(len=512) :: path - real(dp), allocatable, dimension(:,:,:) :: output - real(dp), allocatable, dimension(:) :: mjds + real(dp), allocatable, dimension(:,:,:) :: output, condensed_output + real(dp), allocatable, dimension(:) :: mjds, condensed_mjds npar = 3+self%n_xi if (self%baseline_order >= 0) npar = npar + self%baseline_order + 1 - allocate(output(self%nscan_tot,self%ndet,npar)) - allocate( mjds(self%nscan_tot)) + allocate(output(self%last_scan,self%ndet,npar+1)) + allocate( mjds(self%last_scan)) + + allocate(condensed_output(self%nscan_tot, self%ndet,npar+1)) + allocate(condensed_mjds(self%nscan_tot)) + ! Collect all parameters output = 0.d0 @@ -1644,12 +1650,13 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) do j = 1, self%ndet do i = 1, self%nscan k = self%scanid(i) - output(k,j,1) = self%scans(i)%d(j)%gain - output(k,j,2) = merge(1.d0,0.d0,self%scans(i)%d(j)%accept) - output(k,j,3) = self%scans(i)%d(j)%chisq - output(k,j,4:3+self%n_xi) = self%scans(i)%d(j)%N_psd%xi_n + output(k,j,1) = k + output(k,j,2) = self%scans(i)%d(j)%gain + output(k,j,3) = merge(1.d0,0.d0,self%scans(i)%d(j)%accept) + output(k,j,4) = self%scans(i)%d(j)%chisq + output(k,j,5:4+self%n_xi) = self%scans(i)%d(j)%N_psd%xi_n if (self%baseline_order >= 0) then - output(k,j,4+self%n_xi:npar) = self%scans(i)%d(j)%baseline + output(k,j,5+self%n_xi:npar+1) = self%scans(i)%d(j)%baseline end if if (j == 1) then mjds(k) = self%scans(i)%t0(1) @@ -1697,6 +1704,17 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) end do end do + ! cut missing scan ids from output and mjd before we write it to disk + j = 1 + do i = 1, self%last_scan + if(mjds(i) > 0) then !this scanid exists + condensed_output(j,:,:) = output(i,:,:) + condensed_mjds(j) = mjds(i) + j = j+1 + end if + end do + + !!$ do j = 1, self%ndet !!$ do i = 1, 4 !!$ mu = sum(output(:,j,i)) / count(output(:,j,i) /= 0.d0) @@ -1710,11 +1728,12 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) path = trim(adjustl(itext))//'/tod/'//trim(adjustl(self%freq))//'/' !write(*,*) 'path', trim(path) call create_hdf_group(chainfile, trim(adjustl(path))) - call write_hdf(chainfile, trim(adjustl(path))//'gain', output(:,:,1)) - call write_hdf(chainfile, trim(adjustl(path))//'accept', output(:,:,2)) - call write_hdf(chainfile, trim(adjustl(path))//'chisq', output(:,:,3)) - call write_hdf(chainfile, trim(adjustl(path))//'xi_n', output(:,:,4:3+self%n_xi)) - call write_hdf(chainfile, trim(adjustl(path))//'MJD', mjds) + call write_hdf(chainfile, trim(adjustl(path))//'scanid', condensed_output(:,:,1)) + call write_hdf(chainfile, trim(adjustl(path))//'gain', condensed_output(:,:,2)) + call write_hdf(chainfile, trim(adjustl(path))//'accept', condensed_output(:,:,3)) + call write_hdf(chainfile, trim(adjustl(path))//'chisq', condensed_output(:,:,4)) + call write_hdf(chainfile, trim(adjustl(path))//'xi_n', condensed_output(:,:,5:4+self%n_xi)) + call write_hdf(chainfile, trim(adjustl(path))//'MJD', condensed_mjds) if (self%baseline_order >= 0) call write_hdf(chainfile, trim(adjustl(path))//'baseline', output(:,:,4+self%n_xi:npar)) call write_hdf(chainfile, trim(adjustl(path))//'polang', self%polang) call write_hdf(chainfile, trim(adjustl(path))//'gain0', self%gain0) @@ -1733,7 +1752,7 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) ! Write instrument-specific parameters call self%dumpToHDF_inst(chainfile, path) - deallocate(output, mjds) + deallocate(output, mjds, condensed_output, condensed_mjds) end subroutine dumpToHDF @@ -3266,7 +3285,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres nmax = 1000 gain = self%scans(scan)%d(det)%gain - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flags -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flags -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod ! Generate dynamic mask allocate(mask_dyn(ntod)) @@ -3310,7 +3329,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres ncut = ncut + 1 end if end do - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms @@ -3360,7 +3379,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(cut) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single spikes-- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single spikes-- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (threshold(4) > 0.) then @@ -3387,7 +3406,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (threshold(5) > 0.) then @@ -3414,7 +3433,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if !!$ open(58, file='var4.dat') @@ -3447,7 +3466,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (threshold(7) > 0.) then @@ -3473,7 +3492,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres flag(ntod) = flag(ntod) + flag_dyn ncut = ncut + 1 end if - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + ! close(58) + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (threshold(8) > 0.) then @@ -3497,7 +3517,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end if end do if (output_scan == self%scanid(scan)) close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (output_scan == self%scanid(scan)) then @@ -3550,7 +3570,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do end if - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut end if if (output_scan == self%scanid(scan)) then From 0ebb041dd9fe4c233e77025ee75742fd0a43b962 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 8 Apr 2025 20:15:58 +0200 Subject: [PATCH 141/171] Wright debugging, minor fixes --- .../components/cmb/cmb_relquad.defaults | 2 +- commander3/src/comm_diffuse_comp_smod.f90 | 6 +- commander3/src/comm_mh_specind_mod.f90 | 24 ++++++-- commander3/src/comm_param_mod.f90 | 1 + commander3/src/comm_tod_pixhist_mod.f90 | 19 +++++- commander3/src/comm_zodi_comp_mod.f90 | 60 +++++++++++++------ commander3/src/comm_zodi_mod.f90 | 43 ++++++++++--- commander3/src/commander.f90 | 14 +++-- 8 files changed, 124 insertions(+), 45 deletions(-) diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults index 7741f651c..f339a4f2c 100644 --- a/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults +++ b/commander3/parameter_files/defaults/components/cmb/cmb_relquad.defaults @@ -10,5 +10,5 @@ COMP_CG_SAMPLE_GROUP&& = 0 COMP_PRIOR_GAUSS_MEAN&& = 1.d0 COMP_PRIOR_GAUSS_RMS&& = 0.d0 COMP_DEFAULT_AMPLITUDE&& = 1.d0 -COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def_v2.txt +COMP_TEMPLATE_DEFINITION_FILE&& = cmb_relquad_def.txt COMP_INIT_FROM_HDF&& = none diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 9a70716ec..d21eb6766 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -150,9 +150,9 @@ module subroutine initDiffuse(self, cpar, id, id_abs) elsewhere self%x%alm(i,:) = 0.d0 end where - if (l > 500) then - self%x%alm(i,:) = self%x%alm(i,:) * real(500.d0/l,dp)**20 - end if +!!$ if (l > 500) then +!!$ self%x%alm(i,:) = self%x%alm(i,:) * real(500.d0/l,dp)**20 +!!$ end if end do end if diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index e89641292..4e139bfea 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -212,7 +212,6 @@ subroutine sample_template_mh(outdir, cpar, handle, handle_noise, l) allocate(scales(n_scales)) - ! Calculate initial chisq chisq_old = 0d0 call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_old, & @@ -268,6 +267,8 @@ subroutine sample_template_mh(outdir, cpar, handle, handle_noise, l) call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_prop, & & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) + !call output_FITS_sample(cpar, 2000+l, .true.) + if (cpar%myid_chain .eq. 0) then write(*,*) "| Proposal chisq is ", chisq_prop write(*,*) "| Delta chi^2 is ", chisq_prop - chisq_old @@ -386,18 +387,27 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) if (cpar%myid == 0) then write(*,*) '| MH sampling group ', l end if - + + ! Perform one CG sample for init chisq; this should in principle not + ! be necessary, and indicates that the Gibbs loop may be broken before this + call store_buffer() ! Avoid burn-in penalty + if (trim(cpar%mcmc_update_cg_groups(l)) == 'none') then + if (cpar%myid == 0) write(*,*) '| No groups to sample' + else + if (cpar%myid == 0) write(*,*) '| Sampling CG groups ',trim(cpar%mcmc_update_cg_groups(l)) + call sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups=cpar%mcmc_update_cg_groups(l)) + end if + ! Calculate initial chisq chisq_old = 0d0 call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_old, & - & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) + & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) + if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) if (cpar%myid_chain .eq. 0) then write(*,*) '| Old chisq is ', chisq_old end if - call store_buffer() - negative = .false. c => compList do while (associated(c)) @@ -437,7 +447,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) end select - !go to next compedt + !go to next component c => c%nextComp() end do @@ -456,6 +466,8 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_prop, & & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) + !call output_FITS_sample(cpar, 1000+100*l+m, .true.) + if (cpar%myid_chain .eq. 0) then write(*,*) "| Proposal chisq is ", chisq_prop write(*,*) "| Delta chi^2 is ", chisq_prop - chisq_old diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index c67824210..76a2e1bb0 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -3024,6 +3024,7 @@ subroutine read_zodi_params_hash(htbl, cpar) cpar%zs_general_params(:, 3) = DEFAULT_PRIOR_UPPER_LIMIT do i = 1, size(cpar%zodi_param_labels%general) + if (trim(cpar%zs_phasefunc) /= 'Hong' .and. i > 2) cycle call get_parameter_from_hash(htbl, 'ZODI_'//trim(adjustl(cpar%zodi_param_labels%general(i))), par_string=value_string)! par_dp=cpar%zs_general_params(i)) call get_tokens(value_string, ',', value_and_priors_str, num=n_tokens) if (.not. (n_tokens == 4 .or. n_tokens == 1)) stop "zodi parameter must have 1, or 4 tokens (value,) or (value,prior_lower_limit,prior_upper_limit,prior_type) [no spaces]" diff --git a/commander3/src/comm_tod_pixhist_mod.f90 b/commander3/src/comm_tod_pixhist_mod.f90 index 4a3a5c4e1..d30bb0c83 100644 --- a/commander3/src/comm_tod_pixhist_mod.f90 +++ b/commander3/src/comm_tod_pixhist_mod.f90 @@ -39,7 +39,8 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) ! Find absolute min and max per low-res pixel allocate(tod%pixhist(5,0:npix_hist-1)) ! (mu, rms, nhit, min, max) allocate(delta(0:npix_hist-1)) ! (mu, rms, nhit, min, max) - allocate(hist(0:NBIN_HIST,0:npix_hist-1)) + allocate(hist(0:NBIN_HIST,0:npix_hist-1)) + tod%pixhist = 0. tod%pixhist(4,:) = 1e30 tod%pixhist(5,:) = -1e30 do i = 1, tod%nscan @@ -80,6 +81,7 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) if (iand(sd%flag(k,j), tod%flag0) .ne. 0) cycle call ring2nest(tod%nside, sd%pix(k,j,1), pix) pix = pix / q + if (delta(pix) == 0.) cycle ! 0 or 1 samples in current pixel bin = int((sd%tod(k,j)-tod%pixhist(4,pix))/delta(pix))+1 if (bin(1) < 1 .or. bin(1) > NBIN_HIST) bin(1) = 0 ! Sample out of range; discarded hist(bin(1),pix) = hist(bin(1),pix) + 1 @@ -96,6 +98,8 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) ! Check histogram quality, and refine limits refine = .false. do i = 0, npix_hist-1 + if (delta(i) == 0.) cycle ! 0 or 1 samples in current pixel + nhit = sum(hist(1:NBIN_HIST,i)) if (nhit == 0) cycle ! Cut bins from low side @@ -140,12 +144,22 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) ! Update bin width delta(i) = (tod%pixhist(5,i)-tod%pixhist(4,i))/NBIN_HIST - if (delta(i) == 0.) write(*,*) "zero", i, tod%pixhist(4,i), tod%pixhist(5,i), hist(:,i) + !if (delta(i) == 0.) write(*,*) "zero", i, tod%pixhist(4,i), tod%pixhist(5,i), hist(:,i) end do end do ! Define cuts and output some histograms to disk do i = 0, npix_hist-1 + if (delta(i) == 0.) then + ! 0 or 1 samples in current pixel; accept anything + tod%pixhist(1,i) = 0. + tod%pixhist(2,i) = 0. + tod%pixhist(3,i) = 0. + tod%pixhist(4,i) = -1e30 + tod%pixhist(5,i) = 1e30 + cycle + end if + nhit = sum(hist(1:NBIN_HIST,i)) if (nhit == 0) cycle do j = 1, NBIN_HIST @@ -161,7 +175,6 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) tod%pixhist(4,i) = mu - 4.0*sigma tod%pixhist(5,i) = mu + 4.0*sigma - if (tod%myid == 0 .and. mod(i,1000)==0) then call int2string(i,pix_text) open(58,file='pixhist'//pix_text//'.dat', recl=1024) diff --git a/commander3/src/comm_zodi_comp_mod.f90 b/commander3/src/comm_zodi_comp_mod.f90 index a1f042174..d99f3e006 100644 --- a/commander3/src/comm_zodi_comp_mod.f90 +++ b/commander3/src/comm_zodi_comp_mod.f90 @@ -770,15 +770,16 @@ subroutine param2model_WrightCloudRing(self, x) self%p5 = x(10) self%p6 = x(11) self%p7 = x(12) - self%p9 = x(13) - self%p10 = x(14) - self%p13 = x(15) - self%p14 = x(16) - self%p15 = x(17) - self%p16 = x(18) - self%p17 = x(19) - self%p18 = x(20) - self%p19 = x(21) + self%p8 = x(13) + self%p9 = x(14) + self%p10 = x(15) + self%p13 = x(16) + self%p14 = x(17) + self%p15 = x(18) + self%p16 = x(19) + self%p17 = x(20) + self%p18 = x(21) + self%p19 = x(22) end subroutine param2model_WrightCloudRing subroutine model2param_WrightCloudRing(self, x) @@ -797,15 +798,16 @@ subroutine model2param_WrightCloudRing(self, x) x(10) = self%p5 x(11) = self%p6 x(12) = self%p7 - x(13) = self%p9 - x(14) = self%p10 - x(15) = self%p13 - x(16) = self%p14 - x(17) = self%p15 - x(18) = self%p16 - x(19) = self%p17 - x(20) = self%p18 - x(21) = self%p19 + x(13) = self%p8 + x(14) = self%p9 + x(15) = self%p10 + x(16) = self%p13 + x(17) = self%p14 + x(18) = self%p15 + x(19) = self%p16 + x(20) = self%p17 + x(21) = self%p18 + x(22) = self%p19 end subroutine model2param_WrightCloudRing subroutine param2model_WrightBand(self, x) @@ -1065,6 +1067,22 @@ subroutine get_density_WrightCloudRing(self, X_vec, theta, n_out) real(dp) :: x_D, y_D, z_D, L_D, A, D ! X_vec = r = position to evaluate model in heliocentric coordinates +!!$ open(58,file='n.dat', recl=1024) +!!$ write(*,*) 'p3', self%p3 +!!$ write(*,*) 'p4', self%p4 +!!$ write(*,*) 'p5', self%p5 +!!$ write(*,*) 'p6', self%p6 +!!$ write(*,*) 'p7', self%p7 +!!$ write(*,*) 'p8', self%p8 +!!$ write(*,*) 'p9', self%p9 +!!$ write(*,*) 'p10', self%p10 +!!$ write(*,*) 'p13', self%p13 +!!$ write(*,*) 'p14', self%p14 +!!$ write(*,*) 'p15', self%p15 +!!$ write(*,*) 'p16', self%p16 +!!$ write(*,*) 'p17', self%p17 +!!$ write(*,*) 'p18', self%p18 +!!$ write(*,*) 'p19', self%p19 do i = 1, size(n_out) R = sqrt(sum(X_vec(:,i)**2)) z_c = [self%p6, self%p7, 10.d0] / sqrt(100.d0 + self%p6**2 + self%p7**2) @@ -1100,7 +1118,10 @@ subroutine get_density_WrightCloudRing(self, X_vec, theta, n_out) ! Total density n_out(i) = self%n_0 * R/R_c * f * R_c**(-self%p1) * (1.d0 + 0.1d0 * self%p10 * D*(1.d0+A)) + !write(58,*) R, n_out(i), X_vec(:,i), sin_i, Z, f, self%n_0, R_c, self%p1, self%p10, D, A end do +! close(58) +! stop end subroutine get_density_WrightCloudRing subroutine get_density_WrightBand(self, X_vec, theta, n_out) @@ -1119,7 +1140,8 @@ subroutine get_density_WrightBand(self, X_vec, theta, n_out) R_b = R + sum(o_b * X_vec(:,i)) if (abs(sin_i) < 0.1d0*self%q1 .and. R_b < self%R_1) then - n_out(i) = self%n_0 * R/R_b**2 * cosh(1.72d0*abs(sin_i)/(0.1d0*self%q1)) + !n_out(i) = self%n_0 * R/R_b**2 * cosh(1.72d0*abs(sin_i)/(0.1d0*self%q1)) + n_out(i) = self%n_0 * R/R_b**2 * cosh(1.72d0*abs(sin_i)/self%q1) / pi else n_out(i) = 0.d0 end if diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 14a9d8a5c..68ad4db2d 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -112,7 +112,7 @@ subroutine initialize_zodi_mod(cpar) end if end do else if (trim(zodi_model%phasefunc_type) == 'Wright') then - zodi_model%n_general_params = 2 + zodi_model%n_phase_params = 2 zodi_model%n_general_params = 2 + zodi_model%n_phase_params allocate(zodi_model%par_phase(zodi_model%n_phase_params)) zodi_model%par_phase(1) = -0.3133d0 ! p20 @@ -186,7 +186,7 @@ subroutine initialize_zodi_mod(cpar) do i = 1, zodi_model%n_comps ind = zodi_model%comps(i)%start_ind npar = zodi_model%comps(i)%npar - zodi_model%theta2band(ind:ind+npar-1) = 0 ! Shape paraneters affect all band + zodi_model%theta2band(ind:ind+npar-1) = 0 ! Shape parameters affect all bands do j = 1, numband zodi_model%theta2band(ind+npar+j-1) = j ! Emissivity only affect band j zodi_model%theta2band(ind+npar+numband+j-1) = j ! The same for albedo @@ -895,7 +895,11 @@ subroutine get_s_zodi(band, s_therm, s_scat, s_zodi, comp_id) al = zodi_model%comps(i)%c%albedo(band) em = zodi_model%comps(i)%c%emissivity(band) !write(*,*) i, em, al, any(s_scat(:,i)/=s_scat(:,i)), any(s_therm(:,i)/=s_therm(:,i)) - s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + (1. - al) * em * s_therm(:,i-first+1)) + if (trim(zodi_model%phasefunc_type) == 'Wright') then + s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + em * s_therm(:,i-first+1)) + else + s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + (1. - al) * em * s_therm(:,i-first+1)) + end if end do end subroutine get_s_zodi @@ -1285,6 +1289,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod logical(lgt) :: scattering, thermal, use_lowres real(dp) :: earth_lon, R_obs, R_min, R_max, dt_tod, obs_time, lat, lon real(dp) :: unit_vector(3), obs_pos(3), earth_pos(3) + real(dp), allocatable, dimension(:) :: b_nu !real(dp), dimension(gauss_degree) :: R_LOS, T_LOS, density_LOS, solar_flux_LOS, scattering_angle, phase_function, b_nu_LOS s_zodi_scat = 0. @@ -1389,19 +1394,34 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !!$ end do if (scattering) then - comp_LOS(k)%F_sol = model%F_sun(tod%zodiband)/comp_LOS(k)%R**2 + if (trim(model%phasefunc_type) == 'Wright') then + allocate(b_nu(size(tod%bp(0)%p%nu))) + call get_blackbody_emission(tod%bp(0)%p%nu, 5772.d0, b_nu) + comp_LOS(k)%F_sol = tsum(tod%bp(0)%p%nu, tod%bp(0)%p%tau*b_nu)/comp_LOS(k)%R**2 + deallocate(b_nu) + else + comp_LOS(k)%F_sol = model%F_sun(tod%zodiband)/comp_LOS(k)%R**2 + end if call get_scattering_angle(comp_LOS(k)%X, comp_LOS(k)%X_unit, comp_LOS(k)%R, comp_LOS(k)%Theta) call model%get_phase_function(comp_LOS(k)%Theta, tod%zodiband, comp_LOS(k)%Phi) end if ! Get dust grain temperature, and compute splined blackbody emission - comp_LOS(k)%T = model%T_0 * comp_LOS(k)%R**(-model%delta) + if (trim(model%phasefunc_type) == 'Wright' .and. k > 1) then + comp_LOS(k)%T = exp(5.5301d0) * comp_LOS(k)%R**(-0.5d0) + else + comp_LOS(k)%T = model%T_0 * comp_LOS(k)%R**(-model%delta) + end if call splint_simple_multi(tod%zodi_b_nu_spl_obj(det), comp_LOS(k)%T, comp_LOS(k)%B_nu) ! Compute predicted signal; store computed signal in cache call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) if (scattering) then - s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 + if (trim(model%phasefunc_type) == 'Wright') then + s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 + else + s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 + end if if (use_lowres) then tod%zodi_scat_cache_lowres(lookup_idx, k, det) = s_zodi_scat(i, k) else @@ -1409,7 +1429,11 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod end if end if if (thermal) then - s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 + if (trim(model%phasefunc_type) == 'Wright') then + s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 + else + s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 + end if if (use_lowres) then tod%zodi_therm_cache_lowres(lookup_idx, k, det) = s_zodi_therm(i, k) else @@ -1784,10 +1808,10 @@ subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, s_therm, s deallocate(s_scat_, s_therm_, s_zodi) end if - return + !return ! Add solar component by Healpix map lookup - if (trim(exclude_static) /= 'solar') then + if (associated(tod%map_solar) .and. trim(exclude_static) /= 'solar') then do h = 1, tod%nhorn do i = 1, ntod j = tod%scans(scan)%d(det)%pix_sol(i,h) @@ -1798,6 +1822,7 @@ subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, s_therm, s end do end do end if + return ! Add Moon component by Healpix map lookup if (trim(exclude_static) /= 'moon') then diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 47f8ee667..6a6dea8fb 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -329,6 +329,7 @@ program commander !---------------------------------------------------------------------------------- ! Process TOD structures if (iter > 0 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then + !if (iter == 1 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then ! Create zodi atlas ! if (.false.) then @@ -405,10 +406,12 @@ program commander end select ! Sample stationary components - if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') - if (cpar%sample_solar_maps) call sample_static_zodi_map(cpar, handle, 'solar') - if (cpar%sample_moon_maps) call sample_static_zodi_map(cpar, handle, 'moon') - + !if (first_zodi) then + if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') + if (cpar%sample_solar_maps) call sample_static_zodi_map(cpar, handle, 'solar') + if (cpar%sample_moon_maps) call sample_static_zodi_map(cpar, handle, 'moon') + !end if + !!$ if (mod(iter-2,10) == 0) then !!$ call zodi_model%params_to_model([& @@ -479,6 +482,9 @@ program commander call timer%start(TOT_SPECIND) call sample_nonlin_params(cpar, iter, handle, handle_noise) call timer%stop(TOT_SPECIND) + + ! Do CG group sampling + call sample_all_amps_by_CG(cpar, handle, handle_noise) end if !if (mod(iter,cpar%thinning) == 0) call output_FITS_sample(cpar, 100+iter, .true.) From 7a4293e067a4d5242bcd1e45267c441182a70b1b Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Thu, 10 Apr 2025 09:36:56 +0200 Subject: [PATCH 142/171] Better output from dynamic masking and MH sampling; auto-tuned step sizes in MH MBBtab --- commander3/src/comm_chisq_mod.f90 | 7 +- commander3/src/comm_cr_mod.f90 | 12 +- commander3/src/comm_diffuse_comp_mod.f90 | 3 +- commander3/src/comm_diffuse_comp_smod.f90 | 19 +- commander3/src/comm_mh_specind_mod.f90 | 195 +++++++++----------- commander3/src/comm_ptsrc_comp_mod.f90 | 22 +-- commander3/src/comm_signal_mod.f90 | 47 ++--- commander3/src/comm_sparse_mod.f90 | 10 +- commander3/src/comm_tod_dirbe_mod.f90 | 3 + commander3/src/comm_tod_mod.f90 | 78 ++++++-- commander3/src/comm_tod_pixhist_mod.f90 | 3 +- commander3/src/commander.f90 | 206 ++++------------------ 12 files changed, 255 insertions(+), 350 deletions(-) diff --git a/commander3/src/comm_chisq_mod.f90 b/commander3/src/comm_chisq_mod.f90 index 6fb1b141e..7e5effe67 100644 --- a/commander3/src/comm_chisq_mod.f90 +++ b/commander3/src/comm_chisq_mod.f90 @@ -24,7 +24,7 @@ module comm_chisq_mod contains - subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_eval, band_list, evalpol) + subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_eval, band_list, evalpol, ndof) implicit none integer(i4b), intent(in) :: comm logical(lgt), intent(in), optional :: lowres_eval @@ -36,6 +36,7 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ type(map_ptr), dimension(1:), intent(in), optional :: mask character(len=512), intent(in), optional :: maskpath integer(i4b), dimension(:), intent(in), optional :: band_list + integer(i4b), intent(out), optional :: ndof integer(i4b) :: i, j, k, p, ierr, nmaps, nbands integer(i4b), dimension(:), allocatable :: bandlist @@ -78,6 +79,7 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ if (present(chisq_fullsky) .or. present(chisq_map)) then if (present(chisq_fullsky)) chisq_fullsky = 0.d0 if (present(chisq_map)) chisq_map%map = 0.d0 + if (present(ndof)) ndof = 0 do p = 1, nbands i = bandlist(p) if (i == 0) cycle @@ -143,8 +145,10 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ if (present(chisq_fullsky)) then if (lowres) then chisq_fullsky = chisq_fullsky + sum(res_lowres%map) + if (present(ndof)) ndof = ndof + count(res_lowres%map /= 0.) else chisq_fullsky = chisq_fullsky + sum(res%map) + if (present(ndof)) ndof = ndof + count(res%map /= 0.) !write(*,*) trim(data(i)%label), sum(res%map), chisq_fullsky end if end if @@ -159,6 +163,7 @@ subroutine compute_chisq(comm, chisq_map, chisq_fullsky, mask, maskpath, lowres_ if (present(chisq_fullsky)) then call mpi_allreduce(MPI_IN_PLACE, chisq_fullsky, 1, MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr) + if (present(ndof)) call mpi_allreduce(MPI_IN_PLACE, ndof, 1, MPI_INTEGER, MPI_SUM, comm, ierr) end if end subroutine compute_chisq diff --git a/commander3/src/comm_cr_mod.f90 b/commander3/src/comm_cr_mod.f90 index cdbc284e8..45e0283bd 100644 --- a/commander3/src/comm_cr_mod.f90 +++ b/commander3/src/comm_cr_mod.f90 @@ -35,15 +35,16 @@ module comm_cr_mod contains - subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) + subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat, verbosity) implicit none type(comm_params), intent(in) :: cpar integer(i4b), intent(in) :: samp_group real(dp), dimension(1:), intent(out) :: x real(dp), dimension(1:), intent(in) :: b integer(i4b), intent(out) :: stat + integer(i4b), intent(in), optional :: verbosity - integer(i4b) :: i, j, k, l, m, n, maxiter, root, ierr + integer(i4b) :: i, j, k, l, m, n, maxiter, root, ierr, verbosity_ integer(i4b), save :: samp_group_prev real(dp) :: eps, tol, delta0, delta_new, delta_old, alpha, beta, t1, t2, t3, t4 real(dp) :: lim_convergence, val_convergence, chisq, chisq_prev, buff, dq @@ -55,6 +56,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) maxiter = cpar%cg_samp_group_maxiter(samp_group) eps = cpar%cg_tol n = size(x) + verbosity_ = cpar%verbosity; if (present(verbosity)) verbosity_ = verbosity ! Allocate temporary data vectors call update_status(status, "cr1") @@ -67,7 +69,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) samp_group_prev = samp_group !call update_status(status, "cr3") call wall_time(t2) - if (cpar%myid_chain == root .and. cpar%verbosity > 2) then + if (cpar%myid_chain == root .and. verbosity_ > 2) then write(*,fmt='(a,f8.2)') ' | CG initialize preconditioner, time = ', real(t2-t1,sp) end if @@ -284,7 +286,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) !if (cpar%myid == root) write(*,*) x(size(x)-1:size(x)) call wall_time(t2) - if (cpar%myid_chain == root .and. cpar%verbosity > 2) then + if (cpar%myid_chain == root .and. verbosity_ > 2) then if (trim(cpar%cg_conv_crit) == 'residual' .or. trim(cpar%cg_conv_crit) == 'fixed_iter') then !!$ write(*,*) ' CG iter. ', i, ' -- res = ', & !!$ & val_convergence, ', tol = ', lim_convergence, & @@ -354,7 +356,7 @@ subroutine solve_cr_eqn_by_CG(cpar, samp_group, x, b, stat) write(*,*) ' number of iterations = ', maxiter stat = stat + 1 else - if (cpar%myid_chain == root .and. cpar%verbosity > 1) then + if (cpar%myid_chain == root .and. verbosity_ > 1) then write(*,fmt='(a,i5,a,e13.5,a,e13.5,a,f8.2)') ' | Final CG iter ', i, ' -- res = ', & & real(val_convergence,sp), ', tol = ', real(lim_convergence,sp) end if diff --git a/commander3/src/comm_diffuse_comp_mod.f90 b/commander3/src/comm_diffuse_comp_mod.f90 index baa89c807..5fc352aec 100644 --- a/commander3/src/comm_diffuse_comp_mod.f90 +++ b/commander3/src/comm_diffuse_comp_mod.f90 @@ -484,10 +484,11 @@ module subroutine setup_needlets(info, nside_def, defmask, Z, ndef) integer(i4b), intent(out) :: ndef end subroutine setup_needlets - module subroutine applyMonoDipolePrior(self, handle) + module subroutine applyMonoDipolePrior(self, handle, verbosity) implicit none class(comm_diffuse_comp), intent(inout) :: self type(planck_rng), intent(inout) :: handle + integer(i4b), intent(in), optional :: verbosity end subroutine applyMonoDipolePrior module subroutine nullify_monopole_amp(band) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index d21eb6766..52109fef4 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -3501,12 +3501,13 @@ module subroutine setup_needlets(info, nside_def, defmask, Z, ndef) end subroutine setup_needlets - module subroutine applyMonoDipolePrior(self, handle) + module subroutine applyMonoDipolePrior(self, handle, verbosity) implicit none class(comm_diffuse_comp), intent(inout) :: self type(planck_rng), intent(inout) :: handle + integer(i4b), intent(in), optional :: verbosity - integer(i4b) :: i, j, k, l, m, ierr, pix + integer(i4b) :: i, j, k, l, m, ierr, pix, verbosity_ real(dp) :: mu(0:3), a, b, Amat(0:3,0:3), bmat(0:3), v(0:3), corr_res(3) class(comm_map), pointer :: map, lr_map class(comm_mapinfo), pointer :: info => null() @@ -3519,6 +3520,8 @@ module subroutine applyMonoDipolePrior(self, handle) return end if + verbosity_ = 10; if (present(verbosity)) verbosity_ = verbosity + ! Compute monopole offset given the specified prior mu = 0.d0 @@ -3544,7 +3547,7 @@ module subroutine applyMonoDipolePrior(self, handle) ! Subtract mean in real space self%x%map(:,1) = self%x%map(:,1) - mu(0) - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' | Monopole prior correction for component: '//trim(self%label) write(*,fmt='(a,f11.3)') ' | Monopole: ',mu(0)*self%cg_scale(1) write(*,fmt='(a)') ' | ' @@ -3574,7 +3577,7 @@ module subroutine applyMonoDipolePrior(self, handle) if (trim(self%mono_prior_type) == 'monopole-dipole') then ! Subtract mean in real space self%x%map(:,1) = self%x%map(:,1) - mu(0) - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' | Monopole prior correction (with dipole estimate) for component: '//trim(self%label) write(*,fmt='(a,f10.3,a,3f10.3,a)') ' | Monopole (dipole):', & & mu(0)*self%cg_scale(1),' ( ',mu(1:3)*self%cg_scale(1), ' )' @@ -3589,7 +3592,7 @@ module subroutine applyMonoDipolePrior(self, handle) call pix2vec_ring(self%x%info%nside, self%x%info%pix(i+1), v(1:3)) self%x%map(i,1) = self%x%map(i,1) - sum(v*mu) end do - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' Monopole+dipole prior correction for component: '//trim(self%label) write(*,fmt='(a)') ' Monopole Dipole_x Dipole_y Dipole_z' write(*,fmt='(a,4f11.3)') ' ',mu*self%cg_scale(1) @@ -3709,7 +3712,7 @@ module subroutine applyMonoDipolePrior(self, handle) ! Subtract mean in real space self%x%map(:,1) = self%x%map(:,1) - mu(0) - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' | Cross-correlation prior correction for component: '//trim(self%label) write(*,fmt='(a,i2)') ' | Number of linear fits (thresholds): ',& & self%mono_prior_Nthresh @@ -3792,7 +3795,7 @@ module subroutine applyMonoDipolePrior(self, handle) ! Subtract mean in real space self%x%map(:,1) = self%x%map(:,1) - mu(0) - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' Lowest value prior correction for component: '//trim(self%label) write(*,fmt='(a,f14.3,f14.3)') ' Prior value (mu,RMS) ', & & self%mono_prior_gaussian_mean*self%cg_scale(1), & @@ -3902,7 +3905,7 @@ module subroutine applyMonoDipolePrior(self, handle) ! Subtract mean in real space self%x%map(:,1) = self%x%map(:,1) - mu(0) - if (self%x%info%myid == 0) then + if (self%x%info%myid == 0 .and. verbosity_ > 0) then write(*,fmt='(a)') ' | Band monopole prior correction for -- comp: '//trim(self%label)//' -- prior band: '//trim(self%mono_prior_band) write(*,fmt='(a,f14.3,f14.3)') ' | Band monopole prior (mu,RMS) ', prior_vals(1),prior_vals(2) write(*,fmt='(a,f14.3)') ' | New band monopole ',b*mono_mix/sqrt(4.d0*pi) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 4e139bfea..2ae01d782 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -22,6 +22,8 @@ module comm_mh_specind_mod use comm_signal_mod implicit none + integer(i4b), dimension(100,2) :: mh_accept_stat = 0 ! (nsamp, naccept) + real(dp), dimension(100) :: mh_scale = 1. ! Step length modifier contains @@ -348,23 +350,30 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) type(comm_params) :: cpar real(dp) :: chisq, my_chisq, chisq_old, chisq_new, chisq_prop, mval, mval_0 - integer(i4b) :: band, ierr, i, j, k, m, pol, pix + integer(i4b) :: band, ierr, i, j, k, m, pol, pix, ndof logical(lgt) :: include_comp, reject, todo, negative character(len=512) :: tokens(10), str_buff, operation class(comm_comp), pointer :: c => null() class(comm_map), pointer :: invN_res => null(), map => null(), sig => null(), res => null() - - + if (cpar%myid == 0) then + write(*,fmt='(a,i3,a,a)') ' | MH MBBtab sampling group ', l, ', active CG sampling groups = ', trim(cpar%mcmc_update_cg_groups(l)) + if (mh_accept_stat(l,1) > 30 .and. real(mh_accept_stat(l,2),sp)/mh_accept_stat(l,1) < 0.1d0) then + write(*,*) 'MH MBBtab ADJUSTING STEP LENGTH for group', l + mh_scale(l) = mh_scale(l) / 2. + mh_accept_stat(l,:) = 0 + end if + write(*,fmt='(a,f10.5)') ' | Step length modifier = ', mh_scale(l) + if (mh_accept_stat(l,1) > 0) then + write(*,fmt='(a,i8,a,f8.4)') ' | nsamp_tot = ', mh_accept_stat(l,1), ', accept rate = ', real(mh_accept_stat(l,2),sp)/mh_accept_stat(l,1) + end if + end if + ! Loop over sampling groups - - !do l = 1, cpar%mcmc_num_user_samp_groups do m = 1, cpar%mcmc_samp_group_numstep(l) - if (cpar%myid == 0) write(*,*) '| Running MH sample ', m, ' out of ', cpar%mcmc_samp_group_numstep(l) mval_0 = -1d0 - k = 0 - + k = 0 c => compList do while (associated(c)) k = k + 1 @@ -381,31 +390,25 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) call mpi_bcast(mval_0, 1, MPI_DOUBLE_PRECISION, & & 0, data(1)%info%comm, ierr) - if (mval_0 <= 0d0) then - return - end if - if (cpar%myid == 0) then - write(*,*) '| MH sampling group ', l - end if + if (mval_0 <= 0d0) return + + if (cpar%myid == 0) write(*,fmt='(a,i3,a,i3)') ' | Sample ', m, ' out of ', cpar%mcmc_samp_group_numstep(l) + mh_accept_stat(l,1) = mh_accept_stat(l,1) + 1 ! Perform one CG sample for init chisq; this should in principle not - ! be necessary, and indicates that the Gibbs loop may be broken before this + ! be necessary, but is useful for cases where the Gibbs chain hasn't burned in yet. + ! Otherwise, one gets a burn-in penalty during the CG step from the large number of + ! free parameters involved there, compared to the few global parameters sampled here. call store_buffer() ! Avoid burn-in penalty - if (trim(cpar%mcmc_update_cg_groups(l)) == 'none') then - if (cpar%myid == 0) write(*,*) '| No groups to sample' - else - if (cpar%myid == 0) write(*,*) '| Sampling CG groups ',trim(cpar%mcmc_update_cg_groups(l)) - call sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups=cpar%mcmc_update_cg_groups(l)) + if (trim(cpar%mcmc_update_cg_groups(l)) /= 'none') then + call sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups=cpar%mcmc_update_cg_groups(l), verbosity=0) end if ! Calculate initial chisq - chisq_old = 0d0 - call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_old, & - & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) - if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) - - if (cpar%myid_chain .eq. 0) then - write(*,*) '| Old chisq is ', chisq_old + if (trim(cpar%mcmc_update_cg_groups(l)) /= 'none' .or. m == 1) then + call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_old, & + & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:), ndof=ndof) + if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) ! Reset to previous values end if negative = .false. @@ -415,29 +418,20 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) select type (c) type is (comm_MBBtab_comp) - !if (c%id == k) then if (maxval(c%theta_steplen(c%npar+1:,l)) > 0) then - if (cpar%myid_chain .eq. 0) then - write(*,*) '| ', trim(c%label) c%SEDtab_buff = c%SEDtab - write(*,*) '| MBBtab original' - do i = 1, c%ntab - if (c%theta_steplen(c%npar+i,l) > 0) then - write(*,*) '| ', c%SEDtab(3:,i) - end if - end do - write(*,*) '| MBBtab proposal' + write(*,fmt='(a,a12)',advance='no') ' | ', trim(c%label) do i = 1, c%ntab if (c%theta_steplen(c%npar+i,l) > 0) then + write(*,fmt='(a,i4,a,f16.8)',advance='no') ', bin = ', i, ', old = ', c%SEDtab(3,i) do j = 3, size(c%SEDtab(:,i)) - c%SEDtab(j,i) = c%SEDtab(j,i) + rand_gauss(handle) * c%theta_steplen(c%npar+i,l) + c%SEDtab(j,i) = c%SEDtab(j,i) + rand_gauss(handle) * c%theta_steplen(c%npar+i,l) * mh_scale(l) end do - write(*,*) '| ', c%SEDtab(3:,i) + write(*,fmt='(a,f16.8)') ', prop = ', c%SEDtab(3,i) end if end do end if - negative = negative .or. any(c%SEDtab(3:,:) < 0.d0) end if call mpi_bcast(c%SEDtab, size(c%SEDtab), MPI_DOUBLE_PRECISION, & @@ -455,94 +449,65 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) call update_mixing_matrices(update_F_int=.true.) ! Perform component separation - if (trim(cpar%mcmc_update_cg_groups(l)) == 'none') then - if (cpar%myid == 0) write(*,*) '| No groups to sample' - else - if (cpar%myid == 0) write(*,*) '| Sampling CG groups ',trim(cpar%mcmc_update_cg_groups(l)) - call sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups=cpar%mcmc_update_cg_groups(l)) + if (trim(cpar%mcmc_update_cg_groups(l)) /= 'none') then + call sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups=cpar%mcmc_update_cg_groups(l), verbosity=0) end if chisq_prop = 0d0 call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_prop, & & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) - !call output_FITS_sample(cpar, 1000+100*l+m, .true.) - - if (cpar%myid_chain .eq. 0) then - write(*,*) "| Proposal chisq is ", chisq_prop - write(*,*) "| Delta chi^2 is ", chisq_prop - chisq_old - end if - ! Check MH statistic !reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 .or. negative reject = log(rand_uni(handle)) > (chisq_old - chisq_prop)/2 call mpi_bcast(reject, 1, MPI_LOGICAL, 0, data(1)%info%comm, ierr) - if (reject) then - if (cpar%myid_chain == 0) then - write(*,*) '| ' - write(*,*) '| MH step rejected, returning to original tabulated values.' - write(*,*) '| ' - end if - - - c => compList - do while (associated(c)) - - select type (c) - type is (comm_MBBtab_comp) - - !if (c%id == k) then - if (maxval(c%theta_steplen(c%npar+1:,l)) > 0) then - if (cpar%myid_chain .eq. 0) then - do i = 1, c%ntab - c%SEDtab(3:,i) = c%SEDtab_buff(3:,i) - end do - end if - - call mpi_bcast(c%SEDtab, size(c%SEDtab), MPI_DOUBLE_PRECISION, & - & 0, data(1)%info%comm, ierr) - end if - - end select - - !go to next component - c => c%nextComp() - end do - - ! Update mixing matrices - call update_mixing_matrices(update_F_int=.true.) - - ! Instead of doing compsep, revert the amplitudes here - if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) - - chisq_prop = 0d0 - call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_prop, & - & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) + if (cpar%myid_chain == 0) then + write(*,fmt='(a,f12.2,a,f12.2,a,f7.3)') " | REJECT -- X^2 = ", chisq_prop, ', dX^2 = ', (chisq_prop - chisq_old), ', X^2/dof = ', chisq_prop/ndof + end if - if (cpar%myid_chain == 0) then - write(*,*) '| ' - write(*,*) '| Chisq reverted back to ', chisq_prop, ' should be ', chisq_old - write(*,*) '| ' - end if + ! Reset parameters to old values + c => compList + do while (associated(c)) + select type (c) + type is (comm_MBBtab_comp) + if (maxval(c%theta_steplen(c%npar+1:,l)) > 0) then + if (cpar%myid_chain .eq. 0) then + do i = 1, c%ntab + c%SEDtab(3:,i) = c%SEDtab_buff(3:,i) + end do + end if + call mpi_bcast(c%SEDtab, size(c%SEDtab), MPI_DOUBLE_PRECISION, & + & 0, data(1)%info%comm, ierr) + end if + end select + c => c%nextComp() + end do - else - if (cpar%myid_chain == 0) then - write(*,*) '| ' - write(*,*) '| MH step accepted' - write(*,*) '| ' - end if + ! Update mixing matrices + call update_mixing_matrices(update_F_int=.true.) + + ! Instead of doing compsep, revert the amplitudes here + if (trim(cpar%mcmc_update_cg_groups(l)) .ne. 'none') call revert_CG_amps(cpar) + + ! Test for proper reset +!!$ chisq_prop = 0d0 +!!$ call compute_chisq(data(1)%info%comm, chisq_fullsky=chisq_prop, & +!!$ & maskpath=cpar%mcmc_samp_group_mask(l), band_list=cpar%mcmc_group_bands_indices(l,:)) +!!$ if (cpar%myid_chain == 0) then +!!$ write(*,*) '| ' +!!$ write(*,*) '| Chisq reverted back to ', chisq_prop, ' should be ', chisq_old +!!$ write(*,*) '| ' +!!$ end if + + else if (cpar%myid_chain == 0) then + write(*,fmt='(a,f12.2,a,f12.2,a,f7.3)') " | ACCEPT -- X^2 = ", chisq_prop, ', dX^2 = ', (chisq_prop - chisq_old), ', X^2/dof = ', chisq_prop/ndof + chisq_old = chisq_prop + mh_accept_stat(l,2) = mh_accept_stat(l,2) + 1 end if - - end do - - if (cpar%myid == 0) then - write(*,*) '| Finished sampling mbbtab' - end if - end subroutine sample_mbbtab_mh subroutine sample_specind_mh(outdir, cpar, handle, handle_noise, l) @@ -996,10 +961,10 @@ subroutine revert_CG_amps(cpar) integer(i4b) :: i, ind class(comm_comp), pointer :: c => null() - if (cpar%myid == 0) then - write(*,*) '| Reverting to buffer values. Did you run sample_maps_with_CG with ' - write(*,*) '| store_buff = .true.?' - end if + !if (cpar%myid == 0) then + ! write(*,*) '| Reverting to buffer values. Did you run sample_maps_with_CG with ' + ! write(*,*) '| store_buff = .true.?' + !end if c => compList do while (associated(c)) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index a45a01ed3..0bdeb79f0 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -1535,11 +1535,12 @@ subroutine compute_symmetric_beam(band, glon, glat, T, bl, beamfile) end subroutine compute_symmetric_beam - subroutine initPtsrcPrecond(comm, samp_group) + subroutine initPtsrcPrecond(comm, samp_group, verbosity) implicit none integer(i4b), intent(in) :: comm, samp_group + integer(i4b), intent(in), optional :: verbosity - integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt, nactive, c1, c2 + integer(i4b) :: i, i1, i2, j, j1, j2, k1, k2, q, l, la, m, n, p, p1, p2, n1, n2, myid, ierr, cnt, nactive, c1, c2, verbosity_ real(dp) :: t1, t2, t3, t4, dist, tot, tot2 logical(lgt) :: skip real(dp), allocatable, dimension(:) :: buff @@ -1550,7 +1551,8 @@ subroutine initPtsrcPrecond(comm, samp_group) if (.not. apply_ptsrc_precond) return if (npre(samp_group) == 0) return - + verbosity_ = 10; if (present(verbosity)) verbosity_ = verbosity + ! Make a list of active components, and check that at least one wants update nactive = 0 skip = .true. @@ -1586,7 +1588,7 @@ subroutine initPtsrcPrecond(comm, samp_group) pt1 => pc(c1)%p if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,10000) == 0) write(*,*) 'Precomp sparsity =', k1, pt1%nsrc, n + if (myid_pre == 0 .and. mod(k1,10000) == 0 .and. verbosity_ > 0) write(*,*) 'Precomp sparsity =', k1, pt1%nsrc, n i1 = i1+1 i2 = pt1%myid do c2 = 1, nactive @@ -1602,7 +1604,7 @@ subroutine initPtsrcPrecond(comm, samp_group) end do end do call mpi_allreduce(MPI_IN_PLACE, n, 1, MPI_INTEGER, MPI_SUM, comm, ierr) - if (myid_pre == 0) write(*,*) 'Number of matrix elements = ', n + if (myid_pre == 0 .and. verbosity_ > 0) write(*,*) 'Number of matrix elements = ', n ! Allocate sparse matrix P_cr(samp_group)%invM_src(1,j)%M => sparse_system(npre(samp_group), n) end if @@ -1614,7 +1616,7 @@ subroutine initPtsrcPrecond(comm, samp_group) pt1 => pc(c1)%p if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,10000) == 0) write(*,*) 'Computing A =', k1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,10000) == 0 .and. verbosity > 0) write(*,*) 'Computing A =', k1, pt1%nsrc i1 = i1+1 i2 = 0 @@ -1683,7 +1685,7 @@ subroutine initPtsrcPrecond(comm, samp_group) ! Construct matrix with sparsity pattern do i1 = 1, P_cr(samp_group)%invM_src(1,j)%M%ni - if (myid_pre == 0 .and. mod(i1,10000) == 0) write(*,*) 'Updating A =', i1, P_cr(samp_group)%invM_src(1,j)%M%ni + if (myid_pre == 0 .and. mod(i1,10000) == 0 .and. verbosity_ > 0) write(*,*) 'Updating A =', i1, P_cr(samp_group)%invM_src(1,j)%M%ni c1 = 1 k1 = i1 do while (k1 > pc(c1)%p%nsrc) @@ -1802,13 +1804,13 @@ subroutine initPtsrcPrecond(comm, samp_group) end do ! Invert matrix to finalize preconditioner call wall_time(t3) - call P_cr(samp_group)%invM_src(1,j)%M%decomp() + call P_cr(samp_group)%invM_src(1,j)%M%decomp(verbosity) call wall_time(t4) - if (myid_pre == 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) + if (myid_pre == 0 .and. verbosity_ > 0) write(*,*) 'ptsrc precond inv = ', real(t4-t3,sp) end if end do call wall_time(t2) - if (myid_pre == 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) + if (myid_pre == 0 .and. verbosity_ > 0) write(*,*) 'ptsrc precond init = ', real(t2-t1,sp) do i = 1, nactive pc(i)%p%recompute_ptsrc_precond = .false. diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index 62cc36fa1..d377ac3f3 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -210,21 +210,23 @@ subroutine dump_components(filename) end subroutine dump_components - subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) + subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise, verbosity) implicit none type(comm_params), intent(in) :: cpar integer(i4b), intent(in) :: samp_group type(planck_rng), intent(inout) :: handle, handle_noise - - integer(i4b) :: stat, i, j, l, m, nactive + integer(i4b), intent(in), optional :: verbosity + + integer(i4b) :: stat, i, j, l, m, nactive, verbosity_ real(dp) :: Nscale = 1.d-4 class(comm_comp), pointer :: c => null() character(len=32) :: cr_active_bands(100) real(dp), allocatable, dimension(:) :: rhs, x, mask class(comm_map), pointer :: res => null() - - + + verbosity_ = cpar%verbosity; if (present(verbosity)) verbosity_ = verbosity + allocate(x(ncr), mask(ncr)) ! Set up component mask for current sample group @@ -296,9 +298,9 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) & handle, handle_noise, mask, samp_group, rhs) call update_status(status, "init_precond1") if (.not. allocated(P_cr)) allocate(P_cr(cpar%cg_num_user_samp_groups)) - call initPrecond(cpar%comm_chain, samp_group) + call initPrecond(cpar%comm_chain, samp_group, verbosity) call update_status(status, "init_precond2") - call solve_cr_eqn_by_CG(cpar, samp_group, x, rhs, stat) + call solve_cr_eqn_by_CG(cpar, samp_group, x, rhs, stat, verbosity) call cr_x2amp(samp_group, x) call update_status(status, "cr_end") deallocate(rhs,x) @@ -308,7 +310,7 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) do while (associated(c)) select type (c) class is (comm_diffuse_comp) - if (c%active_samp_group(samp_group)) call c%applyMonoDipolePrior(handle) + if (c%active_samp_group(samp_group)) call c%applyMonoDipolePrior(handle, verbosity) end select c => c%nextComp() end do @@ -324,12 +326,14 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) call c%x%info%i2lm(i,l,m) if (l == 0) then ! monopole - write(*,fmt='(a)') " | Band monopole of '"//& - & trim(c%label)//"' used as zero-level prior" - write(*,fmt='(a,f14.3)') " | Revert back to pre-CG value: ",& - & c%mono_alm/sqrt(4.d0*pi) - write(*,fmt='(a,f14.3,a)') " | (Sampled value in CG: ",& - & c%x%alm(i,1)/sqrt(4.d0*pi)," )" + if (verbosity_ > 0) then + write(*,fmt='(a)') " | Band monopole of '"//& + & trim(c%label)//"' used as zero-level prior" + write(*,fmt='(a,f14.3)') " | Revert back to pre-CG value: ",& + & c%mono_alm/sqrt(4.d0*pi) + write(*,fmt='(a,f14.3,a)') " | (Sampled value in CG: ",& + & c%x%alm(i,1)/sqrt(4.d0*pi)," )" + end if c%x%alm(i,1) = c%mono_alm ! revert to pre-CG search value !monopole in alm_uKRJ = mu_in_alm_uK_RJ + rms_in_alm_uKRJ * rand_gauss @@ -346,7 +350,7 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise) end subroutine sample_amps_by_CG - subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups) + subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups, verbosity) ! ! ! Convenience function for performing amplitude sampling over @@ -358,12 +362,14 @@ subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups) type(comm_params), intent(in) :: cpar type(planck_rng), intent(inout) :: handle, handle_noise character(len=512), intent(in), optional :: cg_groups + integer(i4b), intent(in), optional :: verbosity - integer(i4b) :: samp_group, i, n + integer(i4b) :: samp_group, i, n, verbosity_ integer(i4b), dimension(MAXSAMPGROUP) :: group_inds character(len=3) :: toks(MAXSAMPGROUP) + verbosity_ = cpar%verbosity; if (present(verbosity)) verbosity_ = verbosity if (present(cg_groups)) then group_inds = 0 @@ -379,12 +385,12 @@ subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups) call timer%start(TOT_AMPSAMP) do samp_group = 1, cpar%cg_num_user_samp_groups if (findloc(group_inds, samp_group, dim=1) == 0) cycle - if (cpar%myid_chain == 0) then + if (cpar%myid_chain == 0 .and. verbosity_ > 0) then write(*,fmt='(a,i4,a,i4,a,i4,a,a)') ' | Chain = ', cpar%mychain, & & ' -- CG sample group = ', samp_group, ' of ', cpar%cg_num_user_samp_groups, ': ', & & trim(cpar%cg_samp_group(samp_group)) end if - call sample_amps_by_CG(cpar, samp_group, handle, handle_noise) + call sample_amps_by_CG(cpar, samp_group, handle, handle_noise, verbosity) if (trim(cpar%cmb_dipole_prior_mask) /= 'none') call apply_cmb_dipole_prior(cpar, handle) @@ -393,11 +399,12 @@ subroutine sample_all_amps_by_CG(cpar, handle, handle_noise, cg_groups) end subroutine sample_all_amps_by_CG - subroutine initPrecond(comm, samp_group) + subroutine initPrecond(comm, samp_group, verbosity) implicit none integer(i4b), intent(in) :: comm, samp_group + integer(i4b), intent(in), optional :: verbosity call initDiffPrecond(comm, samp_group) - call initPtsrcPrecond(comm, samp_group) + call initPtsrcPrecond(comm, samp_group, verbosity) call initTemplatePrecond(comm, samp_group) end subroutine initPrecond diff --git a/commander3/src/comm_sparse_mod.f90 b/commander3/src/comm_sparse_mod.f90 index 75ad94c4e..3aca67c33 100644 --- a/commander3/src/comm_sparse_mod.f90 +++ b/commander3/src/comm_sparse_mod.f90 @@ -138,11 +138,12 @@ subroutine sparse_system_set_rhs(self, b) end if end subroutine sparse_system_set_rhs - subroutine sparse_system_decomp(self) + subroutine sparse_system_decomp(self, verbosity) implicit none class(sparse_system), intent(inout) :: self + integer(i4b), intent(in), optional :: verbosity - integer(i4b) :: solver, error, phase + integer(i4b) :: solver, error, phase, msglvl ! Initialize PARDISO solver solver = 10 ! use sparse direct method @@ -152,9 +153,10 @@ subroutine sparse_system_decomp(self) ! Symbolic factorization phase = 11 ! only reordering and symbolic factorization self%iparm(33) = 1 ! compute determinant + msglvl = self%msglvl; if (present(verbosity)) msglvl = verbosity call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & - & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) + & self%idum, self%nrhs, self%iparm, msglvl, self%ddum, self%ddum, error) if (error /= 0) THEN write(*,*) 'pardiso symbolic factorization error: ', error stop @@ -167,7 +169,7 @@ subroutine sparse_system_decomp(self) phase = 22 call pardiso(self%pt, self%maxfct, self%mnum, self%mtype, phase, self%n, & & self%a(1:self%nj), self%ia(1:self%ni+1), self%ja(1:self%nj), & - & self%idum, self%nrhs, self%iparm, self%msglvl, self%ddum, self%ddum, error) + & self%idum, self%nrhs, self%iparm, msglvl, self%ddum, self%ddum, error) if (error /= 0) THEN write(*,*) 'pardiso factorization error: ', error stop diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index c15ecb2d6..62171aa52 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -491,6 +491,9 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, deallocate(d_calib) end do + ! Synchronize and output flagging statistics in first iteration + if (self%first_call) call self%report_dynamic_mask_stats + if (self%myid == 0) write(*,*) ' --> Finalizing maps, bp' ! Output latest scan list with new timing information diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 8f72f295a..badd45aea 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -50,7 +50,7 @@ module comm_tod_mod real(sp), allocatable, dimension(:,:) :: diode ! (ndiode, ntod) array of undifferenced data type(byte_pointer), allocatable, dimension(:) :: zdiode ! pointers to the compressed undifferenced diode data, len (ndiode) byte, allocatable, dimension(:) :: flag ! Compressed detector flag; 0 is accepted, /= 0 is rejected - integer(i4b), allocatable, dimension(:,:) :: mask_dyn ! Dynamic online-generated mask, (2,ntod), each row gives a range of masked samples + integer(i4b), allocatable, dimension(:,:) :: mask_dyn ! Dynamic online-generated mask, (2,ntod), each row gives a range of masked sample type(byte_pointer), allocatable, dimension(:) :: pix ! pointer array of pixels length nhorn type(byte_pointer), allocatable, dimension(:) :: psi ! pointer array of psi, length nhorn integer(i4b), allocatable, dimension(:,:) :: offset_range ! Beginning and end tod index of every offset region @@ -62,7 +62,17 @@ module comm_tod_mod real(sp), allocatable, dimension(:,:) :: earth_elon ! Earth elongation, for sidelobe mapping and masking ! Zodi sampling structures (downsampled and precomputed quantities. only allocated if zodi sampling is true) - logical(lgt), allocatable, dimension(:) :: zodi_glitch_mask + logical(lgt), allocatable, dimension(:) :: zodi_glitch_mask +! integer(i4b), allocatable, dimension(:) :: downsamp_pix_full +! real(sp), allocatable, dimension(:) :: downsamp_tod_full +! real(sp), allocatable, dimension(:) :: downsamp_sky_full +! real(sp), allocatable, dimension(:) :: downsamp_zodi_full +! real(sp), allocatable, dimension(:, :) :: downsamp_scat_full +! real(sp), allocatable, dimension(:, :) :: downsamp_therm_full +! real(sp), allocatable, dimension(:, :) :: downsamp_point_full ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} +! real(sp), allocatable, dimension(:, :) :: s_scat_lowres_full +! real(sp), allocatable, dimension(:, :) :: s_therm_lowres_full + integer(i4b), allocatable, dimension(:) :: downsamp_pix real(sp), allocatable, dimension(:) :: downsamp_tod real(sp), allocatable, dimension(:) :: downsamp_sky @@ -70,7 +80,6 @@ module comm_tod_mod real(sp), allocatable, dimension(:, :) :: downsamp_scat real(sp), allocatable, dimension(:, :) :: downsamp_therm real(sp), allocatable, dimension(:, :) :: downsamp_point ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} - real(sp), allocatable, dimension(:, :) :: s_scat_lowres real(sp), allocatable, dimension(:, :) :: s_therm_lowres end type comm_detscan @@ -217,6 +226,7 @@ module comm_tod_mod real(dp), pointer, dimension(:,:) :: map_solar ! Full-sky solar centric/sidelobe model real(dp), pointer, dimension(:,:) :: map_moon ! Full-sky Moon centric/sidelobe model real(dp), pointer, dimension(:) :: map_earth ! Earth elongation centric/sidelobe model + integer(i4b), dimension(-1:9) :: mask_dyn_stats = 0 ! Statistics for dynamic mask (ntod_tot, ncut_base, ncut_1, ncut_2,...) real(sp), allocatable, dimension(:,:) :: pixhist ! TOD summary from histograms; {mean, rms, nhit, min, max}, NESTED ordering ! class(comm_map), pointer :: map_solar => null() ! Solar centric/sidelobe model class(comm_mapinfo), pointer :: info => null() ! Map definition @@ -306,6 +316,7 @@ module comm_tod_mod procedure :: precompute_zodi_lookups procedure :: clear_zodi_cache procedure :: create_dynamic_mask + procedure :: report_dynamic_mask_stats procedure :: get_s_static end type comm_tod @@ -3265,8 +3276,10 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres ntot = count(iand(flag,self%flag0) .eq. 0) nmax = 1000 gain = self%scans(scan)%d(det)%gain + self%mask_dyn_stats(-1) = self%mask_dyn_stats(-1) + ntod + self%mask_dyn_stats( 0) = self%mask_dyn_stats( 0) + ntod - ntot ! Number of samples removed by base flagging - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flags -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, base flags -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ntod-ntot,sp) / ntod, ntod ! Generate dynamic mask allocate(mask_dyn(ntod)) @@ -3296,7 +3309,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end if end if end do - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, pixhist -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, pixhist -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(1) = self%mask_dyn_stats(1) + ncut end if if (threshold(2) > 0) then @@ -3310,7 +3324,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres ncut = ncut + 1 end if end do - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, extreme -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(2) = self%mask_dyn_stats(2) + ncut end if ! Single sample outlier cut; potentially iterate in order to adjust the threshold rms @@ -3360,7 +3375,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(cut) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single spikes-- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single spikes-- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(3) = self%mask_dyn_stats(3) + ncut end if if (threshold(4) > 0.) then @@ -3387,7 +3403,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, small window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(4) = self%mask_dyn_stats(4) + ncut end if if (threshold(5) > 0.) then @@ -3414,7 +3431,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, broad window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(5) = self%mask_dyn_stats(5) + ncut end if !!$ open(58, file='var4.dat') @@ -3447,7 +3465,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do if (output_scan == self%scanid(scan)) close(58) deallocate(var_window) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, 500 window -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(6) = self%mask_dyn_stats(6) + ncut end if if (threshold(7) > 0.) then @@ -3473,7 +3492,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres flag(ntod) = flag(ntod) + flag_dyn ncut = ncut + 1 end if - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, single samp -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(7) = self%mask_dyn_stats(7) + ncut end if if (threshold(8) > 0.) then @@ -3497,7 +3517,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end if end do if (output_scan == self%scanid(scan)) close(58) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, consecutive -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(8) = self%mask_dyn_stats(8) + ncut end if if (output_scan == self%scanid(scan)) then @@ -3550,7 +3571,8 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres end do end if - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, solar elong -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(ncut,sp) / ntod, ncut + self%mask_dyn_stats(9) = self%mask_dyn_stats(9) + ncut end if if (output_scan == self%scanid(scan)) then @@ -3604,7 +3626,7 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres if (n > 0) then allocate(self%scans(scan)%d(det)%mask_dyn(2,n)) self%scans(scan)%d(det)%mask_dyn = bad(:,1:n) - write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(iand(flag,self%flag0) .ne. 0),sp) / ntod, count(iand(flag,self%flag0) .ne. 0), ntod + !write(*,fmt='(a,a,i6,i4,a,f8.5,i8,i8)') ' Dynamic mask, total -- ', trim(self%freq), self%scanid(scan), det, ' = ', real(count(iand(flag,self%flag0) .ne. 0),sp) / ntod, count(iand(flag,self%flag0) .ne. 0), ntod end if if (count(iand(flag,self%flag0) .eq. 0) == 0) then @@ -3615,6 +3637,34 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres deallocate(bad, mask_dyn) end subroutine create_dynamic_mask + subroutine report_dynamic_mask_stats(self) + implicit none + class(comm_tod), intent(in) :: self + + integer(i4b) :: ierr, ntod + + ! Synchronize stats across cores + call mpi_allreduce(MPI_IN_PLACE, self%mask_dyn_stats, size(self%mask_dyn_stats), MPI_INTEGER, MPI_SUM, self%comm, ierr) + + if (self%myid == 0) then + ntod = self%mask_dyn_stats(-1) + write(*,fmt='(a,a,a)') 'TOD flagging stats for ', trim(self%freq), ' ( frac, ntot )' + write(*,fmt='(a,f8.5,i16)') ' Total number of samples = ', real(self%mask_dyn_stats(-1),sp)/ntod, ntod + write(*,fmt='(a,f8.5,i16)') ' Base flagging = ', real(self%mask_dyn_stats( 0),sp)/ntod, self%mask_dyn_stats( 0) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, pixhist = ', real(self%mask_dyn_stats( 1),sp)/ntod, self%mask_dyn_stats( 1) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, extreme = ', real(self%mask_dyn_stats( 2),sp)/ntod, self%mask_dyn_stats( 2) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, single spikes = ', real(self%mask_dyn_stats( 3),sp)/ntod, self%mask_dyn_stats( 3) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, 5 window = ', real(self%mask_dyn_stats( 4),sp)/ntod, self%mask_dyn_stats( 4) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, 50 window = ', real(self%mask_dyn_stats( 5),sp)/ntod, self%mask_dyn_stats( 5) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, 500 window = ', real(self%mask_dyn_stats( 6),sp)/ntod, self%mask_dyn_stats( 6) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, single samp = ', real(self%mask_dyn_stats( 7),sp)/ntod, self%mask_dyn_stats( 7) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, consecutive = ', real(self%mask_dyn_stats( 8),sp)/ntod, self%mask_dyn_stats( 8) + write(*,fmt='(a,f8.5,i16)') ' Dynamic mask, solar mask = ', real(self%mask_dyn_stats( 9),sp)/ntod, self%mask_dyn_stats( 9) + write(*,fmt='(a,f8.5,i16)') ' Final accept ratio = ', real(ntod-sum(self%mask_dyn_stats(0:9)),sp)/ntod, ntod-sum(self%mask_dyn_stats(0:9)) + end if + + end subroutine report_dynamic_mask_stats + subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) implicit none class(comm_tod), intent(in) :: tod diff --git a/commander3/src/comm_tod_pixhist_mod.f90 b/commander3/src/comm_tod_pixhist_mod.f90 index d30bb0c83..81f61f5bd 100644 --- a/commander3/src/comm_tod_pixhist_mod.f90 +++ b/commander3/src/comm_tod_pixhist_mod.f90 @@ -68,7 +68,7 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) iter = 0 do while (refine) iter = iter + 1 - if (tod%myid == 0) write(*,*) 'Pixhist, band = ', trim(tod%freq), ', iter = ', iter + !if (tod%myid == 0) write(*,*) 'Pixhist, band = ', trim(tod%freq), ', iter = ', iter ! Build histogram hist = 0. @@ -190,6 +190,7 @@ subroutine compute_tod_pixhist(tod, map_sky, map_gain, procmask, procmask2) write(58,*) tod%pixhist(5,i), 2.*maxval(P) end if end do + if (tod%myid == 0) write(*,fmt='(a,a,a,i6)') ' --> Pixhist, band = ', trim(tod%freq), ', numiter = ', iter deallocate(delta, hist) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 6a6dea8fb..99676b2ea 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -32,10 +32,6 @@ program commander type(planck_rng) :: handle, handle_noise character(len=6) :: samptext - ! param_vec for zodi (REMOVE THIS AFTER ATLAS) - ! type(zodi_model) :: current_model, previous_model - ! real(dp), allocatable :: param_vec(:) - type(comm_mapinfo), pointer :: info => null() type(comm_map), pointer :: m => null() class(comm_comp), pointer :: c1 => null() @@ -78,10 +74,7 @@ program commander call print_help() call exit(0) case default - !print '(2a, /)', 'Unrecognised command-line option: ', arg - !call print_help() - !call exit(0) - exit comm3_args + exit comm3_args end select end do comm3_args !---------------------------------------------------------------------------------- @@ -116,30 +109,6 @@ program commander !!! write(*,*) "last", param_test(1) !!! end if -!!$ n = 100000 -!!$ q = 100000 -!!$ allocate(arr(n)) -!!$ do i = 1, n -!!$ allocate(arr(i)%p(q)) -!!$ arr(i)%p = i -!!$ if (mod(i,1000) == 0) then -!!$ write(*,*) 'up', arr(i)%p(6) -!!$ call update_status(status, "debug") -!!$ end if -!!$ end do -!!$ -!!$ do i = 1, n -!!$ deallocate(arr(i)%p) -!!$ if (mod(i,1000) == 0) then -!!$ write(*,*) 'down', i -!!$ call update_status(status, "debug2") -!!$ end if -!!$ end do -!!$ deallocate(arr) -!!$ stop - - - if (iargc() == 0) then if (cpar%myid == cpar%root) write(*,*) 'Usage: commander [parfile] {sample restart}' call MPI_Finalize(ierr) @@ -160,8 +129,6 @@ program commander write(*,fmt='(a,i12,t70,a)') ' | Number of chains = ', cpar%numchain, '|' write(*,fmt='(a,i12,t70,a)') ' | Number of processors in first chain = ', cpar%numprocs_chain, '|' write(*,fmt='(a,t70,a)') ' |', '|' -! write(*,fmt='(a,f12.3,a,t70,a)') ' | Time to initialize run = ', t2-t0, ' sec', '|' -! write(*,fmt='(a,f12.3,a,t70,a)') ' | Time to read in parameters = ', t3-t1, ' sec', '|' write(*,fmt='(a)') ' ---------------------------------------------------------------------' end if @@ -211,24 +178,6 @@ program commander if (trim(adjustl(cpar%zs_init_ascii)) /= 'none') call ascii_to_zodi_model(cpar, zodi_model, cpar%zs_init_ascii) end if -!!$ samp_group = 1 -!!$ npar = count(zodi_model%theta_stat(:,samp_group)==0) -!!$ allocate(theta_old(npar)) -!!$ call zodi_model%model_to_params(theta_old, samp_group) -!!$ if (cpar%myid == cpar%root) then -!!$ do i = 1, npar -!!$ write(*,*) i, theta_old(i) -!!$ end do -!!$ end if -!!$ call mpi_finalize(ierr) -!!$ stop - - - - -!write(*,*) 'Setting gain to 1' -!data(6)%gain = 1.d0 - ! Make sure TOD and BP modules agree on initial bandpass parameters ok = trim(cpar%cs_init_inst_hdf) /= 'none' if (ok) ok = trim(cpar%init_chain_prefix) /= 'none' @@ -256,7 +205,6 @@ program commander ! ************************************************************** if (cpar%myid == cpar%root .and. cpar%verbosity > 0) then - !write(*,*) '|' write(*,fmt='(a)') ' ---------------------------------------------------------------------' write(*,fmt='(a,f12.3,a)') ' | Time to read data = ', t2-t1, ' sec' write(*,*) '| Starting Gibbs sampling' @@ -264,21 +212,16 @@ program commander ! Prepare chains call init_chain_file(cpar, first_sample) - !first_sample = 1 if (first_sample == -1) then call output_FITS_sample(cpar, 0, .true.) ! Output initial point to sample 0 first_sample = 1 else ! Re-initialise seeds and reinitialize call initialize_mpi_struct(cpar, handle, handle_noise, reinit_rng=first_sample) - !first_sample = 10 - !first_sample=first_sample-1 ! Reject last sample, which may be corrupt call initialize_from_chain(cpar, handle, init_samp=first_sample, init_from_output=.true., first_call=.true.) first_sample = first_sample+1 end if call timer%stop(TOT_INIT) - !data(1)%bp(0)%p%delta(1) = data(1)%bp(0)%p%delta(1) + 0.2 - !data(2)%bp(0)%p%delta(1) = data(1)%bp(0)%p%delta(1) + 0.2 ! Run Gibbs loop @@ -286,13 +229,6 @@ program commander first = .true. first_zodi = .true. modfact = 1; if (cpar%enable_TOD_analysis .and. cpar%sample_zodi .and. (cpar%sample_signal_amplitudes .or. cpar%sample_specind .or. cpar%mcmc_num_samp_groups > 0)) modfact = 2 - !---------------------------------------------------------------------------------- - ! Part of Simulation routine - !---------------------------------------------------------------------------------- - ! Will make only one full gibbs loop to produce simulations - !if (cpar%enable_tod_simulations) cpar%num_gibbs_iter = 2 - !---------------------------------------------------------------------------------- - do while (iter <= cpar%num_gibbs_iter) ok = .true. @@ -317,6 +253,7 @@ program commander call update_mixing_matrices(update_F_int=.true.) end if end if + !---------------------------------------------------------------------------------- ! Part of Simulation routine !---------------------------------------------------------------------------------- @@ -326,37 +263,11 @@ program commander call copy_tod(cpar, ierr) call write_filelists_to_disk(cpar, ierr) end if + !---------------------------------------------------------------------------------- ! Process TOD structures if (iter > 0 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then !if (iter == 1 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then - - ! Create zodi atlas - ! if (.false.) then - ! allocate(param_vec(base_zodi_model%N_PARAMETERS)) - ! do i = 1, base_zodi_model%N_PARAMETERS - ! if (cpar%myid == cpar%root) print *, "Creating zodi atlas for parameter: ", i - ! do j = 1, 3 - ! base_zodi_model = sampled_zodi_model - ! base_zodi_model%param_i = i - ! base_zodi_model%up_down_j = j - - ! param_vec = base_zodi_model%model_to_param_vec() - ! if (j == 1) then - ! param_vec(i) = param_vec(i) - 0.1*param_vec(i) - ! else if (j == 3) then - ! param_vec(i) = param_vec(i) + 0.1*param_vec(i) - ! end if - ! call base_zodi_model%param_vec_to_model(param_vec) - ! call process_all_TODs(cpar, cpar%mychain, iter, handle) - ! end do - ! end do - ! end if - - ! if (iter == 1) then ! For faster component separation since we dont sample the cios - - ! First iteration should just be component separation, in case sky model - ! is off call timer%start(TOT_TODPROC) call process_all_TODs(cpar, cpar%mychain, iter, handle) call timer%stop(TOT_TODPROC) @@ -367,80 +278,41 @@ program commander exit end if + ! Sample zodi parameters if (mod(iter,modfact) == 0 .and. iter > 1 .and. cpar%enable_TOD_analysis .and. cpar%sample_zodi) then -! if (.true. .and. cpar%include_tod_zodi) then - call timer%start(TOT_ZODI_SAMP) - call project_and_downsamp_sky(cpar) - call downsamp_invariant_structs(cpar) - if (first_zodi) then - ! in the first tod gibbs iter we precompute timeinvariant downsampled quantities - call precompute_lowres_zodi_lookups(cpar) - else - call apply_zodi_glitch_mask(cpar) - end if - -!!$ do i = 1, zodi_model%n_comps -!!$ write(*,*) 'n0', zodi_model%comps(i)%c%n_0 -!!$ end do -!!$ do i = 1, numband -!!$ write(*,*) 'emissivity', data(i)%tod%zodi_emissivity, data(i)%tod%zodi_albedo -!!$ end do - + call timer%start(TOT_ZODI_SAMP) + call project_and_downsamp_sky(cpar) + call downsamp_invariant_structs(cpar) + if (first_zodi) then + ! in the first tod gibbs iter we precompute timeinvariant downsampled quantities + call precompute_lowres_zodi_lookups(cpar) + else + call apply_zodi_glitch_mask(cpar) + end if - call compute_downsamp_zodi(cpar, zodi_model) - if (first_zodi) then - !call sample_linear_zodi(cpar, handle, iter, zodi_model, verbose=.true.) - call compute_downsamp_zodi(cpar, zodi_model) - call create_zodi_glitch_mask(cpar, handle) - first_zodi = .false. - end if - call apply_zodi_glitch_mask(cpar) - !write(*,*) 'disabling glitch mask' - - ! Sample non-stationary zodi components with geometric 3D model - select case (trim(adjustl(cpar%zs_sample_method))) - case ("powell") - do i = 1, cpar%zs_num_samp_groups - if (iter > 1) call minimize_zodi_with_powell(cpar, iter, handle, i) - end do - end select - - ! Sample stationary components - !if (first_zodi) then - if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') - if (cpar%sample_solar_maps) call sample_static_zodi_map(cpar, handle, 'solar') - if (cpar%sample_moon_maps) call sample_static_zodi_map(cpar, handle, 'moon') - !end if - + call compute_downsamp_zodi(cpar, zodi_model) + if (first_zodi) then + !call compute_downsamp_zodi(cpar, zodi_model) + call create_zodi_glitch_mask(cpar, handle) + first_zodi = .false. + end if + call apply_zodi_glitch_mask(cpar) + + ! Sample non-stationary zodi components with geometric 3D model + select case (trim(adjustl(cpar%zs_sample_method))) + case ("powell") + do i = 1, cpar%zs_num_samp_groups + if (iter > 1) call minimize_zodi_with_powell(cpar, iter, handle, i) + end do + end select + + ! Sample stationary components + !if (first_zodi) then + if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') + if (cpar%sample_solar_maps) call sample_static_zodi_map(cpar, handle, 'solar') + if (cpar%sample_moon_maps) call sample_static_zodi_map(cpar, handle, 'moon') + !end if -!!$ if (mod(iter-2,10) == 0) then -!!$ call zodi_model%params_to_model([& -!!$ & 1.198d-7 + 0d-9*rand_gauss(handle), & -!!$ & 2.10d0 + 0.0d0*rand_gauss(handle), & -!!$ & 78.01d0 + 0.d0* rand_gauss(handle), & -!!$ & 3.72d-2 + 0.000d0 * rand_gauss(handle), & -!!$ & 8.71d-3 + 0.000d0 * rand_gauss(handle), & -!!$ & -2.14d-3 + 0.000d0 * rand_gauss(handle), & -!!$ & 0.951d0 + 0.00d0*rand_gauss(handle), & -!!$ & 3.50d0 + 0.00d0*rand_gauss(handle), & -!!$ & 0.822d0 + 0.00d0*rand_gauss(handle), & -!!$ & 0.183d0 + 0.00d0*rand_gauss(handle), & -!!$ & 1d-9 + 3d-10*rand_gauss(handle), & -!!$ & 0.d0, & -!!$ & 0.d0, & -!!$ & 0.d0, & -!!$ & 0.d0, & -!!$ & 0.d0, & -!!$ & 1.d0 + 0.3d0*rand_gauss(handle), & -!!$ & 3.d0 + 0.3*rand_gauss(handle), & -!!$ & 286d0, 0.466863d0]) -!!$ end if -!!$ if (mod(iter-1,2) == 0) then -!!$ call sample_zodi_group(cpar, handle, iter, zodi_model, verbose=.true.) -!!$ else -!!$ call minimize_zodi_with_powell(cpar) -!!$ end if - call timer%stop(TOT_ZODI_SAMP) end if @@ -511,14 +383,6 @@ program commander if (mod(iter,cpar%thinning) == 0) call output_FITS_sample(cpar, iter, .true.) call timer%stop(TOT_OUTPUT) - ! Sample partial-sky templates - !call sample_partialsky_tempamps(cpar, handle) - - !call output_FITS_sample(cpar, 1000, .true.) - - - - call wall_time(t2) if (ok) then if (cpar%myid_chain == 0) then From 21a0ef2f97e759c63c7c0f1a6629ef3676e6d4c3 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Fri, 11 Apr 2025 09:07:19 +0200 Subject: [PATCH 143/171] Started simplifying zodi_mod; fixing various bugs on the way --- commander3/config/config.ita_internal | 4 +- commander3/src/comm_defs.f90 | 2 +- commander3/src/comm_param_mod.f90 | 3 + commander3/src/comm_ptsrc_comp_mod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 41 +- commander3/src/comm_zodi_mod.f90 | 5 +- commander3/src/comm_zodi_samp_mod.f90 | 1388 ++++-------------------- commander3/src/commander.f90 | 32 +- 8 files changed, 236 insertions(+), 1241 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index 0a76cd9d7..eb9ef14dd 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -49,10 +49,10 @@ export MPCC := mpiicc # =========== Compiler Optimizations ============= #main -export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 +#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. +export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/src/comm_defs.f90 b/commander3/src/comm_defs.f90 index f821fd315..f217c16df 100644 --- a/commander3/src/comm_defs.f90 +++ b/commander3/src/comm_defs.f90 @@ -33,7 +33,7 @@ module comm_defs real(dp) :: v_solar(3)= [0.d0, 0.d0, 0.d0] real(dp) :: EXP_OVERFLOW = 700.d0 real(dp) :: SECOND_TO_DAY = 1.1574074074074073e-05 - integer(i4b) :: zodi_nside = 64 + integer(i4b) :: zodi_nside = 512 !************************************************** ! Counters diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index 76a2e1bb0..fb61efc71 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -292,6 +292,7 @@ module comm_param_mod character(len=2048) :: zs_comp_labels(MAXZODICOMPS), zs_comp_types(MAXZODICOMPS), zs_init_hdf(MAXZODICOMPS), zs_sample_method, zs_init_ascii, zs_refband, zs_em_global, zs_al_global character(len=2048) :: zs_wiring character(len=2048), allocatable :: zs_samp_groups(:), zs_samp_group_bands(:) + real(dp), allocatable :: zs_samp_group_max_b_ecl(:) logical(lgt) :: zs_output_comps, zs_output_ascii, zs_joint_mono, zs_output_tod_res type(InterplanetaryDustParamLabels) :: zodi_param_labels @@ -3110,10 +3111,12 @@ subroutine read_zodi_params_hash(htbl, cpar) call get_parameter_hashtable(htbl, 'ZODI_RMS_RANDOMIZE_BETWEEN_STEPS', par_dp=cpar%zs_randomize_rms) allocate(cpar%zs_samp_groups(cpar%zs_num_samp_groups)) allocate(cpar%zs_samp_group_bands(cpar%zs_num_samp_groups)) + allocate(cpar%zs_samp_group_max_b_ecl(cpar%zs_num_samp_groups)) do i = 1, cpar%zs_num_samp_groups call int2string(i, itext2) call get_parameter_hashtable(htbl, 'ZODI_SAMPLING_GROUP'//itext2, par_string=cpar%zs_samp_groups(i)) call get_parameter_hashtable(htbl, 'ZODI_SAMPLING_GROUP_BANDS'//itext2, par_string=cpar%zs_samp_group_bands(i)) + call get_parameter_hashtable(htbl, 'ZODI_SAMPLING_GROUP_MAX_ECL_LAT'//itext2, par_dp=cpar%zs_samp_group_max_b_ecl(i)) end do end if diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 0bdeb79f0..c116b59cf 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -1616,7 +1616,7 @@ subroutine initPtsrcPrecond(comm, samp_group, verbosity) pt1 => pc(c1)%p if (j > pt1%nmaps) cycle do k1 = 1, pt1%nsrc - if (myid_pre == 0 .and. mod(k1,10000) == 0 .and. verbosity > 0) write(*,*) 'Computing A =', k1, pt1%nsrc + if (myid_pre == 0 .and. mod(k1,10000) == 0 .and. verbosity_ > 0) write(*,*) 'Computing A =', k1, pt1%nsrc i1 = i1+1 i2 = 0 diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index badd45aea..0c169c69e 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -62,26 +62,28 @@ module comm_tod_mod real(sp), allocatable, dimension(:,:) :: earth_elon ! Earth elongation, for sidelobe mapping and masking ! Zodi sampling structures (downsampled and precomputed quantities. only allocated if zodi sampling is true) - logical(lgt), allocatable, dimension(:) :: zodi_glitch_mask -! integer(i4b), allocatable, dimension(:) :: downsamp_pix_full -! real(sp), allocatable, dimension(:) :: downsamp_tod_full -! real(sp), allocatable, dimension(:) :: downsamp_sky_full -! real(sp), allocatable, dimension(:) :: downsamp_zodi_full -! real(sp), allocatable, dimension(:, :) :: downsamp_scat_full -! real(sp), allocatable, dimension(:, :) :: downsamp_therm_full -! real(sp), allocatable, dimension(:, :) :: downsamp_point_full ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} -! real(sp), allocatable, dimension(:, :) :: s_scat_lowres_full -! real(sp), allocatable, dimension(:, :) :: s_therm_lowres_full + logical(lgt), allocatable, dimension(:,:) :: zodi_glitch_mask + integer(i4b), allocatable, dimension(:) :: downsamp_pix_full + real(sp), allocatable, dimension(:) :: downsamp_tod_full + real(sp), allocatable, dimension(:) :: downsamp_sky_full + real(sp), allocatable, dimension(:,:) :: downsamp_point_full ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} + real(sp), allocatable, dimension(:) :: downsamp_obs_time_full ! downsampled_obs_time used for zodi sampling +!!$ real(sp), allocatable, dimension(:) :: downsamp_zodi_full +!!$ real(sp), allocatable, dimension(:, :) :: downsamp_scat_full +!!$ real(sp), allocatable, dimension(:, :) :: downsamp_therm_full +!!$ real(sp), allocatable, dimension(:, :) :: s_scat_lowres_full +!!$ real(sp), allocatable, dimension(:, :) :: s_therm_lowres_full - integer(i4b), allocatable, dimension(:) :: downsamp_pix - real(sp), allocatable, dimension(:) :: downsamp_tod - real(sp), allocatable, dimension(:) :: downsamp_sky - real(sp), allocatable, dimension(:) :: downsamp_zodi - real(sp), allocatable, dimension(:, :) :: downsamp_scat - real(sp), allocatable, dimension(:, :) :: downsamp_therm - real(sp), allocatable, dimension(:, :) :: downsamp_point ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} - real(sp), allocatable, dimension(:, :) :: s_scat_lowres - real(sp), allocatable, dimension(:, :) :: s_therm_lowres + integer(i4b), allocatable, dimension(:) :: downsamp_pix + real(sp), allocatable, dimension(:) :: downsamp_tod + real(sp), allocatable, dimension(:) :: downsamp_sky + real(sp), allocatable, dimension(:,:) :: downsamp_point ! (ntod,{lat_gal, lon_gal, lat_ecl, lon_ecl, solar elongation} + real(sp), allocatable, dimension(:) :: downsamp_obs_time ! downsampled_obs_time used for zodi sampling +!!$ real(sp), allocatable, dimension(:) :: downsamp_zodi +!!$ real(sp), allocatable, dimension(:, :) :: downsamp_scat +!!$ real(sp), allocatable, dimension(:, :) :: downsamp_therm +!!$ real(sp), allocatable, dimension(:, :) :: s_scat_lowres +!!$ real(sp), allocatable, dimension(:, :) :: s_therm_lowres end type comm_detscan ! Stores information about all detectors at once @@ -108,7 +110,6 @@ module comm_tod_mod type(huffcode) :: todkey ! Huffman decompression key integer(i4b) :: chunk_num ! Absolute number of chunk in the data files integer(i4b), allocatable, dimension(:,:) :: zext ! Extension of compressed diode arrays - real(sp), allocatable, dimension(:) :: downsamp_obs_time ! downsampled_obs_time used for zodi sampling class(comm_detscan), allocatable, dimension(:) :: d ! Array of all detectors end type comm_scan diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 68ad4db2d..da57396ba 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -1248,6 +1248,7 @@ end subroutine samp_group2stat subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, model, use_lowres_pointing, comp) + implicit none ! Returns the predicted zodiacal emission for a scan (chunk of time-ordered data). ! ! Parameters @@ -1312,7 +1313,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod use_lowres = .false. else if (.not. allocated(tod%zodi_therm_cache_lowres)) stop "zodi cache not allocated. `use_lowres_pointing` should only be true when sampling zodi." - if (.not. allocated(tod%scans(scan)%downsamp_obs_time)) then + if (.not. allocated(tod%scans(scan)%downsamp_obs_time_full)) then print *, tod%zodiband, scan, "lowres obs_time not allocated" stop end if @@ -1328,7 +1329,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod ! Reset cache if time between last cache update and current time is larger than `delta_t_reset`. ! NOTE: this cache is only effective if the scans a core handles are in chronological order. if (use_lowres) then - obs_time = tod%scans(scan)%downsamp_obs_time(i) + obs_time = tod%scans(scan)%downsamp_obs_time_full(i) else obs_time = obs_time + dt_tod ! assumes a time continuous TOD end if diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 4d6c24141..026d1324b 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -6,8 +6,8 @@ module comm_zodi_samp_mod private public initialize_zodi_samp_mod, downsamp_invariant_structs, project_and_downsamp_sky, compute_downsamp_zodi - public minimize_zodi_with_powell, get_chisq_priors, precompute_lowres_zodi_lookups, create_zodi_glitch_mask - public apply_zodi_glitch_mask, sample_static_zodi_map!, sample_static_zodi_amps + public minimize_zodi_with_powell, get_chisq_priors, precompute_lowres_zodi_lookups, create_zodi_sampgroup_mask + public apply_zodi_sampgroup_mask, sample_static_zodi_map!, sample_static_zodi_amps real(dp), allocatable :: chisq_previous, step_size, prior_vec(:, :), prior_vec_powell(:, :), step_sizes_emissivity(:, :), step_sizes_albedo(:, :), step_sizes_ipd(:), step_sizes_n0(:), theta_0(:) real(dp), allocatable :: powell_emissivity(:, :), powell_albedo(:, :) @@ -59,14 +59,6 @@ subroutine initialize_zodi_samp_mod(cpar) end subroutine initialize_zodi_samp_mod - function get_boxwidth(samprate_lowres, samprate) result(box_width) - ! Returns the boxcar width for downsampling the zodi tods - real(dp), intent(in) :: samprate_lowres, samprate - real(dp) :: box_width - box_width = max(real(nint(samprate/samprate_lowres),dp),1.d0) - end function - - function get_chisq_priors(params, samp_group) result(chisq_prior) implicit none @@ -115,23 +107,25 @@ function get_chisq_priors(params, samp_group) result(chisq_prior) end if end function get_chisq_priors - subroutine downsamp_invariant_structs(cpar) - ! Downsamples pointing, tod and caches the zodi mask (sky mask + flags) + ! Downsamples pointing, tod and caches the zodi mask (sky mask + flags) + subroutine downsamp_invariant_structs(cpar) + implicit none type(comm_params), intent(in) :: cpar - integer(i4b) :: i, j, k, l, g, scan, npix, nmaps, ndelta, ext(2), padding, ierr, ntod, ndet, nhorn, ndownsamp, box_halfwidth - real(dp) :: box_width, dt_tod, theta, phi, vec0(3), vec1(3), M_ecl2gal(3,3), day, lambda_solar, lat, lon - real(sp), allocatable :: tod(:), mask(:), downsamp_vec(:, :), s_static(:) + integer(i4b) :: i, j, k, kp, l, g, scan, nside, npix, nmaps, ext(2), padding, ierr, ntod, ndet, nhorn, ndownsamp, box_halfwidth, thin, ntod_lowres + real(dp) :: dt_tod, theta, phi, vec0(3), vec1(3), M_ecl2gal(3,3), day, lambda_solar, lat, lon + real(sp), allocatable :: tod(:), downsamp_vec(:, :), s_static(:) integer(i4b), allocatable :: pix(:, :), psi(:, :), flag(:) real(dp), allocatable, dimension(:, :) :: m_buf, vec integer(i4b), allocatable, dimension(:) :: downsamp_pix logical(lgt), allocatable, dimension(:) :: downsamp_mask_idx real(sp), allocatable, dimension(:) :: downsamp_mask, downsamp_tod, downsamp_obs_time, obs_time real(sp), allocatable, dimension(:) :: procmask_zodi + logical(sp), allocatable, dimension(:) :: mask type(hdf_file) :: tod_file character(len=4) :: scan_str + type(comm_detscan), pointer :: d - padding = 5 if (cpar%myid == cpar%root) print *, "downsampling tod and pointing" ! For each zodi band, create downsampled residual time stream @@ -142,113 +136,67 @@ subroutine downsamp_invariant_structs(cpar) if (trim(data(i)%tod_type) == 'none') cycle if (.not. data(i)%tod%subtract_zodi) cycle - ndelta = 1 - npix = 12*data(i)%map%info%nside**2 + nside = data(i)%map%info%nside + npix = nside nmaps = data(i)%map%info%nmaps - ndet = data(i)%tod%ndet + ndet = data(i)%tod%ndet nhorn = data(i)%tod%nhorn - ! Build zodi mask - allocate (m_buf(0:npix - 1, nmaps)) - allocate (procmask_zodi(0:npix - 1)) + ! Distribute zodi mask + allocate(m_buf(0:npix-1, nmaps)) + allocate(procmask_zodi(0:npix-1)) call data(i)%tod%procmask_zodi%bcast_fullsky_map(m_buf); procmask_zodi = m_buf(:, 1) - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) - box_halfwidth = anint(box_width / 2.) + + thin = max(nint(data(i)%tod%samprate/data(i)%tod%samprate_lowres), 1) + dt_tod = (thin/data(i)%tod%samprate)*SECOND_TO_DAY ! dt between two samples in units of days (assumes equispaced tods) do scan = 1, data(i)%tod%nscan if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle - ntod = data(i)%tod%scans(scan)%ntod - ! Allocate temporary variables to be downsampled - allocate (pix(ntod, nhorn)) - allocate (psi(ntod, nhorn)) - allocate (flag(ntod)) - allocate (tod(ntod)) - allocate (s_static(ntod)) - allocate (mask(ntod)) - allocate (vec(3, ntod)) - - ! Get shape of downsampled structs - call data(i)%tod%downsample_tod(tod, ext, width=box_width) - - ! Allocate downsampled strucs - allocate (downsamp_tod(ext(1):ext(2))) - allocate (downsamp_mask(ext(1):ext(2))) - allocate (downsamp_pix(ext(1):ext(2))) - allocate (downsamp_mask_idx(ext(1):ext(2))) - allocate (downsamp_vec(3, ext(1):ext(2))) - - ! downsample obs_time - allocate (obs_time(ntod)) - dt_tod = (1./data(i)%tod%samprate)*SECOND_TO_DAY ! dt between two samples in units of days (assumes equispaced tods) - do k = 1, ntod - obs_time(k) = data(i)%tod%scans(scan)%t0(1) + (k - 1)*dt_tod - end do - allocate (downsamp_obs_time(ext(1):ext(2))) - call data(i)%tod%downsample_tod(obs_time, ext, downsamp_obs_time, width=box_width) + ntod = data(i)%tod%scans(scan)%ntod + ntod_lowres = ntod/thin - do j = 1, data(i)%tod%ndet - pix = 0. - psi = 0. - flag = 0 - tod = 0. - mask = 0. - - downsamp_tod = 0. - downsamp_mask = 0. - downsamp_pix = 0 - downsamp_mask_idx = .true. - downsamp_vec = 0. + do k = 1, ntod_lowres + end do + + ! Initialize detector specific downsampled quantities + do j = 1, data(i)%tod%ndet + d => data(i)%tod%scans(scan)%d(j) + allocate(d%downsamp_pix_full(ntod_lowres)) + allocate(d%downsamp_psi_full(ntod_lowres)) + allocate(d%downsamp_mask_full(ntod_lowres)) + allocate(d%downsamp_tod_full(ntod_lowres)) + allocate(d%downsamp_obs_time_full(ntod_lowres)) + + ! Get downsampled pixel, mask and obstime + allocate(pix(ntod,nhorn), psi(ntod,nhorn), flag(ntod), mask(ntod)) call data(i)%tod%decompress_pointing_and_flags(scan, j, pix, psi, flag) + do k = 1, ntod_lowres + kp = (k-1)*thin + 1 + d%downsamp_pix_full(k) = pix(kp,1) + d%downsamp_obs_time_full(k) = data(i)%tod%scans(scan)%t0(1) + (kp-1)*dt_tod + mask(k) = procmask_zodi(pix(kp,1)) == 1 .and. iand(flag(kp), data(i)%tod%flag0) == 0 + end do + deallocate(pix, psi, flag) ! Get TOD after subtracting static zodi + allocate(tod(ntod), s_static(ntod)) if (data(i)%tod%compressed_tod) then call data(i)%tod%decompress_tod(scan, j, tod) else tod = data(i)%tod%scans(scan)%d(j)%tod end if call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static) - tod = tod - data(i)%tod%scans(scan)%d(j)%gain * s_static - - do k = 1, data(i)%tod%scans(scan)%ntod - mask(k) = procmask_zodi(pix(k, 1)) - if (iand(flag(k), data(i)%tod%flag0) .ne. 0) mask(k) = 0. - vec(:, k) = data(i)%tod%ind2vec(:, data(i)%tod%pix2ind(pix(k, 1))) + do k = 1, ntod_lowres + kp = (k-1)*thin + 1 + d%downsamp_tod_full(k) = tod(kp) - data(i)%tod%scans(scan)%d(j)%gain * s_static(kp) end do + deallocate(tod, s_static) - where (mask > 0.5) - mask = 1. - elsewhere - mask = 0. - end where - - do k = 1, 3 - call data(i)%tod%downsample_tod(real(vec(k, :), sp), ext, downsamp_vec(k, :), width=box_width) - end do - - do k = 0, ext(2)-padding - call vec2pix_ring(data(i)%tod%nside, real(downsamp_vec(:, k), dp), downsamp_pix(k)) - end do - - ! Downsample the mask - call data(i)%tod%downsample_tod(mask, ext, downsamp_mask, width=box_width) - - ! Downsample the tods - call data(i)%tod%downsample_tod(tod, ext, downsamp_tod, width=box_width) - - ! Construct the downsampled pix array (pick central pixel in each box) + ! Remove masked samples + d%downsamp_pix_full = pack(d%downsamp_pix_full, mask) + d%downsamp_tod_full = pack(d%downsamp_tod_full, mask) + d%downsamp_obs_time_full = pack(d%downsamp_obs_time_full, mask) - ! do k = 1, int(size(tod)/box_width) + 1 - ! l = floor(min(((k-1)*box_width + box_halfwidth), real(ntod, dp))) - ! downsamp_pix(k) = pix(l, 1) - ! end do - - where (downsamp_mask < 1.) downsamp_mask_idx = .false. - - ! Find upper bound and truncate the downsampled arrays by where they were padded and - ! filter out the masked values. Store the result in the tod objects for use in sampling. - data(i)%tod%scans(scan)%d(j)%downsamp_pix = pack(downsamp_pix(0:ext(2)-padding), downsamp_mask_idx(0:ext(2)-padding)) - data(i)%tod%scans(scan)%d(j)%downsamp_tod = pack(downsamp_tod(0:ext(2)-padding), downsamp_mask_idx(0:ext(2)-padding)) - if (j == 1) data(i)%tod%scans(scan)%downsamp_obs_time = pack(downsamp_obs_time(0:ext(2)-padding), downsamp_mask_idx(0:ext(2)-padding)) ! write timestreams to files ! call int2string(data(i)%tod%scanid(scan), scan_str) ! call open_hdf_file(trim(adjustl("/mn/stornext/u3/metins/dirbe/chains/chains_downsamp/dtod_"//scan_str//".h5")), tod_file, 'w') @@ -260,66 +208,43 @@ subroutine downsamp_invariant_structs(cpar) ! call close_hdf_file(tod_file) ! Allocate other downsampled quantities with same shape - ndownsamp = size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) - if (.not. allocated(data(i)%tod%scans(scan)%d(j)%downsamp_scat)) then - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ndownsamp)) - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_scat(ndownsamp, zodi_model%n_comps)) - allocate (data(i)%tod%scans(scan)%d(j)%downsamp_therm(ndownsamp, zodi_model%n_comps)) - - ! Compute downsampled pointing in various coordinates - allocate(data(i)%tod%scans(scan)%d(j)%downsamp_point(ndownsamp,5)) - end if - do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) -!!$ call pix2ang_ring(data(i)%tod%nside, data(i)%tod%scans(scan)%d(j)%downsamp_pix(k), lat, lon) -!!$ phi = phi * 180.d0/pi -!!$ lon = 90.d0 - lon * 180.d0/pi -!!$ data(i)%tod%scans(scan)%d(j)%downsamp_point(k,1) = lon ! Ecliptic longitude -!!$ data(i)%tod%scans(scan)%d(j)%downsamp_point(k,2) = lat ! Ecliptic latitude -!!$ day = data(i)%tod%scanid(scan) -!!$ lambda_solar = (-80.598349 + 0.98564736 * day + 1.912 * cos(2.d0*pi/365.25 * (day-94.8))) * pi/180.d0 -!!$ data(i)%tod%scans(scan)%d(j)%downsamp_point(k,5) = acos(cos(lat*pi/180.d0) * cos(lon*pi/180.d0 - lambda_solar)) * 180.d0/pi ! Solar elongation -!!$ call pix2vec_ring(data(i)%tod%nside, data(i)%tod%scans(scan)%d(j)%downsamp_pix(k), vec1) -!!$ !vec0 = -0.5d0 * (data(i)%tod%scans(scan)%x0_obs + data(i)%tod%scans(scan)%x1_obs) -!!$ !vec0 = vec0/sqrt(sum(vec0**2)) -!!$ !theta = dot_product(vec0, vec1) -!!$ !data(i)%tod%scans(scan)%d(j)%downsamp_point(k,5) = acos(theta)*180.d0/pi ! Solar elongation -!!$ vec1 = matmul(M_ecl2gal, vec1) -!!$ call vec2ang(vec1, theta, phi) -!!$ data(i)%tod%scans(scan)%d(j)%downsamp_point(k,3) = phi*180.d0/pi ! Galactic longitude -!!$ data(i)%tod%scans(scan)%d(j)%downsamp_point(k,4) = (0.5d0*pi-theta)*180.d0/pi ! Galactic latitude - - call pix2ang_ring(data(i)%tod%nside, data(i)%tod%scans(scan)%d(j)%downsamp_pix(k), lat, lon) + ntod_lowres = count(mask) + allocate(d%downsamp_zodi_full(ntod_lowres)) + allocate(d%downsamp_scat_full(ntod_lowres)) + allocate(d%downsamp_therm_full(ntod_lowres)) + allocate(d%downsamp_point_full(ntod_lowres,5)) + do k = 1, ntod_lowres + call pix2ang_ring(nside, d%downsamp_pix_full(k), lat, lon) lon = lon * 180.d0/pi if (lon > 180.d0) lon = lon - 360.d0 lat = 90.d0 - lat * 180.d0/pi - data(i)%tod%scans(scan)%d(j)%downsamp_point(k,3) = lon ! Galactic longitude - data(i)%tod%scans(scan)%d(j)%downsamp_point(k,4) = lat ! Galactic latitude - call pix2vec_ring(data(i)%tod%nside, data(i)%tod%scans(scan)%d(j)%downsamp_pix(k), vec1) + d%downsamp_point_full(k,3) = lon ! Galactic longitude + d%downsamp_point_full(k,4) = lat ! Galactic latitude + call pix2vec_ring(nside, d%downsamp_pix_full(k), vec1) vec1 = matmul(transpose(M_ecl2gal), vec1) call vec2ang(vec1, lat, lon) lon = lon * 180.d0/pi if (lon > 180.d0) lon = lon - 360.d0 lat = 90.d0 - lat * 180.d0/pi - data(i)%tod%scans(scan)%d(j)%downsamp_point(k,1) = lon ! Galactic longitude - data(i)%tod%scans(scan)%d(j)%downsamp_point(k,2) = lat ! Galactic latitude + d%downsamp_point_full(k,1) = lon ! Galactic longitude + d%downsamp_point_full(k,2) = lat ! Galactic latitude day = data(i)%tod%scanid(scan) lambda_solar = (-80.598349 + 0.98564736 * day + 1.912 * cos(2.d0*pi/365.25 * (day-94.8))) * pi/180.d0 - data(i)%tod%scans(scan)%d(j)%downsamp_point(k,5) = acos(cos(lat*pi/180.d0) * cos(lon*pi/180.d0 - lambda_solar)) * 180.d0/pi ! Solar elongation - end do - + d%downsamp_point_full(k,5) = acos(cos(lat*pi/180.d0) * cos(lon*pi/180.d0 - lambda_solar)) * 180.d0/pi ! Solar elongation + end do end do - deallocate (obs_time, downsamp_obs_time) - deallocate (pix, psi, vec, flag, tod, s_static, mask, downsamp_tod, downsamp_mask, downsamp_pix, downsamp_mask_idx, downsamp_vec) end do deallocate (m_buf, procmask_zodi) end do - end subroutine + end subroutine downsamp_invariant_structs - subroutine precompute_lowres_zodi_lookups(cpar) - ! Loop over each band with zodi and precompute lookup tables for lowres zodi caching + ! Loop over each band with zodi and precompute lookup tables for lowres zodi caching + subroutine precompute_lowres_zodi_lookups(cpar) + implicit none type(comm_params), intent(in) :: cpar + integer(i4b) :: i, j, k, l, scan, n_lowres_obs, nobs_downsamp, nobs_lowres, pix_high, pix_low, ierr integer(i4b), allocatable :: pix2ind_highres(:), ind2pix_highres(:) real(dp), allocatable :: ind2vec_zodi_temp(:, :) @@ -337,8 +262,8 @@ subroutine precompute_lowres_zodi_lookups(cpar) do scan = 1, data(i)%tod%nscan if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle do j = 1, data(i)%tod%ndet - do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) - pix2ind_highres(data(i)%tod%scans(scan)%d(j)%downsamp_pix(k)) = 1 + do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_pix_full) + pix2ind_highres(data(i)%tod%scans(scan)%d(j)%downsamp_pix_full(k)) = 1 end do end do end do @@ -388,9 +313,10 @@ subroutine precompute_lowres_zodi_lookups(cpar) end subroutine subroutine project_and_downsamp_sky(cpar) - type(comm_params), intent(in) :: cpar - integer(i4b) :: i, j, k, scan, ext(2), upper_bound, padding, ierr, ntod, nhorn, npix, ndet, nmaps, ndelta - real(dp) :: box_width + implicit none + type(comm_params), intent(in) :: cpar + + integer(i4b) :: i, j, k, scan, ext(2), upper_bound, padding, ierr, ntod, nhorn, npix, ndet, nmaps, thin, ntod_lowres type(map_ptr), allocatable, dimension(:, :) :: sky_signal real(sp), allocatable, dimension(:) :: downsamp_sky, downsamp_mask logical(lgt), allocatable, dimension(:) :: downsamp_mask_idx @@ -403,168 +329,145 @@ subroutine project_and_downsamp_sky(cpar) if (cpar%myid == cpar%root) print *, "projecting downsampled sky" - padding = 5 ! For each zodi band, create downsampled residual time stream do i = 1, numband - ! Only generate downsampled arrays for tod bands and bands where we have zodi if (trim(data(i)%tod_type) == 'none') cycle if (.not. data(i)%tod%subtract_zodi) cycle - npix = 12*data(i)%map%info%nside**2 - ndelta = 1 nmaps = data(i)%map%info%nmaps - ndet = data(i)%tod%ndet - nhorn = data(i)%tod%nhorn - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) + ndet = data(i)%tod%ndet + thin = max(nint(data(i)%tod%samprate/data(i)%tod%samprate_lowres), 1) - allocate (sky_signal(data(i)%tod%ndet, ndelta)) + ! Distribute sky signal + allocate(sky_signal(data(i)%tod%ndet,1)) do j = 1, data(i)%tod%ndet - call get_sky_signal(i, j, sky_signal(j, ndelta)%p, mono=.false.) + call get_sky_signal(i, j, sky_signal(j,1)%p, mono=.false.) end do - allocate (map_sky(nmaps, data(i)%tod%nobs, 0:data(i)%tod%ndet, 1)) call distribute_sky_maps(data(i)%tod, sky_signal, 1.e0, map_sky) - allocate (m_buf(0:npix - 1, nmaps)) - allocate (procmask_zodi(0:npix - 1)) - call data(i)%tod%procmask_zodi%bcast_fullsky_map(m_buf) - procmask_zodi = m_buf(:, 1) - + ! Project sky signal into already downsampled data structures do scan = 1, data(i)%tod%nscan if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle ntod = data(i)%tod%scans(scan)%ntod do j = 1, ndet - allocate (pix(ntod, nhorn)) - allocate (psi(ntod, nhorn)) - allocate (flag(ntod)) - allocate (mask(ntod)) - allocate (sky(ntod)) - pix = 0 - psi = 0 - flag = 0 - mask = 0. - sky = 0. - - ! Project sky map down to downsampled timestream and cache - call data(i)%tod%decompress_pointing_and_flags(scan, j, pix, psi, flag) - - do k = 1, ntod - mask(k) = procmask_zodi(pix(k, 1)) - if (iand(flag(k), data(i)%tod%flag0) .ne. 0) mask(k) = 0. - end do - where (mask > 0.) mask = 1. ! make sure mask is binary before downsampling - - do k = 1, ntod - sky(k) = map_sky(1, data(i)%tod%pix2ind(pix(k, 1)), j, 1) !zodi is only temperature (for now) + ntod_lowres = size(data(i)%tod%scans(scan)%d(j)%downsamp_pix_full) + allocate(data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(ntod_lowres)) + do k = 1, ntod_lowres + data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(k) = map_sky(1, data(i)%tod%pix2ind(pix(k, 1)), j, 1) !zodi is only temperature (for now) end do - - ! Get downsample shape - call data(i)%tod%downsample_tod(sky, ext, width=box_width) - - allocate (downsamp_sky(ext(1):ext(2))) - allocate (downsamp_mask(ext(1):ext(2))) - allocate (downsamp_mask_idx(ext(1):ext(2))) - downsamp_mask_idx = .true. - - call data(i)%tod%downsample_tod(sky, ext, downsamp_sky, width=box_width) - - call data(i)%tod%downsample_tod(mask, ext, downsamp_mask, width=box_width) - where (downsamp_mask < 1.) downsamp_mask_idx = .false. - - data(i)%tod%scans(scan)%d(j)%downsamp_sky = pack(downsamp_sky(0:ext(2)-padding), downsamp_mask_idx(0:ext(2)-padding)) - deallocate(pix, psi, flag, mask, sky) - deallocate(downsamp_sky, downsamp_mask_idx, downsamp_mask) end do - end do - deallocate (map_sky, sky_signal, m_buf, procmask_zodi) + deallocate (map_sky, sky_signal) end do end subroutine - subroutine compute_downsamp_zodi(cpar, model) - type(comm_params), intent(in) :: cpar - type(ZodiModel), intent(inout) :: model - integer(i4b) :: i, j, scan, ierr, ndet - - if (cpar%myid == cpar%root) print *, "computing downsampled zodi" - - do i = 1, numband - if (trim(data(i)%tod_type) == 'none') cycle - if (.not. data(i)%tod%subtract_zodi) cycle - - do scan = 1, data(i)%tod%nscan - if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle - - ndet = data(i)%tod%ndet - do j = 1, ndet - call get_zodi_emission(& - & tod=data(i)%tod, & - & pix=data(i)%tod%scans(scan)%d(j)%downsamp_pix, & - & scan=scan, & - & det=j, & - & s_zodi_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & model=model, & - & use_lowres_pointing=.true. & - &) - call get_s_zodi(i, & - & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - &) - end do - end do - end do - end subroutine +!!$ subroutine compute_downsamp_zodi(cpar, model) +!!$ type(comm_params), intent(in) :: cpar +!!$ type(ZodiModel), intent(inout) :: model +!!$ integer(i4b) :: i, j, scan, ierr, ndet +!!$ +!!$ if (cpar%myid == cpar%root) print *, "computing downsampled zodi" +!!$ +!!$ do i = 1, numband +!!$ if (trim(data(i)%tod_type) == 'none') cycle +!!$ if (.not. data(i)%tod%subtract_zodi) cycle +!!$ +!!$ do scan = 1, data(i)%tod%nscan +!!$ if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle +!!$ +!!$ ndet = data(i)%tod%ndet +!!$ do j = 1, ndet +!!$ call get_zodi_emission(& +!!$ & tod=data(i)%tod, & +!!$ & pix=data(i)%tod%scans(scan)%d(j)%downsamp_pix, & +!!$ & scan=scan, & +!!$ & det=j, & +!!$ & s_zodi_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & +!!$ & s_zodi_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & +!!$ & model=model, & +!!$ & use_lowres_pointing=.true. & +!!$ &) +!!$ call get_s_zodi(i, & +!!$ & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & +!!$ & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & +!!$ & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi & +!!$ &) +!!$ end do +!!$ end do +!!$ end do +!!$ end subroutine - subroutine create_zodi_glitch_mask(cpar, handle) + subroutine create_zodi_sampgroup_mask(cpar, handle) type(comm_params), intent(in) :: cpar type(planck_rng), intent(inout) :: handle - integer(i4b) :: i, j, k, scan, ierr, non_glitch_size, thinstep, offset - real(dp) :: box_width, rms, frac + + integer(i4b) :: i, j, k, l, scan, ierr, non_glitch_size, thinstep, offset, ntod, ngood + real(dp) :: rms, frac, thin_frac + logical(lgt), allocatable, dimension(:) :: basemask real(sp), allocatable :: res(:) real(sp), allocatable :: downsamp_scat_comp(:, :), downsamp_therm_comp(:, :) - thinstep = nint(1.d0/cpar%zs_tod_thin_factor) do i = 1, numband if (trim(data(i)%tod_type) == 'none') cycle if (.not. data(i)%tod%subtract_zodi) cycle do scan = 1, data(i)%tod%nscan - offset = rand_uni(handle) * thinstep - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) do j = 1, data(i)%tod%ndet if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle + ! Initialize masks + ntod = size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) + allocate(data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(ntod,cpar%zs_num_samp_groups)) + data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask = .true. + + !allocate(basemask(ntod)) + ! Search for strong outliers - res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%gain * (data(i)%tod%scans(scan)%d(j)%downsamp_sky + data(i)%tod%scans(scan)%d(j)%downsamp_zodi) - rms = sqrt(mean(real(res**2, dp))) - data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask = abs(res) > 10. * real(rms, sp) - frac = count(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask)/real(size(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask),dp) - if (frac > 0.01d0) then - write(*,*) 'Warning: Removing high fraction of glitches = ', frac - end if - - ! Apply TOD thinning - !allocate(data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask(data(i)%tod%scans(scan)%ntod)) - do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) - if (mod(k+offset,thinstep) /= 0) then - data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask(k) = .true. +!!$ res = data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%gain * (data(i)%tod%scans(scan)%d(j)%downsamp_sky + data(i)%tod%scans(scan)%d(j)%downsamp_zodi) +!!$ rms = sqrt(mean(real(res**2, dp))) +!!$ basemask = abs(res) > 10. * real(rms, sp) +!!$ frac = count(basemask)/real(ntod,dp) +!!$ if (frac > 0.01d0) write(*,*) 'Warning: Removing high fraction of glitches = ', frac + + ! Apply TOD thinning; may be different for each sampling group + do l = 1, cpar%zs_num_samp_groups + ! Remove samples at high latitudes, if requested by user + if (cpar%zs_samp_group_max_b_ecl(i) < 0.5d0*pi) then + do k = 1, ntod + if (abs(data(i)%tod%scans(scan)%d(j)%downsamp_point_full(k,3)) > cpar%zs_samp_group_max_b_ecl(i)) then + data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(k,l) = .false. + end if + end do end if + + ! Apply thinning factor, adjusted for already masked samples + ngood = count(data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(:,l)) + thinstep = max(nint(real(ngood,sp)/real(ntod,sp) / cpar%zs_tod_thin_factor),1) + k = 1 + ngood = 0 + do while (k <= ntod) + if (data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(k,l)) then + ngood = ngood + 1 + if (mod(ngood,thinstep) /= 0) data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(k,l) = .false. + end if + k = k+1 + end do end do + deallocate(basemask) end do end do end do - end subroutine - - subroutine apply_zodi_glitch_mask(cpar) - type(comm_params), intent(in) :: cpar - integer(i4b) :: i, j, k, scan, ierr, non_glitch_size - real(sp), allocatable :: res(:) - real(sp), allocatable :: downsamp_scat_comp(:, :), downsamp_therm_comp(:, :) - integer(i4b), allocatable :: downsamp_pix(:) + end subroutine create_zodi_sampgroup_mask + subroutine apply_zodi_sampgroup_mask(cpar, samp_group) + implicit none + type(comm_params), intent(in) :: cpar + integer(i4b), intent(in) :: samp_group + + integer(i4b) :: i, j, k, scan, ngood + do i = 1, numband if (trim(data(i)%tod_type) == 'none') cycle if (.not. data(i)%tod%subtract_zodi) cycle @@ -572,33 +475,22 @@ subroutine apply_zodi_glitch_mask(cpar) do scan = 1, data(i)%tod%nscan do j = 1, data(i)%tod%ndet if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - !if (size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) < 10) cycle ! Remove flagged samples - non_glitch_size = count(.not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - if (size(data(i)%tod%scans(scan)%d(j)%downsamp_pix) /= non_glitch_size) data(i)%tod%scans(scan)%d(j)%downsamp_pix = pack(data(i)%tod%scans(scan)%d(j)%downsamp_pix, .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - if (size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) /= non_glitch_size) data(i)%tod%scans(scan)%d(j)%downsamp_tod = pack(data(i)%tod%scans(scan)%d(j)%downsamp_tod, .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - if (size(data(i)%tod%scans(scan)%d(j)%downsamp_sky) /= non_glitch_size) data(i)%tod%scans(scan)%d(j)%downsamp_sky = pack(data(i)%tod%scans(scan)%d(j)%downsamp_sky, .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - if (size(data(i)%tod%scans(scan)%d(j)%downsamp_zodi) /= non_glitch_size) data(i)%tod%scans(scan)%d(j)%downsamp_zodi = pack(data(i)%tod%scans(scan)%d(j)%downsamp_zodi, .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - - ! pack doesnt work on multidimensional arrays so here we manually reallocate the zodi caches to the new sizes - if (size(data(i)%tod%scans(scan)%d(j)%downsamp_therm,1) /= non_glitch_size) then - allocate(downsamp_scat_comp(non_glitch_size, zodi_model%n_comps)) - allocate(downsamp_therm_comp(non_glitch_size, zodi_model%n_comps)) - do k = 1, zodi_model%n_comps - downsamp_scat_comp(:, k) = pack(data(i)%tod%scans(scan)%d(j)%downsamp_scat(:, k), .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - downsamp_therm_comp(:, k) = pack(data(i)%tod%scans(scan)%d(j)%downsamp_therm(:, k), .not. data(i)%tod%scans(scan)%d(j)%zodi_glitch_mask) - end do - deallocate(data(i)%tod%scans(scan)%d(j)%downsamp_scat) - deallocate(data(i)%tod%scans(scan)%d(j)%downsamp_therm) - allocate(data(i)%tod%scans(scan)%d(j)%downsamp_scat(non_glitch_size, zodi_model%n_comps)) - allocate(data(i)%tod%scans(scan)%d(j)%downsamp_therm(non_glitch_size, zodi_model%n_comps)) - data(i)%tod%scans(scan)%d(j)%downsamp_therm = downsamp_therm_comp - data(i)%tod%scans(scan)%d(j)%downsamp_scat = downsamp_scat_comp - deallocate(downsamp_scat_comp, downsamp_therm_comp) - end if - - + ngood = count(data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(:,samp_group)) + data(i)%tod%scans(scan)%d(j)%downsamp_pix = pack(data(i)%tod%scans(scan)%d(j)%downsamp_pix_full, data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(:,samp_group)) + data(i)%tod%scans(scan)%d(j)%downsamp_tod = pack(data(i)%tod%scans(scan)%d(j)%downsamp_tod_full, data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(:,samp_group)) + data(i)%tod%scans(scan)%d(j)%downsamp_sky = pack(data(i)%tod%scans(scan)%d(j)%downsamp_sky_full, data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(:,samp_group)) + +!!$ ! Allocate arrays for zodi, but don't fill them +!!$ if (allocated(data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ngood))) then +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ngood)) +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_scat(ngood, zodi_model%n_comps)) +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_therm(ngood, zodi_model%n_comps)) +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_zodi(ngood)) +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_scat(ngood, zodi_model%n_comps)) +!!$ allocate(data(i)%tod%scans(scan)%d(j)%downsamp_therm(ngood, zodi_model%n_comps)) +!!$ end if end do end do end do @@ -651,13 +543,6 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) ! Get chisq of old point scale = pack(zodi_model%theta_scale(:,1), zodi_model%theta_stat(:,samp_group)==0) call zodi_model%model_to_params(theta_old, samp_group) -!!$ if (cpar%myid == cpar%root) then -!!$ do i = 1, npar -!!$ write(*,*) 'a', i, theta_old(i) -!!$ end do -!!$ end if -!!$ call mpi_finalize(ierr) -!!$ stop ! Enforce priors; rms = 0 call randomize_zodi_init(theta_old, samp_group, cpar, handle, rms=0.d0) @@ -741,10 +626,9 @@ function lnL_zodi(p) real(dp) :: lnL_zodi real(dp), allocatable :: theta(:) - real(dp) :: chisq, chisq_tot, box_width, t1, t2, t3, t4, mono + real(dp) :: chisq, chisq_tot, t1, t2, t3, t4, mono integer(i4b) :: i, j, k, scan, ntod, ndet, nscan, flag, ierr, ndof, ndof_tot logical(lgt) :: accept - logical(lgt), dimension(numband) :: update_band character(len=4) :: scan_str type(hdf_file) :: tod_file @@ -757,26 +641,7 @@ function lnL_zodi(p) theta = p*scale end if call mpi_bcast(theta, size(theta), MPI_DOUBLE_PRECISION, 0, data(1)%tod%comm, ierr) - - ! Check which parameters have changed - update_band = .true. -!!$ update_band = .false. -!!$ j = 0 -!!$ do i = 1, zodi_model%npar_tot -!!$ if (zodi_model%theta_stat(i,samp_group) /= 0) cycle -!!$ j = j+1 -!!$ if (theta(j) /= theta_prev(j)) then -!!$ !if (data(1)%tod%myid == 0) write(*,*) j, theta(j), theta_prev(j), zodi_model%theta2band(i) -!!$ if (zodi_model%theta2band(i) == 0) then -!!$ update_band = .true. -!!$ exit -!!$ else -!!$ update_band(zodi_model%theta2band(i)) = .true. -!!$ end if -!!$ end if -!!$ end do - !if (data(1)%tod%myid == 0) write(*,*) data(1)%tod%myid, ' -- update =', update_band, all(theta == theta_prev) - + ! Check priors if (cpar%myid_chain == 0) then chisq_tot = get_chisq_priors(theta, samp_group) @@ -806,28 +671,9 @@ function lnL_zodi(p) ndet = data(i)%tod%ndet nscan = data(i)%tod%nscan - if (.not. update_band(i)) then - !write(*,*) 'skipping', i, chisq_prev(i) - if (cpar%myid_chain == 0) write(*,*) 'skipping band ', i, chisq_prev(i) - chisq_tot = chisq_tot + chisq_prev(i) - do scan = 1, nscan - do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle - ndof = ndof + size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) - end do - end do - cycle - end if - ! Get monopole - mono = band_monopole(i) !get_monopole_amp(data(i)%label) -!!$ if (data(1)%tod%myid == 0) then -!!$ write(*,*) 'theta =', theta -!!$ write(*,*) 'mono =', mono -!!$ end if + mono = band_monopole(i) - box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) - ! Make sure that the zodi cache is cleared before each new band call data(i)%tod%clear_zodi_cache() @@ -836,10 +682,7 @@ function lnL_zodi(p) do scan = 1, nscan ! Skip scan if no accepted data do j = 1, ndet - if (.not. data(i)%tod%scans(scan)%d(j)%accept) then - !write(*,*) ' Scan rejected:', data(i)%tod%scanid(scan), data(1)%tod%myid - cycle - end if + if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle call wall_time(t3) call get_zodi_emission(& @@ -873,7 +716,7 @@ function lnL_zodi(p) & (data(i)%tod%scans(scan)%d(j)%downsamp_sky & & + data(i)%tod%scans(scan)%d(j)%downsamp_zodi & & + mono) & - & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & + & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0))**2 & &) chisq_tot = chisq_tot + chisq chisq_prev(i) = chisq_prev(i) + chisq @@ -936,426 +779,8 @@ function lnL_zodi(p) end subroutine minimize_zodi_with_powell - -!!$ subroutine minimize_zodi_with_powell2(cpar, handle) -!!$ type(comm_params), intent(in) :: cpar -!!$ type(planck_rng), intent(inout) :: handle -!!$ logical(lgt), save :: first_call = .true. -!!$ logical(lgt) :: accept -!!$ real(dp), allocatable :: theta(:), theta_phys(:), theta_new(:), theta_final(:) -!!$ character(len=128), allocatable :: labels(:) -!!$ integer(i4b) :: i, j, k, ierr, flag, group_idx, end_idx, n_bands -!!$ real(dp) :: chisq_lnL, chisq_red -!!$ real(dp), allocatable, dimension(:) :: prior_vec_powell_min, prior_vec_powell_max, prior_vec_powell_type -!!$ integer(i4b), allocatable :: indices(:) -!!$ -!!$ if (allocated(param_vec_current)) then -!!$ ! Start at a new random point -!!$ call randomize_zodi_init(cpar, handle) -!!$ else -!!$ allocate(param_vec_current(zodi_model%n_params)) -!!$ chisq_red_current = 1.d30 -!!$ end if -!!$ -!!$ allocate(theta(zodi_model%n_params)) -!!$ call zodi_model%model_to_params2(theta, labels) -!!$ if (cpar%myid == 0) print *, "minimizing zodi parameters with powell" -!!$ -!!$ ! filter out parameters for powell search -!!$ allocate(powell_included_params(zodi_model%n_params)) -!!$ powell_included_params = .false. -!!$ -!!$ ! Get parameters to sample from sampling groups -!!$ do group_idx = 1, cpar%zs_num_samp_groups -!!$ call parse_samp_group_strings(cpar%zs_samp_groups(group_idx), labels, indices) -!!$ do i = 1, size(indices) -!!$ powell_included_params(indices(i)) = .true. -!!$ end do -!!$ end do -!!$ prior_vec_powell_min = prior_vec(:, 1) -!!$ prior_vec_powell_max = prior_vec(:, 2) -!!$ prior_vec_powell_type = prior_vec(:, 3) -!!$ -!!$ ! ! append emissivities and albedoes to the vector given to powell. -!!$ do i = 1, numband -!!$ if (trim(data(i)%tod_type) == 'none') cycle -!!$ if (.not. data(i)%tod%subtract_zodi) cycle -!!$ if (cpar%ds_zodi_reference_band(data(i)%id_abs)) cycle -!!$ theta = [theta, data(i)%tod%zodi_emissivity] -!!$ powell_included_params = [powell_included_params, [(.true. , j=1, size(data(i)%tod%zodi_emissivity))]] -!!$ prior_vec_powell_min = [prior_vec_powell_min, [(emissivity_prior(1) , j=1, size(data(i)%tod%zodi_emissivity))]] -!!$ prior_vec_powell_max = [prior_vec_powell_max, [(emissivity_prior(2) , j=1, size(data(i)%tod%zodi_emissivity))]] -!!$ prior_vec_powell_type = [prior_vec_powell_type, [(real(0, dp), j=1, size(data(i)%tod%zodi_emissivity))]] -!!$ end do -!!$ -!!$ do i = 1, numband -!!$ if (trim(data(i)%tod_type) == 'none') cycle -!!$ if (.not. data(i)%tod%subtract_zodi) cycle -!!$ if (.not. any(data(i)%tod%zodi_albedo > EPS)) cycle -!!$ theta = [theta, data(i)%tod%zodi_albedo] -!!$ powell_included_params = [powell_included_params, [(.true. , j=1, size(data(i)%tod%zodi_albedo))]] -!!$ prior_vec_powell_min = [prior_vec_powell_min, [(albedo_prior(1) , j=1, size(data(i)%tod%zodi_albedo))]] -!!$ prior_vec_powell_max = [prior_vec_powell_max, [(albedo_prior(2) , j=1, size(data(i)%tod%zodi_albedo))]] -!!$ prior_vec_powell_type = [prior_vec_powell_type, [(real(0, dp), j=1, size(data(i)%tod%zodi_albedo))]] -!!$ end do -!!$ -!!$ allocate(prior_vec_powell(size(prior_vec_powell_min), 3)) -!!$ prior_vec_powell(:, 1) = prior_vec_powell_min -!!$ prior_vec_powell(:, 2) = prior_vec_powell_max -!!$ prior_vec_powell(:, 3) = prior_vec_powell_type -!!$ -!!$ if (any(pack(theta, powell_included_params) == 0.)) then -!!$ do i = 1, size(theta) -!!$ write(*,*) i, theta(i) -!!$ end do -!!$ stop "theta_0 contains zeros in zodi powell sampling. Cant compute physical units due to theta/theta_0" -!!$ end if -!!$ -!!$ allocate(theta_0(size(theta))) -!!$ theta_0 = theta -!!$ -!!$ allocate(theta_phys(count(powell_included_params))) -!!$ -!!$ if (cpar%myid == cpar%root) then -!!$ !filter out N_0 parameters and scale to physical units -!!$ theta_phys = pack(theta / theta_0, powell_included_params) -!!$ !call powell(theta_phys, lnL_zodi, ierr) -!!$ do k = 1, 2 -!!$ call powell(theta_phys, lnL_zodi2, ierr, tolerance=1d-3) -!!$ end do -!!$ flag = 0 -!!$ call mpi_bcast(flag, 1, MPI_INTEGER, cpar%root, cpar%comm_chain, ierr) -!!$ chisq_red = lnL_zodi2(theta_phys) -!!$ else -!!$ do while (.true.) -!!$ call mpi_bcast(flag, 1, MPI_INTEGER, cpar%root, cpar%comm_chain, ierr) -!!$ if (flag == 1) then -!!$ chisq_lnL = lnL_zodi2() -!!$ else -!!$ exit -!!$ end if -!!$ end do -!!$ call mpi_bcast(flag, 1, MPI_INTEGER, cpar%root, cpar%comm_chain, ierr) -!!$ chisq_red = lnL_zodi2() -!!$ end if -!!$ -!!$ call mpi_barrier(MPI_COMM_WORLD, ierr) -!!$ call mpi_bcast(theta_phys, size(theta_phys), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ call mpi_bcast(chisq_red, 1, MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ -!!$ allocate(theta_final(zodi_model%n_params)) -!!$ theta_final = theta(1:zodi_model%n_params) -!!$ -!!$ j = 1 -!!$ do i = 1, size(theta) -!!$ if (powell_included_params(i)) then -!!$ theta(i) = theta_phys(j) * theta_0(i) -!!$ j = j + 1 -!!$ end if -!!$ end do -!!$ -!!$ !call min_max_param_vec_with_priors(theta, prior_vec_powell) -!!$ -!!$ -!!$ j = 1 -!!$ do i = 1, size(theta) -!!$ if (powell_included_params(i)) then -!!$ if (i <= zodi_model%n_params) then -!!$ theta_final(i) = theta_phys(j) * theta_0(i) -!!$ end if -!!$ j = j + 1 -!!$ end if -!!$ end do -!!$ -!!$ ! Apply approximate Metropolis rule, using reduced chisq instead of chisq -!!$ if (cpar%myid == cpar%root) then -!!$ if (chisq_red_current == 1.d30) then -!!$ accept = .true. -!!$ else -!!$ accept = rand_uni(handle) < exp(-0.5d0*(chisq_red-chisq_red_current)/0.1d0) -!!$ end if -!!$ end if -!!$ call mpi_bcast(accept, 1, MPI_LOGICAL, cpar%root, cpar%comm_chain, ierr) -!!$ -!!$ if (accept) then -!!$ ! Accept new point; update -!!$ if (cpar%myid == cpar%root) write(*,fmt='(a,f8.2,a,f8.2)') 'Zodi sample accepted, chisq_new =', chisq_red, ', chisq_old = ', chisq_red_current -!!$ param_vec_current = theta_final -!!$ chisq_red_current = chisq_red -!!$ else -!!$ ! Reject new solution, reset to previous solution -!!$ if (cpar%myid == cpar%root) write(*,fmt='(a,f8.2,a,f8.2)') 'Zodi sample rejected, chisq_new =', chisq_red, ', chisq_old = ', chisq_red_current -!!$ call zodi_model%params_to_model2(param_vec_current) -!!$ deallocate(prior_vec_powell, theta_0, powell_included_params) -!!$ return -!!$ end if -!!$ -!!$ ! update model with final parameters -!!$ call zodi_model%params_to_model2(theta_final) -!!$ -!!$ ! update emissivities and albedos with final parameters -!!$ j = 0 -!!$ do i = numband, 1, -1 -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ if (any(data(i)%tod%zodi_albedo > EPS)) then -!!$ j = j + 1 -!!$ data(i)%tod%zodi_albedo = theta(size(theta)-(j*zodi_model%n_comps)+1:size(theta)-(j-1)*zodi_model%n_comps) -!!$ else -!!$ data(i)%tod%zodi_albedo = data(i)%tod%zodi_albedo -!!$ end if -!!$ end do -!!$ do i = numband, 1, -1 -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ if (.not. ref_band(data(i)%id_abs)) then -!!$ j = j + 1 -!!$ data(i)%tod%zodi_emissivity = theta(size(theta)-(j*zodi_model%n_comps)+1:size(theta)-(j-1)*zodi_model%n_comps) -!!$ else -!!$ data(i)%tod%zodi_emissivity = 1. -!!$ end if -!!$ end do -!!$ deallocate(prior_vec_powell, theta_0, powell_included_params) -!!$ end subroutine -!!$ -!!$ function lnL_zodi2(p) -!!$ use healpix_types -!!$ implicit none -!!$ real(dp), dimension(:), intent(in), optional :: p -!!$ real(dp) :: lnL_zodi2 -!!$ type(ZodiModel) :: model -!!$ -!!$ real(dp), allocatable :: theta(:), theta_phys(:), theta_full(:) -!!$ character(len=128), allocatable :: labels(:) -!!$ real(dp) :: chisq, chisq_tod, chisq_prior, box_width, t1, t2, t3, t4, prior -!!$ real(dp), allocatable, dimension(:), save :: theta_prev, chisq_prev -!!$ integer(i4b) :: i, j, k, scan, ntod, ndet, nscan, flag, ierr, n_bands, ndof, ndof_tot -!!$ logical(lgt), dimension(numband) :: update_band -!!$ character(len=4) :: scan_str -!!$ type(hdf_file) :: tod_file -!!$ -!!$ call wall_time(t1) -!!$ model = zodi_model -!!$ allocate(theta_phys(count(powell_included_params))) -!!$ -!!$ if (data(1)%tod%myid == 0) then -!!$ flag = 1 -!!$ call mpi_bcast(flag, 1, MPI_INTEGER, 0, data(1)%tod%comm, ierr) -!!$ theta_phys = p -!!$ end if -!!$ call mpi_bcast(theta_phys, size(theta_phys), MPI_DOUBLE_PRECISION, 0, data(1)%tod%comm, ierr) -!!$ -!!$ -!!$ allocate(theta(model%n_params)) -!!$ call model%model_to_params2(theta, labels) -!!$ -!!$ allocate(theta_full(size(powell_included_params))) -!!$ theta_full(1:model%n_params) = theta -!!$ -!!$ j = 1 -!!$ do i = 1, size(theta_full) -!!$ if (powell_included_params(i)) then -!!$ if (i <= model%n_params) then -!!$ theta(i) = theta_phys(j) * theta_0(i) -!!$ end if -!!$ theta_full(i) = theta_phys(j) * theta_0(i) -!!$ j = j + 1 -!!$ end if -!!$ end do -!!$ -!!$ call model%params_to_model2(theta) -!!$ -!!$ ! if (data(1)%tod%myid == 0) call print_zodi_model(theta, labels) -!!$ -!!$ -!!$ j = 0 -!!$ do i = numband, 1, -1 -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ if (any(data(i)%tod%zodi_albedo > EPS)) then -!!$ j = j + 1 -!!$ powell_albedo(i, :) = theta_full(size(theta_full)-(j*zodi_model%n_comps)+1:size(theta_full)-(j-1)*zodi_model%n_comps) -!!$ else -!!$ powell_albedo(i, :) = data(i)%tod%zodi_albedo -!!$ end if -!!$ end do -!!$ do i = numband, 1, -1 -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ if (.not. ref_band(data(i)%id_abs)) then -!!$ j = j + 1 -!!$ powell_emissivity(i, :) = theta_full(size(theta_full)-(j*zodi_model%n_comps)+1:size(theta_full)-(j-1)*zodi_model%n_comps) -!!$ else -!!$ powell_emissivity(i, :) = 1. -!!$ end if -!!$ end do -!!$ -!!$ ! rescale parameters -!!$ call model%model_to_params2(theta) -!!$ theta_full(1:model%n_params) = theta -!!$ -!!$ ! Check which parameters have changed -!!$ update_band = .false. -!!$ if (.not. allocated(theta_prev)) then -!!$ allocate(theta_prev(model%n_params), chisq_prev(numband)) -!!$ theta_prev = theta_full -!!$ chisq_prev = 0.d0 -!!$ update_band = .true. -!!$ else -!!$ do i = 1, model%n_params -!!$ if (theta_full(i) /= theta_prev(i)) then -!!$ if (param2band(i) == 0) then -!!$ update_band = .true. -!!$ exit -!!$ else -!!$ update_band(param2band(i)) = .true. -!!$ end if -!!$ end if -!!$ end do -!!$ end if -!!$ -!!$ ! Check priors -!!$ if (data(1)%tod%myid == 0) then -!!$ call print_zodi_model(theta, labels, chisq) -!!$ chisq_tod = get_chisq_priors(theta_full, prior_vec_powell) -!!$ prior = chisq_tod -!!$ else -!!$ chisq_tod = 0.d0 -!!$ end if -!!$ call mpi_bcast(prior, 1, MPI_DOUBLE_PRECISION, 0, data(1)%tod%comm, ierr) -!!$ -!!$ if (prior >= 1.d30) then -!!$ lnL_zodi2 = 1.d30 -!!$ return -!!$ end if -!!$ -!!$ ndof = 0 -!!$ do i = 1, numband -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ ! If chisq is already too large, skip rest of the evaluation and go directly to rejection -!!$ if (chisq_tod >= 1.d30) exit -!!$ -!!$ ndet = data(i)%tod%ndet -!!$ nscan = data(i)%tod%nscan -!!$ -!!$ if (.not. update_band(i)) then -!!$ chisq_tod = chisq_tod + chisq_prev(i) -!!$ do scan = 1, nscan -!!$ do j = 1, ndet -!!$ if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle -!!$ ndof = ndof + size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) -!!$ end do -!!$ end do -!!$ cycle -!!$ end if -!!$ -!!$ box_width = get_boxwidth(data(i)%tod%samprate_lowres, data(i)%tod%samprate) -!!$ -!!$ ! Make sure that the zodi cache is cleared before each new band -!!$ call data(i)%tod%clear_zodi_cache() -!!$ -!!$ ! Evaluate zodi model with newly proposed values for each band and calculate chisq -!!$ do scan = 1, nscan -!!$ ! Skip scan if no accepted data -!!$ do j = 1, ndet -!!$ if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle -!!$ -!!$ call wall_time(t3) -!!$ call get_zodi_emission(& -!!$ & tod=data(i)%tod, & -!!$ & pix=data(i)%tod%scans(scan)%d(j)%downsamp_pix, & -!!$ & scan=scan, & -!!$ & det=j, & -!!$ & s_zodi_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & -!!$ & s_zodi_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & -!!$ & model=model, & -!!$ & use_lowres_pointing=.true. & -!!$ &) -!!$ call wall_time(t4) -!!$ !if (data(1)%tod%myid == 0) write(*,*) ' CPU1 = ', t4-t3 -!!$ call get_s_zodi(& -!!$ & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & -!!$ & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & -!!$ & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi, & -!!$ & emissivity=powell_emissivity(i, :), & -!!$ & albedo=powell_albedo(i, :) & -!!$ &) -!!$ call wall_time(t3) -!!$ !if (data(1)%tod%myid == 0) write(*,*) ' CPU2 = ', t3-t4 -!!$ -!!$ chisq = sum( & -!!$ & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & -!!$ & - data(i)%tod%scans(scan)%d(j)%downsamp_sky & -!!$ & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi & -!!$ & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0/sqrt(box_width)))**2 & -!!$ &) -!!$ chisq_tod = chisq_tod + chisq -!!$ chisq_prev(i) = chisq -!!$ call wall_time(t4) -!!$ !if (data(1)%tod%myid == 0) write(*,*) ' CPU3 = ', t4-t3 -!!$ -!!$ -!!$ -!!$ ndof = ndof + size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) -!!$ if (chisq_tod >= 1.d30) exit -!!$ ! call int2string(data(i)%tod%scanid(scan), scan_str) -!!$ ! call open_hdf_file(trim(adjustl("/mn/stornext/u3/metins/dirbe/chains/chains_downsamp/dtodlnl_"//scan_str//".h5")), tod_file, 'w') -!!$ ! call write_hdf(tod_file, '/dtod', data(i)%tod%scans(scan)%d(j)%downsamp_tod) -!!$ ! call write_hdf(tod_file, '/dzodi', data(i)%tod%scans(scan)%d(j)%downsamp_zodi) -!!$ ! call write_hdf(tod_file, '/dsky', data(i)%tod%scans(scan)%d(j)%downsamp_sky) -!!$ ! call write_hdf(tod_file, '/dpix', data(i)%tod%scans(scan)%d(j)%downsamp_pix) -!!$ ! call close_hdf_file(tod_file) -!!$ -!!$ if (data(1)%tod%myid == 0 .and. scan == 1) then -!!$ !write(*,*) "scan = ", data(i)%tod%scanid(scan), sum(abs(data(i)%tod%scans(scan)%d(j)%downsamp_tod)), sum(abs(data(i)%tod%scans(scan)%d(j)%downsamp_sky)), sum(abs(data(i)%tod%scans(scan)%d(j)%downsamp_zodi)), data(i)%tod%scans(scan)%d(j)%N_psd%sigma0 -!!$ open(58,file='res'//trim(data(i)%tod%freq)//'.dat') -!!$ do k = 1, size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) -!!$ write(58,*) data(i)%tod%scans(scan)%d(j)%downsamp_tod(k) & -!!$ & - data(i)%tod%scans(scan)%d(j)%downsamp_sky(k) & -!!$ & - data(i)%tod%scans(scan)%d(j)%downsamp_zodi(k) -!!$ end do -!!$ close(58) -!!$ end if -!!$ call wall_time(t3) -!!$ !if (data(1)%tod%myid == 0) write(*,*) ' CPU4 = ', t3-t4 -!!$ -!!$ end do -!!$ end do -!!$ end do -!!$ ! call mpi_barrier(MPI_COMM_WORLD, ierr) -!!$ ! stop -!!$ -!!$ ! Reduce chisq to root process -!!$ call mpi_reduce(chisq_tod, chisq, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, data(1)%tod%comm, ierr) -!!$ call mpi_reduce(ndof, ndof_tot, 1, MPI_INTEGER, MPI_SUM, 0, data(1)%tod%comm, ierr) -!!$ -!!$ call wall_time(t4) -!!$ !if (data(1)%tod%myid == 0) write(*,*) ' CPU5 = ', t4-t3 -!!$ -!!$ if (data(1)%tod%myid == 0) then -!!$ lnL_zodi2 = chisq/ndof_tot -!!$ call wall_time(t2) -!!$ if (ndof_tot > 0) write(*,fmt='(a,e16.8,a,f10.4,a,f8.3)') "chisq_zodi = ", chisq, ", chisq_red = ", chisq/ndof_tot, ", time = ", t2-t1 -!!$ write(*,*) -!!$ ! call print_zodi_model(theta, labels, chisq) -!!$ end if -!!$ end function - - subroutine get_s_zodi_with_n0(s_therm, s_scat, s_zodi, emissivity, albedo, n_0_comp_ratio, comp) - real(sp), dimension(:, :), intent(in) :: s_scat, s_therm - real(sp), dimension(:), intent(inout) :: s_zodi - real(dp), dimension(:), intent(in) :: emissivity, albedo, n_0_comp_ratio - integer(i4b) :: comp - integer(i4b) :: i - - s_zodi = 0. - do i = 1, size(s_therm, dim= 2) - s_zodi = s_zodi + (s_scat(:, i) * albedo(i) + (1. - albedo(i)) * emissivity(i) * s_therm(:, i)) * n_0_comp_ratio(i) - end do - end subroutine get_s_zodi_with_n0 - - subroutine parse_samp_group_strings(samp_group_str, param_labels, param_indices) + subroutine parse_samp_group_strings(samp_group_str, param_labels, param_indices) + implicit none character(len=*), intent(in) :: samp_group_str character(len=*), intent(in) :: param_labels(:) integer(i4b), allocatable, intent(inout) :: param_indices(:) @@ -1404,250 +829,7 @@ subroutine parse_samp_group_strings(samp_group_str, param_labels, param_indices) end do param_indices = pack(param_indices, param_indices > 0) end subroutine - - -!!$ subroutine zodi_model_to_ascii(cpar, model, filename, overwrite) -!!$ ! Dumps the zodi model to an ascii file on the format {COMP}_{PARAM} = {VALUE}. -!!$ class(ZodiModel), target, intent(in) :: model -!!$ type(comm_params), intent(in) :: cpar -!!$ character(len=*), intent(in) :: filename -!!$ logical(lgt), intent(in), optional :: overwrite -!!$ -!!$ integer(i4b) :: io, i, j, running_idx -!!$ logical(lgt) :: exists, overwrite_ -!!$ real(dp), allocatable :: params(:) -!!$ integer(i4b), allocatable :: comp_switch_indices(:) -!!$ character(len=128), allocatable :: labels(:) -!!$ character(len=512) :: concatenated_string, val -!!$ -!!$ if (present(overwrite)) then -!!$ overwrite_ = overwrite -!!$ else -!!$ overwrite_ = .false. -!!$ end if -!!$ -!!$ if (cpar%myid_chain /= cpar%root) return -!!$ inquire(file=trim(adjustl(filename)), exist=exists) -!!$ if (exists .and. (.not. overwrite_)) then -!!$ print *, "zodi asciifile: " // trim(adjustl(filename)) // " exists and overwrite = .false." -!!$ stop -!!$ end if -!!$ -!!$ open(newunit=io, file=trim(adjustl(filename)), action="write") -!!$ allocate(params(model%n_params)) -!!$ call model%model_to_params2(params, labels=labels) -!!$ -!!$ allocate(comp_switch_indices(model%n_comps)) -!!$ -!!$ running_idx = 0 -!!$ do i = 1, model%n_comps -!!$ running_idx = running_idx + size(model%comps(i)%labels) -!!$ comp_switch_indices(i) = running_idx -!!$ end do -!!$ -!!$ do i = 1, model%n_params -!!$ if (any(comp_switch_indices == i)) then -!!$ write(io, fmt='(a, T25, a, ES12.5, a)') trim(adjustl(labels(i))), "= ", params(i), new_line('a') -!!$ else -!!$ write(io, fmt='(a, T25, a, ES12.5)') trim(adjustl(labels(i))), "= ", params(i) -!!$ end if -!!$ end do -!!$ -!!$ write(io, fmt='(a)') '' -!!$ do i = 1, numband -!!$ if (trim(data(i)%tod_type) == 'none') cycle -!!$ if (.not. data(i)%tod%subtract_zodi) cycle -!!$ concatenated_string = "" -!!$ do j = 1, model%n_comps -!!$ write(val, fmt='(ES12.5)') model%comps(j)%c%emissivity(i) -!!$ concatenated_string = trim(adjustl(concatenated_string)) // "," // trim(adjustl(val)) -!!$ end do -!!$ write(io, fmt='(a, T25, a, a)') trim(adjustl("EMISSIVITY_"//trim(adjustl(data(i)%tod%freq)))), "= ", trim(adjustl(concatenated_string(2:))) -!!$ end do -!!$ -!!$ write(io, fmt='(a)') '' -!!$ do i = 1, numband -!!$ if (trim(data(i)%tod_type) == 'none') cycle -!!$ if (.not. data(i)%tod%subtract_zodi) cycle -!!$ concatenated_string = "" -!!$ do j = 1, model%n_comps -!!$ write(val, fmt='(ES12.5)') model%comps(j)%c%albedo(i) -!!$ concatenated_string = trim(adjustl(concatenated_string)) // "," // trim(adjustl(val)) -!!$ end do -!!$ write(io, fmt='(a, T25, a, a)') trim(adjustl("ALBEDO_"//trim(adjustl(data(i)%tod%freq)))), "= ", trim(adjustl(concatenated_string(2:))) -!!$ end do -!!$ -!!$ close(io) -!!$ end subroutine -!!$ -!!$ subroutine ascii_to_zodi_model(cpar, model, filename) -!!$ ! Reads in and updates the zodi model from an ascii file on the format {COMP}_{PARAM} = {VALUE}. -!!$ class(ZodiModel), target, intent(inout) :: model -!!$ type(comm_params), intent(in) :: cpar -!!$ character(len=*), intent(in) :: filename -!!$ type(hash_tbl_sll) :: htbl -!!$ -!!$ integer(i4b) :: i, j, io, io_status, ierr, n_comps -!!$ logical(lgt) :: exists -!!$ character(len=512) :: key, val, line -!!$ character(len=128), allocatable :: labels(:) -!!$ characteR(len=128) :: toks(100) -!!$ characteR(len=512) :: concatenated_string -!!$ real(dp), allocatable :: params(:) -!!$ -!!$ allocate(params(model%n_params)) -!!$ !if (cpar%myid_chain == cpar%root) then -!!$ inquire(file=trim(adjustl(filename)), exist=exists) -!!$ if (.not. exists) then -!!$ print *, "zodi asciifile: " // trim(adjustl(filename)) // " does not exist" -!!$ stop -!!$ end if -!!$ -!!$ call init_hash_tbl_sll(htbl, tbl_len=500) -!!$ -!!$ open(newunit=io, file=trim(adjustl(filename)), action="read") -!!$ io_status = 0 -!!$ do while (io_status == 0) -!!$ read(io, "(a)", iostat=io_status) line -!!$ if (io_status == 0 .and. line /= "") then -!!$ j = index(line, "=") -!!$ if (j == 0) then -!!$ print *, "Error: invalid line in ascii file: ", trim(adjustl(line)) -!!$ close(io) -!!$ stop -!!$ end if -!!$ -!!$ key = trim(adjustl(line(:j-1))) -!!$ val = trim(adjustl(line(j+1:))) -!!$ call tolower(key) -!!$ call put_hash_tbl_sll(htbl, trim(adjustl(key)), trim(adjustl(val))) -!!$ end if -!!$ end do -!!$ close(io) -!!$ -!!$ call model%model_to_params2(params, labels) -!!$ params = 0. -!!$ if (size(labels) /= size(params)) stop "Error: size of labels and params do not match" -!!$ do i = 1, size(labels) -!!$ call get_parameter_hashtable(htbl, labels(i), par_dp=params(i)) -!!$ end do -!!$ !end if -!!$ -!!$ !call mpi_bcast(params, size(params), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ call model%params_to_model2(params) -!!$ -!!$ do i = 1, numband -!!$ if (trim(data(i)%tod_type) == 'none') cycle -!!$ if (.not. data(i)%tod%subtract_zodi) cycle -!!$ !if (cpar%myid == 0) then -!!$ call get_parameter_hashtable(htbl, trim(adjustl("EMISSIVITY_"//trim(adjustl(data(i)%tod%freq)))), par_string=concatenated_string) -!!$ call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) -!!$ if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model emissivity" -!!$ do j = 1, n_comps -!!$ read(toks(j), *) model%comps(j)%c%emissivity(i) -!!$ end do -!!$ -!!$ call get_parameter_hashtable(htbl, trim(adjustl("ALBEDO_"//trim(adjustl(data(i)%tod%freq)))), par_string=concatenated_string) -!!$ call get_tokens(trim(adjustl(concatenated_string)), ',', toks, n_comps) -!!$ if (n_comps /= model%n_comps) stop "Error: number of components in ascii file does not match model albedo" -!!$ do j = 1, n_comps -!!$ read(toks(j), *) model%comps(j)%c%albedo(i) -!!$ end do -!!$ !end if -!!$ !call mpi_bcast(data(i)%tod%zodi_emissivity, size(data(i)%tod%zodi_emissivity), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ !call mpi_bcast(data(i)%tod%zodi_albedo, size(data(i)%tod%zodi_albedo), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ end do -!!$ end subroutine -!!$ -!!$ -!!$ subroutine print_zodi_model(theta, samp_group) -!!$ implicit none -!!$ real(dp), allocatable, intent(in) :: theta(:) -!!$ integer(i4b), intent(in) :: samp_group -!!$ -!!$ integer(i4b) :: i, j, k, l, n, idx, n_cols, col, comp, n_params -!!$ logical(lgt) :: newline -!!$ -!!$ n_cols = 5 -!!$ n_params = size(theta) -!!$ -!!$ ! General parameters -!!$ k = 1 -!!$ if (any(zodi_model%theta_stat(1:zodi_model%n_general_params,samp_group)==0)) then -!!$ write(*, "(a)", advance="no") 'General: ' -!!$ col = 1 -!!$ do i = 1, zodi_model%n_general_params -!!$ if (zodi_model%theta_stat(i,samp_group)==0) then -!!$ if (col > n_cols .or. i == zodi_model%n_general_params) then -!!$ write(*, "(a,a,g0.4,a)") trim(adjustl(zodi_model%par_labels(i))), "=", theta(k), ", " -!!$ col = 1 -!!$ else -!!$ write(*, "(a,a,g0.4,a)", advance="no") trim(adjustl(zodi_model%par_labels(i))), "=", theta(k), ", " -!!$ col = col+1 -!!$ end if -!!$ k = k+1 -!!$ end if -!!$ end do -!!$ end if -!!$ -!!$ ! Component parameters -!!$ do j = 1, zodi_model%n_comps -!!$ idx = zodi_model%comps(j)%start_ind -!!$ n = zodi_model%comps(j)%npar + 2*numband -!!$ if (all(zodi_model%theta_stat(idx:idx+n-1,samp_group)/=0)) cycle -!!$ write(*, "(a,a)", advance="no") trim(adjustl(zodi_model%comp_labels(j))),': ' -!!$ col = 1 -!!$ do i = idx, idx+n-1 -!!$ newline = (i==idx+n-1) .or. col == n_cols-1 -!!$ if (zodi_model%theta_stat(i,samp_group)==0) then -!!$ write(*, "(a,a,a,g0.4,a)", advance="no") " ", trim(adjustl(zodi_model%par_labels(i))), "=", theta(k), ", " -!!$ k = k+1 -!!$ col = col+1 -!!$ end if -!!$ if (newline .and. col>1) then -!!$ write(*,*) -!!$ col = 1 -!!$ end if -!!$ end do -!!$ end do -!!$ -!!$ ! Monopoles -!!$ col = 1 -!!$ write(*, "(a)", advance="no") 'Mono : ' -!!$ do j = 1, numband -!!$ idx = zodi_model%npar_tot - numband + j -!!$ if (zodi_model%theta_stat(idx,samp_group)==0) then -!!$ write(*, "(a,a,a,g0.4,a)", advance="no") " ", trim(adjustl(data(j)%label)), "=", theta(k), ", " -!!$ k = k+1 -!!$ col = col+1 -!!$ end if -!!$ if ((col == n_cols-1 .and. col>1) .or. j == numband) then -!!$ write(*,*) -!!$ col = 1 -!!$ end if -!!$ end do -!!$ -!!$ end subroutine - subroutine min_max_param_vec_with_priors(params, priors) - real(dp), intent(inout) :: params(:) - real(dp), intent(in) :: priors(:, :) - integer(i4b) :: i - - if (size(params) /= size(priors,1)) then - write(*,*) "Error: params and priors must have the same size", size(params), size(priors,1) - stop - end if - do i = 1, size(params) - if (priors(i, 3) == 1) cycle ! (0 is uniform, 1 is gaussian) - if (params(i) < priors(i, 1)) then - params(i) = priors(i, 1) - else if (params(i) > priors(i, 2)) then - params(i) = priors(i, 2) - end if - end do - - end subroutine subroutine randomize_zodi_init(x, samp_group, cpar, handle, rms) implicit none @@ -1895,188 +1077,4 @@ subroutine sample_static_zodi_map(cpar, handle, map_id) end subroutine sample_static_zodi_map - -!!$ subroutine sample_static_zodi_amps(cpar, handle) -!!$ implicit none -!!$ type(comm_params), intent(inout) :: cpar -!!$ type(planck_rng), intent(inout) :: handle -!!$ -!!$ integer(i4b) :: band, i, j, k, ndet, scan, nscan, npix, nmaps, p, ierr, ntod, nhorn, npix_band, ncomp, refband -!!$ real(dp) :: res, w, vec(3), elon -!!$ character(len=128) :: reflabel -!!$ real(dp), allocatable, dimension(:) :: A, b -!!$ real(sp), allocatable, dimension(:) :: s_sky -!!$ real(sp), allocatable, dimension(:,:) :: s_scat, s_therm -!!$ real(sp), allocatable, dimension(:) :: s_zodi, s_static -!!$ real(sp), allocatable, dimension(:,:,:,:) :: map_sky -!!$ type(map_ptr), allocatable, dimension(:,:) :: sky_signal -!!$ real(sp), allocatable, dimension(:) :: tod, mask, procmask_zodi -!!$ real(dp), allocatable, dimension(:,:) :: m_buf -!!$ integer(i4b), allocatable, dimension(:,:) :: pix, psi -!!$ integer(i4b), allocatable, dimension(:) :: flag -!!$ -!!$ if (cpar%myid == 0) then -!!$ write(*,*) ' Sampling static zodi amplitudes' -!!$ end if -!!$ -!!$ npix = 12*cpar%zodi_solar_nside**2 -!!$ nmaps = 1 -!!$ ncomp = zodi_model%n_comps -!!$ -!!$ ! Find reference band -!!$ refband = 0 -!!$ reflabel = 'none' -!!$ do i = 1, numband -!!$ if (trim(data(i)%label) == trim(cpar%zs_refband)) then -!!$ refband = i -!!$ reflabel = data(refband)%instlabel -!!$ exit -!!$ end if -!!$ end do -!!$ -!!$ ! Allocate temporary map structures -!!$ allocate(A(numband), b(numband), amp_old(numband)) -!!$ A = 0.d0; b = 0.d0 -!!$ amp_old = zodi_model%amp_static -!!$ -!!$ ! Add up contributions from all bands -!!$ do i = 1, numband -!!$ if (data(i)%tod_type == "none") cycle -!!$ if (.not. data(i)%tod%sample_zodi) cycle -!!$ if (trim(data(i)%label) == trim(cpar%zs_refband)) cycle -!!$ if (trim(data(i)%instlabel) == trim(reflabel)) cycle -!!$ -!!$ ndet = data(i)%tod%ndet -!!$ nscan = data(i)%tod%nscan -!!$ nhorn = data(i)%tod%nhorn -!!$ npix_band = 12*data(i)%map%info%nside**2 -!!$ -!!$ ! Set amplitude to 1 during these calculations -!!$ zodi_model%amp_static(i) = 1.d0 -!!$ -!!$ ! Get and distribute sky signal -!!$ allocate(sky_signal(data(i)%tod%ndet,1)) -!!$ do j = 1, data(i)%tod%ndet -!!$ call get_sky_signal(i, j, sky_signal(j,1)%p, mono=.true.) -!!$ end do -!!$ allocate (map_sky(nmaps, data(i)%tod%nobs, 0:data(i)%tod%ndet, 1)) -!!$ call distribute_sky_maps(data(i)%tod, sky_signal, 1.e0, map_sky) -!!$ -!!$ ! Initialize frequency-specific mask -!!$ allocate(m_buf(0:npix_band-1, nmaps), procmask_zodi(0:npix_band-1)) -!!$ call data(i)%tod%procmask_zodi%bcast_fullsky_map(m_buf); procmask_zodi = m_buf(:, 1) -!!$ deallocate(m_buf) -!!$ -!!$ ! Sum up contributions -!!$ do scan = 1, nscan -!!$ ntod = data(i)%tod%scans(scan)%ntod -!!$ allocate(s_scat(ntod,ncomp), s_therm(ntod,ncomp), s_zodi(ntod), s_sky(ntod), s_static(ntod)) -!!$ -!!$ do j = 1, ndet -!!$ if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle -!!$ -!!$ ! Get data and pointing -!!$ allocate(pix(ntod, nhorn), psi(ntod, nhorn), flag(ntod), tod(ntod), mask(ntod)) -!!$ if (data(i)%tod%compressed_tod) then -!!$ call data(i)%tod%decompress_tod(scan, j, tod) -!!$ else -!!$ tod = data(i)%tod%scans(scan)%d(j)%tod -!!$ end if -!!$ -!!$ ! Set up mask; remove flagged samples and foreground contaminated regions -!!$ call data(i)%tod%decompress_pointing_and_flags(scan, j, pix, psi, flag) -!!$ do k = 1, data(i)%tod%scans(scan)%ntod -!!$ mask(k) = procmask_zodi(pix(k, 1)) -!!$ if (iand(flag(k), data(i)%tod%flag0) .ne. 0) mask(k) = 0. -!!$ end do -!!$ where (mask > 0.5) -!!$ mask = 1. -!!$ elsewhere -!!$ mask = 0. -!!$ end where -!!$ -!!$ ! Compute zodi TODs -!!$ call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_zodi, pix_dynamic=pix) -!!$ call get_s_tot_zodi(zodi_model, data(i)%tod, j, scan, s_static, pix_static=data(i)%tod%scans(scan)%d(j)%pix_sol) -!!$ -!!$ ! Add residual to normal equations -!!$ w = 1.d0/data(i)%tod%scans(scan)%d(j)%N_psd%sigma0**2 -!!$ do k = 1, ntod -!!$ if (mask(k) == 0) cycle -!!$ s_sky(k) = map_sky(1, data(i)%tod%pix2ind(pix(k, 1)), j, 1) ! zodi is only temperature (for now) -!!$ A(i) = A(i) + w * s_static(k) * s_static(k) -!!$ b(i) = b(i) + w * s_static(k) * (tod(k) - (s_zodi(k)+s_sky(k))) -!!$ end do -!!$ deallocate(pix, psi, flag, tod, mask) -!!$ end do -!!$ deallocate(s_scat, s_therm, s_zodi, s_sky, s_static) -!!$ end do -!!$ deallocate(procmask_zodi,map_sky, sky_signal) -!!$ end do -!!$ -!!$ ! Gather information across cores -!!$ call mpi_allreduce(MPI_IN_PLACE, A, size(A), MPI_DOUBLE_PRECISION, MPI_SUM, cpar%comm_chain, ierr) -!!$ call mpi_allreduce(MPI_IN_PLACE, b, size(b), MPI_DOUBLE_PRECISION, MPI_SUM, cpar%comm_chain, ierr) -!!$ -!!$ ! Solve for best-fit amplitudes -!!$ if (cpar%myid_chain == 0) then -!!$ ! Collect data from bands with same instrument -!!$ -!!$ do i = 1, numband -!!$ do j = i+1, numband -!!$ if (trim(data(j)%instlabel) == trim(data(i)%instlabel)) then -!!$ A(i) = A(i) + A(j) -!!$ b(i) = b(i) + b(j) -!!$ end if -!!$ end do -!!$ end do -!!$ -!!$ ! Solve for new amplitudes -!!$ do i = 1, numband -!!$ if (trim(data(i)%instlabel) == trim(reflabel)) cycle -!!$ if (A(i) > 0.d0) then -!!$ if (trim(cpar%operation) == 'optimize') then -!!$ zodi_model%amp_static(i) = b(i)/A(i) -!!$ else if (trim(cpar%operation) == 'sample') then -!!$ zodi_model%amp_static(i) = b(i)/A(i) + rand_gauss(handle) / sqrt(A(i)) -!!$ else -!!$ write(*,*) 'Unknown operation in sample_static_zodi_amps = ', trim(cpar%operation) -!!$ end if -!!$ else -!!$ zodi_model%amp_static(i) = 0.d0 -!!$ end if -!!$ zodi_model%amp_static(i) = max(zodi_model%amp_static(i), 0.d0) -!!$ end do -!!$ -!!$ ! Synchronize amplitudes for bands with same instrument -!!$ do i = 1, numband -!!$ do j = i+1, numband -!!$ if (trim(data(j)%instlabel) == trim(data(i)%instlabel)) then -!!$ zodi_model%amp_static(j) = zodi_model%amp_static(i) -!!$ end if -!!$ end do -!!$ end do -!!$ -!!$ -!!$ end if -!!$ -!!$ call mpi_bcast(zodi_model%amp_static, numband, MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) -!!$ -!!$ ! Output to screen -!!$ if (cpar%myid == 0) then -!!$ do i = 1, numband -!!$ if (zodi_model%amp_static(i) /= amp_old(i) .and. zodi_model%amp_static(i) /= 0.d0) then -!!$ write(*,fmt='(a,a,a,f8.3,a,f8.3)') ' Static amp: Band = ', trim(data(i)%label), ', old = ', amp_old(i), ', new = ', zodi_model%amp_static(i) -!!$ end if -!!$ end do -!!$ end if -!!$ -!!$ ! Clean up -!!$ deallocate(A, b, amp_old) -!!$ -!!$ call mpi_finalize(ierr) -!!$ stop -!!$ -!!$ end subroutine sample_static_zodi_amps - -end module + end module comm_zodi_samp_mod diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 99676b2ea..82d003e27 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -273,39 +273,31 @@ program commander call timer%stop(TOT_TODPROC) end if - if (cpar%enable_tod_simulations) then - ! Skip other steps if TOD simulations - exit - end if + ! Skip other steps if TOD simulations + if (cpar%enable_tod_simulations) exit ! Sample zodi parameters if (mod(iter,modfact) == 0 .and. iter > 1 .and. cpar%enable_TOD_analysis .and. cpar%sample_zodi) then call timer%start(TOT_ZODI_SAMP) call project_and_downsamp_sky(cpar) - call downsamp_invariant_structs(cpar) if (first_zodi) then ! in the first tod gibbs iter we precompute timeinvariant downsampled quantities + call downsamp_invariant_structs(cpar) call precompute_lowres_zodi_lookups(cpar) - else - call apply_zodi_glitch_mask(cpar) - end if - - call compute_downsamp_zodi(cpar, zodi_model) - if (first_zodi) then - !call compute_downsamp_zodi(cpar, zodi_model) - call create_zodi_glitch_mask(cpar, handle) + !call compute_downsamp_zodi(cpar, zodi_model) + call create_zodi_sampgroup_mask(cpar, handle) first_zodi = .false. end if - call apply_zodi_glitch_mask(cpar) ! Sample non-stationary zodi components with geometric 3D model - select case (trim(adjustl(cpar%zs_sample_method))) - case ("powell") - do i = 1, cpar%zs_num_samp_groups + do i = 1, cpar%zs_num_samp_groups + call apply_zodi_sampgroup_mask(cpar, i) + select case (trim(adjustl(cpar%zs_sample_method))) + case ("powell") if (iter > 1) call minimize_zodi_with_powell(cpar, iter, handle, i) - end do - end select - + end select + end do + ! Sample stationary components !if (first_zodi) then if (cpar%sample_earth_maps) call sample_static_zodi_map(cpar, handle, 'earth') From 88c69da7892485fdc601a9074e6cdb959cbd1302 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Fri, 11 Apr 2025 13:14:55 +0200 Subject: [PATCH 144/171] first running version of n+2 mapmaking that doesn't crash --- .../defaults/bands/LFI/LFI_030_TOD.defaults | 2 +- commander3/src/comm_chisq_mod.f90 | 25 ++-- commander3/src/comm_data_mod.f90 | 25 +++- commander3/src/comm_diffuse_comp_smod.f90 | 16 ++- commander3/src/comm_map_mod.f90 | 115 +++++++++++++----- commander3/src/comm_n_lcut_mod.f90 | 6 +- commander3/src/comm_n_mod.f90 | 2 +- commander3/src/comm_n_qucov_mod.f90 | 4 +- commander3/src/comm_n_rms_mod.f90 | 12 +- commander3/src/comm_n_rms_qucov_mod.f90 | 8 +- commander3/src/comm_output_mod.f90 | 33 ++--- commander3/src/comm_param_mod.f90 | 5 +- commander3/src/comm_ptsrc_comp_mod.f90 | 14 ++- commander3/src/comm_tod_driver_mod.f90 | 4 +- commander3/src/comm_tod_gain_smod.f90 | 6 +- commander3/src/comm_tod_lfi_smod.f90 | 91 ++++++++++---- commander3/src/comm_tod_mapmaking_mod.f90 | 80 ++++++------ commander3/src/comm_tod_mod.f90 | 6 +- commander3/src/sharp.f90 | 2 +- 19 files changed, 306 insertions(+), 150 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults index 13f857037..b74d11cdb 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults @@ -39,7 +39,7 @@ BAND_TOD_BP_INIT_PROP&&& = bp_init_030_v1.dat BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 3 BAND_TOD_END_SCANID&&& = 44072 -BAND_TOD_TOT_NUMSCAN&&& = 45860 +BAND_TOD_TOT_NUMSCAN&&& = 44070 BAND_TOD_FLAG&&& = 6111232 BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 27M,27S,28M,28S diff --git a/commander3/src/comm_chisq_mod.f90 b/commander3/src/comm_chisq_mod.f90 index 6fb1b141e..24425cbd6 100644 --- a/commander3/src/comm_chisq_mod.f90 +++ b/commander3/src/comm_chisq_mod.f90 @@ -454,7 +454,7 @@ subroutine get_sky_signal(band, det, map_out, mono, cmbmap, abscal_comps, gainma character(len=512), intent(in), optional :: abscal_comps class(comm_map), pointer, intent(inout), optional :: gainmap - integer(i4b) :: i, j, k, n + integer(i4b) :: i, j, k, n, nmaps logical(lgt) :: skip, mono_, calmap real(dp) :: rms_EE2_prior class(comm_map), pointer :: map_diff, cmbmap_band, gaindiff @@ -462,12 +462,23 @@ subroutine get_sky_signal(band, det, map_out, mono, cmbmap, abscal_comps, gainma real(dp), allocatable, dimension(:,:) :: map, alm real(dp), dimension(5) :: P_quad character(len=16), dimension(100) :: abscal_labels - + class(comm_mapinfo), pointer :: info_pol => null() + mono_ = .true.; if (present(mono)) mono_=mono ! Allocate map - map_out => comm_map(data(band)%info) - map_diff => comm_map(data(band)%info) + nmaps = data(band)%info%nmaps + if(nmaps > 3) nmaps = 3 + + if(data(band)%distribute_type == 'nplus2') then + info_pol => comm_mapinfo(data(band)%info%comm, data(band)%info%nside, data(band)%info%lmax, nmaps, data(band)%info%pol, & + &distribute_type=data(band)%info%distribute_type) + map_out => comm_map(info_pol) + map_diff => comm_map(info_pol) + else + map_out => comm_map(data(band)%info) + map_diff => comm_map(data(band)%info) + end if if (present(cmbmap)) then cmbmap_band => comm_map(data(band)%info) @@ -510,7 +521,7 @@ subroutine get_sky_signal(band, det, map_out, mono, cmbmap, abscal_comps, gainma else alm = c%getBand(band, alm_out=.true., det=det) end if - map_diff%alm = map_diff%alm + alm + map_diff%alm = map_diff%alm + alm(:,1:nmaps) if (calmap) then do i = 1, n if (trim(c%label) == trim(abscal_labels(i))) then @@ -522,7 +533,7 @@ subroutine get_sky_signal(band, det, map_out, mono, cmbmap, abscal_comps, gainma class is (comm_ptsrc_comp) allocate(map(0:data(band)%info%np-1,data(band)%info%nmaps)) map = c%getBand(band, det=det) - map_out%map = map_out%map + map + map_out%map = map_out%map + map(:, 1:nmaps) if (calmap) then do i = 1, n if (trim(c%label) == trim(abscal_labels(i))) then @@ -534,7 +545,7 @@ subroutine get_sky_signal(band, det, map_out, mono, cmbmap, abscal_comps, gainma class is (comm_template_comp) allocate(map(0:data(band)%info%np-1,data(band)%info%nmaps)) map = c%getBand(band, det=det) - map_out%map = map_out%map + map + map_out%map = map_out%map + map(:, 1:nmaps) if (calmap) then do i = 1, n if (trim(c%label) == trim(abscal_labels(i))) then diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index f542a73dc..3ea11b204 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -44,6 +44,7 @@ module comm_data_mod integer(i4b) :: tod_freq logical(lgt) :: pol_only, subtract_zodi logical(lgt) :: cr_active + character(len=128) :: distribute_type class(comm_mapinfo), pointer :: info => null() class(comm_mapinfo), pointer :: rmsinfo => null() @@ -82,7 +83,7 @@ subroutine initialize_data_mod(cpar, handle) type(comm_params), intent(in) :: cpar type(planck_rng), intent(inout) :: handle - integer(i4b) :: i, j, k, n, nmaps, numband_tot, ierr + integer(i4b) :: i, j, k, n, nmaps, numband_tot, ierr, ndets character(len=512) :: dir, mapfile class(comm_N), pointer :: tmp => null() class(comm_map), pointer :: smoothed_rms => null() @@ -119,6 +120,7 @@ subroutine initialize_data_mod(cpar, handle) data(n)%tod_type = cpar%ds_tod_type(i) data(n)%subtract_zodi = cpar%ds_tod_subtract_zodi(i) data(n)%noise_format = cpar%ds_noise_format(i) + data(n)%distribute_type = '' allocate(data(n)%gain_stat(cpar%mcmc_num_user_samp_groups)) @@ -129,15 +131,28 @@ subroutine initialize_data_mod(cpar, handle) call update_status(status, "data_"//trim(data(n)%label)) ! Initialize map structures - nmaps = 1; if (cpar%ds_polarization(i)) nmaps = 3 + nmaps = 1 + if (cpar%ds_polarization(i)) then + nmaps = 3 + end if + if (data(n)%tod_type /= 'none') then + if (cpar%ds_tod_map_type(i) == 'nplus2') then + data(n)%distribute_type = 'nplus2' + ndets = num_tokens(trim(cpar%ds_tod_dets(i)), ",") + nmaps = ndets + 3 + end if + end if + data(n)%info => comm_mapinfo(cpar%comm_chain, cpar%ds_nside(i), cpar%ds_lmax(i), & - & nmaps, cpar%ds_polarization(i)) + & nmaps, cpar%ds_polarization(i), distribute_type=data(n)%distribute_type) call get_mapfile(cpar, i, mapfile) data(n)%map => comm_map(data(n)%info, trim(mapfile), mask_misspix=mask_misspix) if (trim(data(n)%noise_format) == 'rms_qucov' .and. cpar%ds_polarization(i)) then data(n)%rmsinfo => comm_mapinfo(cpar%comm_chain, cpar%ds_nside(i), cpar%ds_lmax(i), & - & nmaps+1, cpar%ds_polarization(i)) - else + & nmaps+1, cpar%ds_polarization(i), distribute_type=data(n)%distribute_type) + end if + + if(.not. associated(data(n)%rmsinfo)) then data(n)%rmsinfo => data(n)%info end if if (cpar%only_pol) data(n)%map%map(:,1) = 0.d0 diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 9a70716ec..4938f5c53 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -2977,17 +2977,27 @@ module subroutine updateDiffuseFInt(self, band) class(comm_diffuse_comp), intent(inout) :: self integer(i4b), intent(in), optional :: band - integer(i4b) :: i, j, k + integer(i4b) :: i, j, k, nmaps + + ! only do the computation for the I,Q,U maps, not for the individual det maps + ! that info is instead stored in the j index in this structure if (present(band)) then - do i = 1, data(band)%info%nmaps + ! only do the computation for the I,Q,U maps, not for the individual det maps + ! that info is instead stored in the j index in this structure + nmaps = data(band)%info%nmaps + if (nmaps > 3) nmaps = 3 + + do i = 1, nmaps do j = 0, data(band)%ndet call self%F_int(i,band,j)%p%update(pol=i) end do end do else do k = 1, numband - do i = 1, data(k)%info%nmaps + nmaps = data(k)%info%nmaps + if (nmaps > 3) nmaps = 3 + do i = 1, nmaps do j = 0, data(k)%ndet call self%F_int(i,k,j)%p%update(pol=i) end do diff --git a/commander3/src/comm_map_mod.f90 b/commander3/src/comm_map_mod.f90 index 3a574bd2e..f1857abe1 100644 --- a/commander3/src/comm_map_mod.f90 +++ b/commander3/src/comm_map_mod.f90 @@ -47,7 +47,7 @@ module comm_map_mod ! Data variables type(sharp_alm_info) :: alm_info type(sharp_geom_info) :: geom_info_T, geom_info_P - logical(lgt) :: pol, dist + logical(lgt) :: pol, dist, rms integer(i4b) :: comm, myid, nprocs integer(i4b) :: nside, npix, nmaps, nspec, nring, np, lmax, nm, nalm, mmax integer(c_int), allocatable, dimension(:) :: rings @@ -57,6 +57,7 @@ module comm_map_mod integer(c_int), allocatable, dimension(:) :: pix real(c_double), allocatable, dimension(:,:) :: W integer(i4b), allocatable, dimension(:) :: nalms + character(len=128) :: distribute_type contains procedure :: lm2i procedure :: i2lm @@ -155,11 +156,13 @@ end subroutine tod2file_dp3 !************************************************** ! Constructors !************************************************** - function constructor_mapinfo(comm, nside, lmax, nmaps, pol, dist) + function constructor_mapinfo(comm, nside, lmax, nmaps, pol, dist, distribute_type, rms) implicit none integer(i4b), intent(in) :: comm, nside, lmax, nmaps logical(lgt), intent(in) :: pol logical(lgt), optional, intent(in) :: dist + character(len=128), optional, intent(in) :: distribute_type + logical(lgt), optional, intent(in) :: rms class(comm_mapinfo), pointer :: constructor_mapinfo integer(i4b) :: myid, nprocs, ierr @@ -212,6 +215,10 @@ function constructor_mapinfo(comm, nside, lmax, nmaps, pol, dist) p_new%pol = pol p_new%npix = 12*nside**2 p_new%dist = distval + p_new%distribute_type = '' + if(present(distribute_type)) p_new%distribute_type = distribute_type + p_new%rms = .false. + if(present(rms)) p_new%rms = rms ! Select rings and pixels @@ -347,9 +354,9 @@ function constructor_map(info, filename, mask_misspix, udgrade) if (present(filename)) then if (present(mask_misspix)) then allocate(mask_misspix(0:info%np-1,info%nmaps)) - call constructor_map%readFITS(filename, mask=mask_misspix, udgrade=udgrade) + call constructor_map%readFITS(filename, mask=mask_misspix, udgrade=udgrade, dist_type=info%distribute_type) else - call constructor_map%readFITS(filename, udgrade=udgrade) + call constructor_map%readFITS(filename, udgrade=udgrade, dist_type=info%distribute_type) end if else if (info%np > 0) constructor_map%map = 0.d0 @@ -472,10 +479,14 @@ subroutine exec_sharp_Y(self) if (self%info%pol) then call sharp_execute(SHARP_Y, 0, 1, self%alm(:,1:1), self%info%alm_info, & & self%map(:,1:1), self%info%geom_info_T, comm=self%info%comm) - if (self%info%nmaps == 3) then + if (self%info%nmaps >= 3) then call sharp_execute(SHARP_Y, 2, 2, self%alm(:,2:3), self%info%alm_info, & & self%map(:,2:3), self%info%geom_info_P, comm=self%info%comm) end if + if (self%info%nmaps > 3) then + call sharp_execute(SHARP_Y, 0, self%info%nmaps-3, self%alm(:,4:self%info%nmaps), self%info%alm_info, & + & self%map(:,4:self%info%nmaps), self%info%geom_info_T, comm=self%info%comm) + end if else call sharp_execute(SHARP_Y, 0, self%info%nmaps, self%alm, self%info%alm_info, & & self%map, self%info%geom_info_T, comm=self%info%comm) @@ -494,10 +505,15 @@ subroutine exec_sharp_WY(self) if (self%info%pol) then call sharp_execute(SHARP_WY, 0, 1, self%alm(:,1:1), self%info%alm_info, & & self%map(:,1:1), self%info%geom_info_T, comm=self%info%comm) - if (self%info%nmaps == 3) then + if (self%info%nmaps >= 3) then call sharp_execute(SHARP_WY, 2, 2, self%alm(:,2:3), self%info%alm_info, & & self%map(:,2:3), self%info%geom_info_P, comm=self%info%comm) end if + if (self%info%nmaps > 3) then + call sharp_execute(SHARP_WY, 0, self%info%nmaps-3, self%alm(:,4:self%info%nmaps), self%info%alm_info, & + & self%map(:,4:self%info%nmaps), self%info%geom_info_T, comm=self%info%comm) + end if + else call sharp_execute(SHARP_WY, 0, self%info%nmaps, self%alm, self%info%alm_info, & & self%map, self%info%geom_info_T, comm=self%info%comm) @@ -553,11 +569,15 @@ subroutine exec_sharp_Yt(self) if (self%info%pol) then call sharp_execute(SHARP_Yt, 0, 1, self%alm(:,1:1), self%info%alm_info, & & self%map(:,1:1), self%info%geom_info_T, comm=self%info%comm) - if (self%info%nmaps == 3) then + if (self%info%nmaps >= 3) then call sharp_execute(SHARP_Yt, 2, 2, self%alm(:,2:3), self%info%alm_info, & & self%map(:,2:3), self%info%geom_info_P, comm=self%info%comm) end if - + if (self%info%nmaps > 3) then + call sharp_execute(SHARP_Yt, 0, self%info%nmaps-3, self%alm(:,4:self%info%nmaps), self%info%alm_info, & + & self%map(:,4:self%info%nmaps), self%info%geom_info_T, comm=self%info%comm) + end if + else call sharp_execute(SHARP_Yt, 0, self%info%nmaps, self%alm, self%info%alm_info, & & self%map, self%info%geom_info_T, comm=self%info%comm) @@ -596,6 +616,11 @@ subroutine exec_sharp_YtW(self) call sharp_execute(SHARP_YtW, 2, 2, self%alm(:,2:3), self%info%alm_info, & & self%map(:,2:3), self%info%geom_info_P, comm=self%info%comm) end if + if (self%info%nmaps > 3) then + call sharp_execute(SHARP_YtW, 0, self%info%nmaps-3, self%alm(:,4:self%info%nmaps), self%info%alm_info, & + & self%map(:,4:self%info%nmaps), self%info%geom_info_T, comm=self%info%comm) + end if + else call sharp_execute(SHARP_YtW, 0, self%info%nmaps, self%alm, self%info%alm_info, & & self%map, self%info%geom_info_T, comm=self%info%comm) @@ -829,25 +854,46 @@ subroutine writeFITS(self, filename, comptype, nu_ref, unit, ttype, spectrumfile end subroutine writeFITS - subroutine readFITS(self, filename, mask, udgrade) + subroutine readFITS(self, filename, mask, udgrade, dist_type) implicit none class(comm_map), intent(inout) :: self real(dp), dimension(0:,1:), intent(out), optional :: mask logical(lgt), intent(in), optional :: udgrade character(len=*), intent(in) :: filename + character(len=128), intent(in), optional :: dist_type - integer(i4b) :: i, j, np, npix, ordering, nside, nmaps, ierr, badpix + integer(i4b) :: i, j, np, npix, ordering, nside, nmaps, ierr, badpix, nmaps_in real(dp), allocatable, dimension(:,:) :: map, buffer, map_in integer(i4b), allocatable, dimension(:) :: p integer(i4b), dimension(MPI_STATUS_SIZE) :: mpistat ! Check file consistency npix = int(getsize_fits(trim(filename), ordering=ordering, nside=nside, nmaps=nmaps),i4b) + if (nmaps < self%info%nmaps) then - if (self%info%myid == 0) write(*,*) 'Incorrect nmaps in ' // trim(filename), nmaps, self%info%nmaps - call mpi_finalize(ierr) - stop + if(present(dist_type)) then + if (trim(dist_type) == 'nplus2') then + !distribute the nmaps=3 maps to I,Q,U,I_1,I_2,I_3... + if(nmaps > 3) then + if (self%info%myid == 0) write(*,*) 'Unbroadcastable nmaps in ' // trim(filename), nmaps, self%info%nmaps + call mpi_finalize(ierr) + stop + end if + nmaps_in = nmaps + else + if (self%info%myid == 0) write(*,*) 'dist_type not supported for ' // trim(filename), nmaps, self%info%nmaps, dist_type + call mpi_finalize(ierr) + write(*,*)1.0/0.d0 + stop + end if + else !crash because we don't know what to do + if (self%info%myid == 0) write(*,*) 'Incorrect nmaps in ' // trim(filename), nmaps, self%info%nmaps, present(dist_type), dist_type + call mpi_finalize(ierr) + stop + end if + else + nmaps_in = self%info%nmaps end if if (nside /= self%info%nside .and. .not. (present(udgrade))) then if (self%info%myid == 0) write(*,*) 'Incorrect nside in ' // trim(filename), 'Expected ', self%info%nside @@ -861,16 +907,16 @@ subroutine readFITS(self, filename, mask, udgrade) ! Read map and convert to RING format if necessary allocate(map(0:self%info%npix-1,self%info%nmaps)) if (present(udgrade)) then - allocate(map_in(0:npix-1,self%info%nmaps)) - call input_map(filename, map_in, npix, self%info%nmaps, ignore_polcconv=.true.) + allocate(map_in(0:npix-1, nmaps_in)) + call input_map(filename, map_in, npix, nmaps_in, ignore_polcconv=.true.) if (ordering == 1) then - call udgrade_ring(map_in, nside, map, nside_out=self%info%nside) + call udgrade_ring(map_in, nside, map(:,1:nmaps_in), nside_out=self%info%nside) else - call udgrade_nest(map_in, nside, map, nside_out=self%info%nside) + call udgrade_nest(map_in, nside, map(:,1:nmaps_in), nside_out=self%info%nside) end if deallocate(map_in) else - call input_map(filename, map, self%info%npix, self%info%nmaps, ignore_polcconv=.true.) + call input_map(filename, map, self%info%npix, nmaps_in, ignore_polcconv=.true.) end if if (present(mask)) then @@ -886,6 +932,15 @@ subroutine readFITS(self, filename, mask, udgrade) end do end if + if(dist_type == 'nplus2') then !Use I map for I_1,I_2... + if(self%info%myid == 0) write(*,'(a,i1,a,a)') "Broadcasting n+2 maps from nmaps= ", nmaps, " for ", trim(filename) + do i = 4, self%info%nmaps + map(:,i) = map(:,1) + ! scale rms maps by sqrt(n) + if(self%info%rms) map(:,i) = map(:,i) *sqrt(float(self%info%nmaps - 3)) + end do + end if + ! Distribute to other nodes allocate(p(self%info%npix)) self%map = map(self%info%pix,:) @@ -1476,28 +1531,32 @@ subroutine bcast_fullsky_map(self, map) class(comm_map), intent(in) :: self real(dp), dimension(0:,1:), intent(out) :: map - integer(i4b) :: i, nmaps, npix, np, ierr - real(dp), allocatable, dimension(:,:) :: buffer + integer(i4b) :: i, npix, np, ierr, nmaps_loc + real(dp), allocatable, dimension(:,:) :: buffer_loc integer(i4b), allocatable, dimension(:) :: p npix = self%info%npix - nmaps = self%info%nmaps + nmaps_loc = size(map, 2) + + ! If we are just broadcasting I or just IQU for an n+2 map + !if(size(map, 2) < nmaps) nmaps = size(map, 2) allocate(p(npix)) do i = 0, self%info%nprocs-1 if (self%info%myid == i) then np = self%info%np p(1:np) = self%info%pix(1:np) - allocate(buffer(np,nmaps)) - buffer = self%map + allocate(buffer_loc(np,nmaps_loc)) + buffer_loc = self%map(:, 1:nmaps_loc) end if - + + call mpi_bcast(np, 1, MPI_INTEGER, i, self%info%comm, ierr) call mpi_bcast(p(1:np), np, MPI_INTEGER, i, self%info%comm, ierr) - if (.not. allocated(buffer)) allocate(buffer(np,nmaps)) - call mpi_bcast(buffer, np*nmaps, MPI_DOUBLE_PRECISION, i, self%info%comm, ierr) - map(p(1:np),:) = buffer(1:np,:) - deallocate(buffer) + if (.not. allocated(buffer_loc)) allocate(buffer_loc(np,nmaps_loc)) + call mpi_bcast(buffer_loc, np*nmaps_loc, MPI_DOUBLE_PRECISION, i, self%info%comm, ierr) + map(p(1:np),:) = buffer_loc(1:np,:) + deallocate(buffer_loc) end do deallocate(p) diff --git a/commander3/src/comm_n_lcut_mod.f90 b/commander3/src/comm_n_lcut_mod.f90 index 1407e3e70..0b75632a9 100644 --- a/commander3/src/comm_n_lcut_mod.f90 +++ b/commander3/src/comm_n_lcut_mod.f90 @@ -64,7 +64,7 @@ function constructor(cpar, info, id, id_abs, id_smooth, mask, handle, regnoise, implicit none class(comm_N_lcut), pointer :: constructor type(comm_params), intent(in) :: cpar - type(comm_mapinfo), target, intent(in) :: info + type(comm_mapinfo), target, intent(inout) :: info integer(i4b), intent(in) :: id, id_abs, id_smooth class(comm_map), intent(in) :: mask type(planck_rng), intent(inout) :: handle @@ -151,8 +151,8 @@ end function constructor subroutine update_N_lcut(self, info, handle, mask, regnoise, procmask, noisefile, map) implicit none - class(comm_N_lcut), intent(inout) :: self - class(comm_mapinfo), intent(in) :: info + class(comm_N_lcut), intent(inout) :: self + class(comm_mapinfo), intent(inout) :: info type(planck_rng), intent(inout) :: handle class(comm_map), intent(in), optional :: mask real(dp), dimension(0:,1:), intent(out), optional :: regnoise diff --git a/commander3/src/comm_n_mod.f90 b/commander3/src/comm_n_mod.f90 index 7186928d2..4dfa60eaa 100644 --- a/commander3/src/comm_n_mod.f90 +++ b/commander3/src/comm_n_mod.f90 @@ -110,7 +110,7 @@ subroutine update_N(self, info, handle, mask, regnoise, procmask, noisefile, map implicit none class(comm_N), intent(inout) :: self type(planck_rng), intent(inout) :: handle - class(comm_mapinfo), intent(in) :: info + class(comm_mapinfo), intent(inout) :: info class(comm_map), intent(in), optional :: mask real(dp), dimension(0:,1:), intent(out), optional :: regnoise class(comm_map), intent(in), optional :: procmask diff --git a/commander3/src/comm_n_qucov_mod.f90 b/commander3/src/comm_n_qucov_mod.f90 index c016bd361..62d70646b 100644 --- a/commander3/src/comm_n_qucov_mod.f90 +++ b/commander3/src/comm_n_qucov_mod.f90 @@ -59,7 +59,7 @@ function constructor(cpar, info, id, id_abs, id_smooth, mask, handle, regnoise, implicit none class(comm_N_QUcov), pointer :: constructor type(comm_params), intent(in) :: cpar - type(comm_mapinfo), target, intent(in) :: info + type(comm_mapinfo), target, intent(inout) :: info integer(i4b), intent(in) :: id, id_abs, id_smooth class(comm_map), intent(in) :: mask type(planck_rng), intent(inout) :: handle @@ -93,7 +93,7 @@ end function constructor subroutine update_N_QUcov(self, info, handle, mask, regnoise, procmask, noisefile, map) implicit none class(comm_N_QUcov), intent(inout) :: self - class(comm_mapinfo), intent(in) :: info + class(comm_mapinfo), intent(inout) :: info type(planck_rng), intent(inout) :: handle class(comm_map), intent(in), optional :: mask real(dp), dimension(0:,1:), intent(out), optional :: regnoise diff --git a/commander3/src/comm_n_rms_mod.f90 b/commander3/src/comm_n_rms_mod.f90 index 05fe03451..3627e1c0c 100644 --- a/commander3/src/comm_n_rms_mod.f90 +++ b/commander3/src/comm_n_rms_mod.f90 @@ -59,7 +59,7 @@ function constructor(cpar, info, id, id_abs, id_smooth, mask, handle, regnoise, implicit none class(comm_N_rms), pointer :: constructor type(comm_params), intent(in) :: cpar - type(comm_mapinfo), target, intent(in) :: info + type(comm_mapinfo), target, intent(inout) :: info integer(i4b), intent(in) :: id, id_abs, id_smooth class(comm_map), intent(in) :: mask type(planck_rng), intent(inout) :: handle @@ -108,7 +108,7 @@ function constructor(cpar, info, id, id_abs, id_smooth, mask, handle, regnoise, else tmp = int(getsize_fits(trim(cpar%ds_noise_rms_smooth(id_abs,id_smooth)), nside=nside_smooth), i4b) info_smooth => comm_mapinfo(info%comm, nside_smooth, cpar%lmax_smooth(id_smooth), & - & constructor%nmaps, constructor%pol) + & constructor%nmaps, constructor%pol, distribute_type=info%distribute_type, rms=.true.) constructor%nside = info_smooth%nside constructor%np = info_smooth%np constructor%siN => comm_map(info_smooth, trim(cpar%ds_noise_rms_smooth(id_abs,id_smooth))) @@ -143,7 +143,7 @@ end function constructor subroutine update_N_rms(self, info, handle, mask, regnoise, procmask, noisefile, map) implicit none class(comm_N_rms), intent(inout) :: self - class(comm_mapinfo), intent(in) :: info + class(comm_mapinfo), intent(inout) :: info type(planck_rng), intent(inout) :: handle class(comm_map), intent(in), optional :: mask real(dp), dimension(0:,1:), intent(out), optional :: regnoise @@ -157,6 +157,7 @@ subroutine update_N_rms(self, info, handle, mask, regnoise, procmask, noisefile, class(comm_mapinfo), pointer :: info_lowres => null() call update_status(status, "update_N_rms") + info%rms = .true. if (present(noisefile)) then self%rms0 => comm_map(info, noisefile) @@ -174,6 +175,9 @@ subroutine update_N_rms(self, info, handle, mask, regnoise, procmask, noisefile, if (associated(self%rms_reg)) then self%siN%map = sqrt(self%siN%map**2 + self%rms_reg%map**2) end if + if(.not. present(mask)) then + write(*,*) "Mask not provided in update_N_rms" + end if call uniformize_rms(handle, self%siN, self%uni_fsky, mask, regnoise) self%siN%map = self%siN%map * mask%map ! Apply mask if (present(procmask)) then @@ -251,7 +255,7 @@ subroutine update_N_rms(self, info, handle, mask, regnoise, procmask, noisefile, ! Set up lowres map if (.not.associated(self%siN_lowres)) then - info_lowres => comm_mapinfo(self%info%comm, self%nside_chisq_lowres, 0, self%nmaps, self%pol) + info_lowres => comm_mapinfo(self%info%comm, self%nside_chisq_lowres, 0, self%nmaps, self%pol, rms=.true.) self%siN_lowres => comm_map(info_lowres) end if iN => comm_map(self%siN) diff --git a/commander3/src/comm_n_rms_qucov_mod.f90 b/commander3/src/comm_n_rms_qucov_mod.f90 index ac265515a..5b472217e 100644 --- a/commander3/src/comm_n_rms_qucov_mod.f90 +++ b/commander3/src/comm_n_rms_qucov_mod.f90 @@ -67,9 +67,9 @@ module comm_N_rms_QUcov_mod !************************************************** function constructor(cpar, info, id, id_abs, id_smooth, mask, handle, regnoise, procmask, map) implicit none - class(comm_N_rms_QUcov), pointer :: constructor + class(comm_N_rms_QUcov), pointer :: constructor type(comm_params), intent(in) :: cpar - type(comm_mapinfo), target, intent(in) :: info + type(comm_mapinfo), target, intent(inout) :: info integer(i4b), intent(in) :: id, id_abs, id_smooth class(comm_map), intent(in) :: mask type(planck_rng), intent(inout) :: handle @@ -156,8 +156,8 @@ end function constructor subroutine update_N_rms_QUcov(self, info, handle, mask, regnoise, procmask, noisefile, map) implicit none - class(comm_N_rms_QUcov), intent(inout) :: self - class(comm_mapinfo), intent(in) :: info + class(comm_N_rms_QUcov), intent(inout) :: self + class(comm_mapinfo), intent(inout) :: info type(planck_rng), intent(inout) :: handle class(comm_map), intent(in), optional :: mask real(dp), dimension(0:,1:), intent(out), optional :: regnoise diff --git a/commander3/src/comm_output_mod.f90 b/commander3/src/comm_output_mod.f90 index cace967f6..0992ef081 100644 --- a/commander3/src/comm_output_mod.f90 +++ b/commander3/src/comm_output_mod.f90 @@ -89,7 +89,7 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) integer(i4b), intent(in) :: iter logical(lgt), intent(in) :: output_hdf - integer(i4b) :: i, j, p, hdferr, ierr, unit, p_min, p_max + integer(i4b) :: i, j, p, hdferr, ierr, unit, p_min, p_max, nmaps real(dp) :: chisq, chisq_eff, t1, t2, t3, t4, theta_sum, uscale logical(lgt) :: exist, init, new_header character(len=4) :: ctext @@ -344,7 +344,7 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) if (cpar%output_chisq) then call data(i)%N%sqrtInvN(map) map%map = map%map**2 - info => comm_mapinfo(data(i)%info%comm, chisq_map%info%nside, 0, data(i)%info%nmaps, data(i)%info%nmaps==3) + info => comm_mapinfo(data(i)%info%comm, chisq_map%info%nside, 0, data(i)%info%nmaps, data(i)%info%pol) chisq_sub => comm_map(info) call map%udgrade(chisq_sub) @@ -352,18 +352,23 @@ subroutine output_FITS_sample(cpar, iter, output_hdf) ! of bands with different units comparable uscale = data(i)%bp(0)%p%unit_scale do j = 1, data(i)%info%nmaps - chisq_map%map(:,j) = chisq_map%map(:,j) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) - chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) - !N => data(i)%N - ! select type (N) - ! Defining chisq_eff = -2*log(L) such that - ! -2*log(L) = chi^2 + log(det(2*pi*Sigma)) - ! log(det(Sigma)) -> 2*log(2*pi*sigma) - ! class is (comm_N_rms) - ! chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + log(2*pi) + 2*log(N%rms0%map(:,j)/uscale) - ! class is (comm_N_lcut) - ! chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + log(2*pi) + 2*log(N%rms0%map(:,j)/uscale) - ! end select + if(data(i)%info%nmaps > 3) then + chisq_map%map(:,1) = chisq_map%map(:,1) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) + chisq_map_eff%map(:,1) = chisq_map_eff%map(:,1) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) + else + chisq_map%map(:,j) = chisq_map%map(:,j) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) + chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + chisq_sub%map(:,j) * (map%info%npix/chisq_sub%info%npix) + !N => data(i)%N + ! select type (N) + ! Defining chisq_eff = -2*log(L) such that + ! -2*log(L) = chi^2 + log(det(2*pi*Sigma)) + ! log(det(Sigma)) -> 2*log(2*pi*sigma) + ! class is (comm_N_rms) + ! chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + log(2*pi) + 2*log(N%rms0%map(:,j)/uscale) + ! class is (comm_N_lcut) + ! chisq_map_eff%map(:,j) = chisq_map_eff%map(:,j) + log(2*pi) + 2*log(N%rms0%map(:,j)/uscale) + ! end select + end if end do call chisq_sub%dealloc(); deallocate(chisq_sub) end if diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index c67824210..d0473f57e 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -166,6 +166,7 @@ module comm_param_mod character(len=2048), allocatable, dimension(:) :: ds_tod_procmask_zodi character(len=2048), allocatable, dimension(:) :: ds_tod_filelist character(len=2048), allocatable, dimension(:) :: ds_tod_jumplist + character(len=2048), allocatable, dimension(:) :: ds_tod_map_type character(len=2048), allocatable, dimension(:) :: ds_tod_instfile character(len=2048), allocatable, dimension(:) :: ds_tod_dets character(len=2048), allocatable, dimension(:) :: ds_tod_bp_init @@ -618,7 +619,7 @@ subroutine read_data_params_hash(htbl, cpar) allocate(cpar%ds_gain_lmin(n), cpar%ds_gain_apodmask(n), cpar%ds_gain_fwhm(n)) allocate(cpar%ds_defaults(n,2)) allocate(cpar%ds_component_sensitivity(n)) - allocate(cpar%ds_tod_type(n), cpar%ds_tod_filelist(n), cpar%ds_tod_jumplist(n), cpar%ds_tod_initHDF(n), cpar%ds_tod_level(n)) + allocate(cpar%ds_tod_type(n), cpar%ds_tod_filelist(n), cpar%ds_tod_jumplist(n), cpar%ds_tod_initHDF(n), cpar%ds_tod_level(n), cpar%ds_tod_map_type(n)) allocate(cpar%ds_tod_procmask1(n), cpar%ds_tod_procmask2(n), cpar%ds_tod_bp_init(n)) allocate(cpar%ds_tod_instfile(n), cpar%ds_tod_dets(n), cpar%ds_tod_scanrange(n,2)) allocate(cpar%ds_tod_tot_numscan(n), cpar%ds_tod_flag(n), cpar%ds_tod_abscal(n), cpar%ds_tod_halfring(n), cpar%ds_tod_subtract_zodi(n), cpar%ds_tod_freq(n)) @@ -724,6 +725,8 @@ subroutine read_data_params_hash(htbl, cpar) & par_int=cpar%ds_tod_scanrange(i,2)) call get_parameter_hashtable(htbl, 'BAND_TOD_TOT_NUMSCAN'//itext, len_itext=len_itext, & & par_int=cpar%ds_tod_tot_numscan(i)) + call get_parameter_hashtable(htbl, 'BAND_TOD_MAPMAKE_TYPE'//itext, len_itext=len_itext, & + & par_string=cpar%ds_tod_map_type(i)) call get_parameter_hashtable(htbl, 'BAND_TOD_FLAG'//itext, len_itext=len_itext, & & par_int=cpar%ds_tod_flag(i)) cpar%ds_tod_flag(i) = cpar%ds_tod_flag(i) + 2**30 ! Always Enable dynamic flagging in Commander diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index a45a01ed3..5ab516f6e 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -2903,13 +2903,19 @@ subroutine updatePtsrcFInt(self, band) class(comm_ptsrc_comp), intent(inout) :: self integer(i4b), intent(in), optional :: band - integer(i4b) :: i, j, k, ka + integer(i4b) :: i, j, k, ka, nmaps if(self%precomputed_amps) return + nmaps = data(band)%info%nmaps + if(nmaps > 3) nmaps = 3 + if (present(band)) then + nmaps = data(band)%info%nmaps + if(nmaps > 3) nmaps = 3 + if (self%F_null(band)) return - do i = 1, data(band)%info%nmaps + do i = 1, nmaps do j = 0, data(band)%tod%ndet call self%F_int(i,band,j)%p%update(pol=i) end do @@ -2918,7 +2924,9 @@ subroutine updatePtsrcFInt(self, band) do k = 1, numband if (self%F_null(k)) cycle ka = self%b2a(k) - do i = 1, data(k)%info%nmaps + nmaps = data(band)%info%nmaps + if(nmaps > 3) nmaps = 3 + do i = 1, nmaps do j = 0, data(k)%ndet call self%F_int(i,ka,j)%p%update(pol=i) end do diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index e706ed6cc..764137d74 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -738,7 +738,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr allocate(A(tod%ndet), b(tod%ndet)) A = 0.d0; b = 0.d0 else if (trim(mode) == 'deltaG') then - allocate(dipole_mod(tod%nscan_tot, tod%ndet)) + allocate(dipole_mod(tod%last_scan, tod%ndet)) dipole_mod = 0.d0 else write(*,*) 'Unsupported sampling mode!' @@ -1069,9 +1069,11 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) end do end if ! Bandpass proposals + if(tod%n_bp_prop > 1) then do i = 1, nout-tod%output_n_maps d_calib(tod%output_n_maps+i,:,j) = d_calib(1,:,j) + sd%s_bp(:,j) - sd%s_bp_prop(:,j,i+1) end do + end if end do diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index cee63e1f5..b216476cb 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -186,7 +186,7 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) if (present(smooth) ) smooth_ = smooth ndet = tod%ndet - nscan_tot = tod%nscan_tot + nscan_tot = tod%last_scan ! Collect all gain estimates on the root processor allocate(g(nscan_tot,ndet,2)) @@ -217,7 +217,7 @@ module subroutine sample_smooth_gain(tod, handle, dipole_mods, smooth) end do ! Perform poly-fit - allocate(xx(tod%nscan_tot), yy(tod%nscan_tot)) + allocate(xx(tod%last_scan), yy(tod%last_scan)) allocate(a(0:16)) do j = 1, tod%ndet xx = 0.d0 @@ -1283,7 +1283,7 @@ module subroutine sample_gain_psd(tod, handle) integer*8 :: plan_fwd, plan_back ndet = tod%ndet - nscan_tot = tod%nscan_tot + nscan_tot = tod%last_scan ! Collect gains on all processors allocate(g(nscan_tot,ndet)) g = 0.d0 diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index ce8f91b81..e669a2e5c 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -658,7 +658,7 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d type(comm_scandata) :: sd character(len=4) :: ctext, myid_text character(len=6) :: samptext, scantext - character(len=512) :: prefix, postfix, prefix4D, filename, Sfilename + character(len=512) :: prefix, postfix, prefix4D, filename, Sfilename, prefix_nplus2 character(len=512), allocatable, dimension(:) :: slist real(sp), allocatable, dimension(:) :: procmask, procmask2, sigma0 real(sp), allocatable, dimension(:,:,:) :: d_calib @@ -672,20 +672,23 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d call timer%start(TOD_ALLOC, self%band) ! Toggle optional operations - sample_rel_bandpass = .not. self%sample_abs_bp .or. (size(delta,3) > 1 .and. mod(iter,2) == 0) ! Sample relative bandpasses if more than one proposal sky - sample_abs_bandpass = self%sample_abs_bp .and. (size(delta,3) > 1 .and. mod(iter,2) == 1) ! sample absolute bandpasses + sample_rel_bandpass = .false. !.not. self%sample_abs_bp .or. (size(delta,3) > 1 .and. mod(iter,2) == 0) ! Sample relative bandpasses if more than one proposal sky + sample_abs_bandpass = .false. ! self%sample_abs_bp .and. (size(delta,3) > 1 .and. mod(iter,2) == 1) ! sample absolute bandpasses sample_polang = .false. select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,1) == 0 ! only output scanlist every 10th iteration - sample_rel_bandpass = sample_rel_bandpass .and. .not. self%enable_tod_simulations - sample_abs_bandpass = sample_abs_bandpass .and. .not. self%enable_tod_simulations + sample_rel_bandpass = .false. !sample_rel_bandpass .and. .not. self%enable_tod_simulations + sample_abs_bandpass = .false.!sample_abs_bandpass .and. .not. self%enable_tod_simulations ! Initialize local variables ndelta = size(delta,3) self%n_bp_prop = ndelta-1 nside = map_out%info%nside + nmaps = map_out%info%nmaps + if(nmaps > 3) nmaps = 3 + npix = 12*nside**2 self%output_n_maps = 3 if (self%output_aux_maps > 0) then @@ -696,6 +699,7 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d call int2string(iter, samptext) call int2string(self%myid, myid_text) prefix = trim(chaindir) // '/tod_' // trim(self%freq) // '_' + prefix_nplus2 = trim(chaindir) // '/tod_' postfix = '_c' // ctext // '_k' // samptext // '.fits' ! Distribute maps @@ -764,15 +768,19 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d ! end if ! Sample gain components in separate TOD loops; marginal with respect to n_corr - if (.not. self%enable_tod_simulations) then - call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain1") - call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain2") - call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain3") + !if (.not. self%enable_tod_simulations) then + ! call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain1") + ! call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain2") + ! call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain3") !call sample_gain_psd(self, handle) - end if + !end if ! Prepare intermediate data structures - call binmap%init(self, .true., sample_rel_bandpass) + if(self%map_type == 'nplus2') then + call binmap%init(self, .true., .false., nplus2=.true.) + else if (self%map_type == 'binned') then + call binmap%init(self, .true., sample_rel_bandpass) + end if if (sample_abs_bandpass .or. sample_rel_bandpass) then call timer%start(TOD_ALLOC, self%band) allocate(chisq_S(self%ndet,size(delta,3))) @@ -812,7 +820,7 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d !sd%s_bp = 0. ! Compute noise spectrum parameters - call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + !call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) ! Compute chisquare do j = 1, sd%ndet @@ -888,10 +896,21 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d if (sample_rel_bandpass) then Sfilename = trim(prefix) // 'Smap'// trim(postfix) call finalize_binned_map(self, binmap, rms_out, 1.d6, chisq_S=chisq_S, mask=procmask2) + map_out%map = binmap%outmaps(1)%p%map + else if(self%map_type == 'nplus2') then + call finalize_binned_map_nplus2(self, binmap, rms_out, 1.d6) + !Q+U maps + map_out%map(:,2:3) = binmap%outmaps(1)%p%map(:,2:3) + do i = 1, self%ndet + ! I maps for each detector + map_out%map(:,i+3) = binmap%outmaps(i)%p%map(:,1) + end do + ! mean I map + map_out%map(:,1) = 0.d0 else call finalize_binned_map(self, binmap, rms_out, 1.d6) + map_out%map = binmap%outmaps(1)%p%map end if - map_out%map = binmap%outmaps(1)%p%map ! Sample bandpass parameters if (sample_rel_bandpass .or. sample_abs_bandpass) then @@ -899,17 +918,37 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d self%bp_delta = delta(:,:,1) end if - call timer%start(TOD_WRITE) - ! Output maps to disk - call map_out%writeFITS(trim(prefix)//'map'//trim(postfix)) - call rms_out%writeFITS(trim(prefix)//'rms'//trim(postfix)) - if (self%output_n_maps > 1) call binmap%outmaps(2)%p%writeFITS(trim(prefix)//'res'//trim(postfix)) - if (self%output_n_maps > 2) call binmap%outmaps(3)%p%writeFITS(trim(prefix)//'ncorr'//trim(postfix)) - if (self%output_n_maps > 3) call binmap%outmaps(4)%p%writeFITS(trim(prefix)//'bpcorr'//trim(postfix)) - if (self%output_n_maps > 4) call binmap%outmaps(5)%p%writeFITS(trim(prefix)//'orb'//trim(postfix)) - if (self%output_n_maps > 5) call binmap%outmaps(6)%p%writeFITS(trim(prefix)//'sl'//trim(postfix)) - if (self%output_n_maps > 6) call binmap%outmaps(7)%p%writeFITS(trim(prefix)//'zodi'//trim(postfix)) - if (self%output_n_maps > 7) call binmap%outmaps(8)%p%writeFITS(trim(prefix)//'1hz'//trim(postfix)) + call timer%start(TOD_WRITE) + if(self%map_type == 'binned') then + ! Output maps to disk + call map_out%writeFITS(trim(prefix)//'map'//trim(postfix)) + call rms_out%writeFITS(trim(prefix)//'rms'//trim(postfix)) + if (self%output_n_maps > 1) call binmap%outmaps(2)%p%writeFITS(trim(prefix)//'res'//trim(postfix)) + if (self%output_n_maps > 2) call binmap%outmaps(3)%p%writeFITS(trim(prefix)//'ncorr'//trim(postfix)) + if (self%output_n_maps > 3) call binmap%outmaps(4)%p%writeFITS(trim(prefix)//'bpcorr'//trim(postfix)) + if (self%output_n_maps > 4) call binmap%outmaps(5)%p%writeFITS(trim(prefix)//'orb'//trim(postfix)) + if (self%output_n_maps > 5) call binmap%outmaps(6)%p%writeFITS(trim(prefix)//'sl'//trim(postfix)) + if (self%output_n_maps > 6) call binmap%outmaps(7)%p%writeFITS(trim(prefix)//'zodi'//trim(postfix)) + if (self%output_n_maps > 7) call binmap%outmaps(8)%p%writeFITS(trim(prefix)//'1hz'//trim(postfix)) + else if(self%map_type == 'nplus2') then + do i = 1, self%ndet + call binmap%outmaps(i)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_map"//trim(postfix)) + ! copy rms map for each detector into outmaps(0) + binmap%outmaps(i)%p%map(:,1) = rms_out%map(:,i) + binmap%outmaps(i)%p%map(:,2:3) = rms_out%map(:,self%ndet+1:self%ndet+2) + call binmap%outmaps(i)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_rms"//trim(postfix)) + !call rms_out%writeFITS + if(self%output_n_maps > 1) call binmap%outmaps(i+self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_res"//trim(postfix)) + if(self%output_n_maps > 2) call binmap%outmaps(i+2*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_ncorr"//trim(postfix)) + if(self%output_n_maps > 3) call binmap%outmaps(i+3*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_bpcorr"//trim(postfix)) + if(self%output_n_maps > 4) call binmap%outmaps(i+4*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_orb"//trim(postfix)) + if(self%output_n_maps > 5) call binmap%outmaps(i+5*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_sl"//trim(postfix)) + if(self%output_n_maps > 6) call binmap%outmaps(i+6*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_zodi"//trim(postfix)) + if(self%output_n_maps > 7) call binmap%outmaps(i+7*self%ndet)%p%writeFITS(trim(prefix_nplus2) // trim(self%label(i)) //"_1hz"//trim(postfix)) + end do + else + if (self%myid == 0) write(*,*) "Unknown map_type in LFI output:", self%map_type + end if call timer%stop(TOD_WRITE) ! Clean up @@ -1544,13 +1583,13 @@ module subroutine dumpToHDF_lfi(self, chainfile, path) real(dp), allocatable, dimension(:,:,:) :: R, R_tot real(dp), allocatable, dimension(:,:,:,:) :: ref_filter, adc_corr - allocate(amp(self%nscan_tot,self%ndet), amp_tot(self%nscan_tot,self%ndet)) + allocate(amp(self%last_scan,self%ndet), amp_tot(self%last_scan,self%ndet)) amp = 0.d0 amp(self%scanid,:) = self%spike_amplitude call mpi_reduce(amp, amp_tot, size(amp), MPI_DOUBLE_PRECISION, MPI_SUM, 0, self%info%comm, ierr) if (trim(self%level) == 'L1') then - allocate(R(self%nscan_tot,self%ndet,size(self%R,3)),R_tot(self%nscan_tot,self%ndet,size(self%R,3))) + allocate(R(self%last_scan,self%ndet,size(self%R,3)),R_tot(self%last_scan,self%ndet,size(self%R,3))) R = 0.d0 R(self%scanid,:,:) = self%R call mpi_reduce(R, R_tot, size(R), MPI_DOUBLE_PRECISION, MPI_SUM, 0, self%info%comm, ierr) diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index d1e1dfd52..a5de5d6d5 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -69,13 +69,13 @@ subroutine init_binmap(self, tod, shared, solve_S, nplus2) self%nout = tod%output_n_maps + tod%n_bp_prop !write(*,*) 'hei!', size(tod%bp_delta,2) else if(self%solve_nplus2) then - if(tod%nmaps /= 3) then + if(tod%nmaps /= tod%ndet + 3) then write(*,*) "Cannot use n+2 mapmaking for nmaps=", tod%nmaps stop end if self%ncol = tod%nmaps + tod%ndet - 1 self%n_A = 3*tod%ndet + 3 - self%nout = tod%output_n_maps + tod%ndet-1 + self%nout = tod%output_n_maps *(tod%ndet+2) else self%ncol = tod%nmaps self%n_A = tod%nmaps*(tod%nmaps+1)/2 @@ -203,7 +203,7 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) do det = 1, size(pix,2) ! loop over all the detectors if (.not. tod%scans(scan)%d(det)%accept) cycle off = tod%output_n_maps + 4*(det-1) - if(binmap%solve_nplus2) off = tod%output_n_maps *(det-1) + if(binmap%solve_nplus2) off = 6 + 3*(det-2) inv_sigmasq = (tod%scans(scan)%d(det)%gain/tod%scans(scan)%d(det)%N_psd%sigma0)**2 do t = 1, size(pix,1) @@ -249,7 +249,7 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) do i = 1, nout binmap%b_map(i,det+3,pix_) = binmap%b_map(i,det+3,pix_) + data(i,t,det) * inv_sigmasq end do - else if(binmap%solve_nplus2) then + else if(binmap%solve_nplus2 .and. det > 1) then binmap%A_map(off+1,pix_) = binmap%A_map(off+1,pix_) + 1.d0 *inv_sigmasq binmap%A_map(off+2,pix_) = binmap%A_map(off+2,pix_) + tod%cos2psi(psi_) * inv_sigmasq binmap%A_map(off+3,pix_) = binmap%A_map(off+3,pix_) + tod%sin2psi(psi_) * inv_sigmasq @@ -638,7 +638,7 @@ subroutine finalize_binned_map_unpol(tod, binmap, rms, scale, chisq_S, mask, cor end subroutine finalize_binned_map_unpol - subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, correct_transfer) + subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, mask, correct_transfer) ! ! Routine to finalize the binned maps ! Makes one T map per detector but joint Q+U maps @@ -649,7 +649,6 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co ! binmap: ! rms: ! scale - ! chisq_S ! mask ! implicit none @@ -657,16 +656,15 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co type(comm_binmap), intent(inout) :: binmap class(comm_map), intent(inout) :: rms real(dp), intent(in) :: scale - real(dp), dimension(1:,1:), intent(out), optional :: chisq_S real(sp), dimension(0:), intent(in), optional :: mask logical(lgt), intent(in), optional :: correct_transfer logical(lgt) :: correct_transfer_ - integer(i4b) :: i, j, k, nmaps, ierr, ndet, ncol, n_A, off, ndelta + integer(i4b) :: i, j, k, p, nmaps, ierr, ndet, ncol, n_A, off, ndelta integer(i4b) :: det, nout, np0, comm, myid, nprocs real(dp), allocatable, dimension(:,:) :: A_inv, As_inv real(dp), allocatable, dimension(:,:,:) :: b_tot, bs_tot - real(dp), allocatable, dimension(:) :: W, eta + real(dp), allocatable, dimension(:) :: W, eta, b_copy real(dp), allocatable, dimension(:,:) :: A_tot correct_transfer_ = .false. @@ -681,7 +679,8 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co ndet = tod%ndet n_A = size(binmap%sA_map%a,dim=1) ncol = size(binmap%sb_map%a,dim=2) - ndelta = 0; if (present(chisq_S)) ndelta = size(chisq_S,dim=2) + + allocate(b_copy(ndet+2)) ! Collect contributions from all nodes call mpi_win_fence(0, binmap%sA_map%win, ierr) @@ -708,30 +707,27 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co ! Solve for local map and rms allocate (A_inv(ndet+2, ndet+2), As_inv(ncol, ncol)) - if (present(chisq_S)) chisq_S = 0.d0 do i = 0, np0 - 1 if (all(b_tot(1, :, i) == 0.d0)) then - if (.not. present(chisq_S)) then rms%map(i, :) = 0.d0 do k = 1, nout binmap%outmaps(k)%p%map(i, :) = 0.d0 end do - end if cycle end if A_inv = 0.d0 ! First detector T - A_inv(1, 1) = A_tot(1, i) + A_inv(1, 1) = A_tot(1,i) A_inv(1, ndet+1) = A_tot(2,i) A_inv(1, ndet+2) = A_tot(4,i) A_inv(ndet+1, 1) = A_tot(2,i) A_inv(ndet+2, 1) = A_tot(4,i) ! Other detectors T do j=2, ndet - A_inv(j,j) = A_tot(7+3*(ndet-1), i) - A_inv(j,ndet+1) = A_tot(8+3*(ndet-1), i) - A_inv(j,ndet+2) = A_tot(9+3*(ndet-1), i) + A_inv(j,j) = A_tot(7+3*(ndet-2), i) + A_inv(j,ndet+1) = A_tot(8+3*(ndet-2), i) + A_inv(j,ndet+2) = A_tot(9+3*(ndet-2), i) A_inv(ndet+1,j) = A_inv(j,ndet+1) A_inv(ndet+2,j) = A_inv(j,ndet+2) end do @@ -744,43 +740,45 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, chisq_S, mask, co ! Can I return the condition number? call invert_singular_matrix(A_inv, 1d-12) - do k = 1, tod%ndet+2 - b_tot(k, 1:nmaps, i) = matmul(A_inv, b_tot(k, 1:nmaps, i)) + do k = 1, tod%output_n_maps + b_copy(1) = b_tot(k, 1, i) + b_copy(2:ndet) = b_tot(k, 4:ndet+2, i) + b_copy(ndet+1) = b_tot(k, 2, i) + b_copy(ndet+2) = b_tot(k, 3, i) + b_tot(k, 1:ndet+2, i) = matmul(A_inv, b_copy) end do ! Store map in correct units - do j = 1, nmaps + do p = 1, tod%ndet do k = 1, tod%output_n_maps - binmap%outmaps(k)%p%map(i, j) = b_tot(k, j, i)*scale + ! T component + binmap%outmaps((k-1) * tod%ndet + p)%p%map(i, 1) = b_tot(k, p, i)*scale + ! Joint Q/U component copied into each map + binmap%outmaps((k-1) * tod%ndet + p)%p%map(i, 2) = b_tot(k, tod%ndet+1, i) + binmap%outmaps((k-1) * tod%ndet + p)%p%map(i, 3) = b_tot(k, tod%ndet+2, i) + end do end do ! Store N in correct units - if (rms%info%nmaps == 3) then + if (rms%info%nmaps == tod%ndet + 3) then ! Diagonal matrix; store RMS - do j = 1, nmaps - rms%map(i,j) = sqrt(A_inv(j, j))*scale + do j = 2, rms%info%nmaps + rms%map(i,j) = sqrt(A_inv(j-1, j-1))*scale end do - else if (rms%info%nmaps == 4) then - ! Block-diagonal T + QU; store N - rms%map(i,1) = A_inv(1,1)*scale**2 - rms%map(i,2) = A_inv(2,2)*scale**2 - rms%map(i,3) = A_inv(3,3)*scale**2 - rms%map(i,4) = A_inv(2,3)*scale**2 - end if - end do - - if (present(chisq_S)) then - if (myid == 0) then - call mpi_reduce(mpi_in_place, chisq_S, size(chisq_S), & - & MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) else - call mpi_reduce(chisq_S, chisq_S, size(chisq_S), & - & MPI_DOUBLE_PRECISION, MPI_SUM, 0, comm, ierr) + write(*,*) "Wrong RMS map size in finalize_binned_map_nplus2" end if - end if + !else if (rms%info%nmaps == 4) then + ! Block-diagonal T + QU; store N + ! rms%map(i,1) = A_inv(1,1)*scale**2 + ! rms%map(i,2) = A_inv(2,2)*scale**2 + ! rms%map(i,3) = A_inv(3,3)*scale**2 + ! rms%map(i,4) = A_inv(2,3)*scale**2 + !end if + end do - deallocate (A_inv, As_inv, A_tot, b_tot, bs_tot, W, eta) + deallocate (A_inv, As_inv, A_tot, b_tot, bs_tot, W, eta, b_copy) end subroutine finalize_binned_map_nplus2 diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index c310744cd..9a579f3ad 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -172,6 +172,7 @@ module comm_tod_mod integer(i4b) :: output_n_maps ! Output n_maps character(len=512) :: init_from_HDF ! Read from HDF file character(len=512) :: datadir + character(len=512) :: map_type ! type of mapmaker to use, {nplus2, binned, differential} integer(i4b) :: output_4D_map ! Output 4D maps integer(i4b) :: output_aux_maps ! Output auxiliary maps integer(i4b) :: halfring_split ! Type of halfring split 0=None, 1=HR1, 2=HR2 @@ -439,6 +440,7 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%flag0 = cpar%ds_tod_flag(id_abs) self%abscal_comps = cpar%ds_tod_abscal(id_abs) self%nscan_tot = cpar%ds_tod_tot_numscan(id_abs) + self%map_type = cpar%ds_tod_map_type(id_abs) self%output_4D_map = cpar%output_4D_map_nth_iter self%output_aux_maps = cpar%output_aux_maps self%output_zodi_comps = cpar%zs_output_comps @@ -456,7 +458,7 @@ subroutine tod_constructor(self, cpar, id, id_abs, info, tod_type) self%sol_elong_range = [0., 180.] self%sample_mono = .false. self%nside_pixhist = -1 - + if (cpar%include_tod_zodi) then self%subtract_zodi = cpar%ds_tod_subtract_zodi(self%band) self%zodi_n_comps = cpar%zs_ncomps @@ -3666,7 +3668,7 @@ subroutine distribute_sky_maps(tod, map_in, scale, map_out, map_full) end if end do do k = 1, tod%nobs - do l = 1, tod%nmaps + do l = 1, nmaps map_out(l,k,0,j) = sum(map_out(l,k,1:tod%ndet,j))/tod%ndet end do end do diff --git a/commander3/src/sharp.f90 b/commander3/src/sharp.f90 index 58181aff7..6c01ee374 100644 --- a/commander3/src/sharp.f90 +++ b/commander3/src/sharp.f90 @@ -220,7 +220,7 @@ subroutine sharp_execute_d(type, spin, nmaps, alm, alm_info, map, geom_info, & else ntrans = nmaps / 2 end if - if (ntrans/=1) print *, "ERROR: ntrans /= 1" + !if (ntrans/=1) print *, "ERROR: ntrans /= 1" ! Set up pointer table to access maps alm_ptr(:) = c_null_ptr From 36d161d2708dd30cefc748f8596f6036e9dd7652 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 14 Apr 2025 11:37:20 +0200 Subject: [PATCH 145/171] Zodi mod clean-up --- commander3/config/config.ita_internal | 4 +- commander3/src/comm_tod_driver_mod.f90 | 58 +--- commander3/src/comm_tod_mod.f90 | 44 +-- commander3/src/comm_zodi_mod.f90 | 424 ++++++++++++------------- commander3/src/comm_zodi_samp_mod.f90 | 87 ++--- commander3/src/commander.f90 | 9 +- 6 files changed, 243 insertions(+), 383 deletions(-) diff --git a/commander3/config/config.ita_internal b/commander3/config/config.ita_internal index eb9ef14dd..0a76cd9d7 100644 --- a/commander3/config/config.ita_internal +++ b/commander3/config/config.ita_internal @@ -49,10 +49,10 @@ export MPCC := mpiicc # =========== Compiler Optimizations ============= #main -#export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 +export F90FLAGS := -fpe0 -mavx2 -fpp -g -O2 -traceback -assume byterecl -qopenmp -diag-disable=10448 #debug -export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. +#export F90FLAGS := -O0 -g -C -traceback -assume byterecl -heap-arrays 16384 -qopenmp -fpe0 -check noarg_temp_created -ftrapuv -diag-disable=10448 -check uninit -debug extended -diag-disable=5268 -I. #export F90FLAGS := -fpe0 -march=native -C -g -check noarg_temp_created -traceback -assume byterecl -heap-arrays 16384 -qopenmp -parallel -lmkl -ftrapuv diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index 3ad8ae87b..4b89ffaa8 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -107,10 +107,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, end if if (tod%subtract_zodi) then - call tod%clear_zodi_cache() allocate(sd%s_zodi(sd%ntod, sd%ndet)) - allocate(sd%s_zodi_scat(sd%ntod, tod%zodi_n_comps, sd%ndet)) - allocate(sd%s_zodi_therm(sd%ntod, tod%zodi_n_comps, sd%ndet)) if (tod%sample_zodi) allocate(sd%mask_zodi(sd%ntod, sd%ndet)) end if !call update_status(status, "todinit_alloc") @@ -194,22 +191,7 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, & procmask2, scan, sd%s_sky_prop(:,:,j), sd%mask2) end do end if - - ! ! Project zodi sampling mask to timestream - ! if (tod%subtract_zodi .and. tod%sample_zodi) then - ! if (.not. present(procmask_zodi)) stop "zodi processing mask is not present in init_scan_data_singlehorn but sample zodi is true" - ! do j = 1, self%ndet - ! do i = 1, tod%scans(scan)%ntod - ! self%mask_zodi(i, j) = procmask_zodi(self%pix(i, j, 1)) - ! if (iand(self%flag(i, j), tod%flag0) .ne. 0) self%mask_zodi(i, j) = 0. - ! end do - ! end do - ! end if call timer%stop(TOD_PROJECT, tod%band) - !call update_status(status, "todinit_bp") - !if (.true. .or. tod%myid == 78) write(*,*) 'c71', tod%myid, tod%correct_sl - !if (.true. .or. tod%myid == 78) write(*,*) 'c72', tod%myid, tod%ndet - !if (.true. .or. tod%myid == 78) write(*,*) 'c73', tod%myid, tod%slconv(1)%p%psires ! Perform sanity tests do j = 1, sd%ndet @@ -236,25 +218,9 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, sd%s_zodi = 0. else call timer%start(TOD_ZODI, tod%band) - if (tod%myid == 0) write(*, fmt='(a24, i3, a1)') ' --> Simulating zodi: ', nint(real(scan-1, sp)/real(tod%nscan,sp) * 100, i4b), '%' + if (tod%myid == 0) write(*, fmt='(a24, i3, a1)') ' --> Computing zodi: ', nint(real(scan-1, sp)/real(tod%nscan,sp) * 100, i4b), '%' do j = 1, sd%ndet -!!$ call get_zodi_emission(& -!!$ & tod=tod, & -!!$ & pix=self%pix(:, j, 1), & -!!$ & scan=scan, & -!!$ & det=j, & -!!$ & s_zodi_scat=self%s_zodi_scat(:, :, j), & -!!$ & s_zodi_therm=self%s_zodi_therm(:, :, j), & -!!$ & model=zodi_model & -!!$ &) -!!$ call get_s_zodi(& -!!$ & s_therm=self%s_zodi_therm(:, :, j), & -!!$ & s_scat=self%s_zodi_scat(:, :, j), & -!!$ & s_zodi=self%s_zodi(:, j), & -!!$ & emissivity=tod%zodi_emissivity, & -!!$ & albedo=tod%zodi_albedo & -!!$ &) - call get_s_tot_zodi(zodi_model, tod, j, scan, sd%s_zodi(:, j), pix_dynamic=sd%pix(:,j,:), s_scat=sd%s_zodi_scat(:,:,j), s_therm=sd%s_zodi_therm(:,:,j)) + call get_s_tot_zodi(zodi_model, tod, j, scan, sd%s_zodi(:, j), pix_dynamic=sd%pix(:,j,:)) !!$ if (tod%myid == 0) then !!$ open(58,file='zodi.dat') !!$ do k = 1, size(self%s_zodi(:,j)) @@ -268,7 +234,6 @@ subroutine init_scan_data_singlehorn(sd, tod, scan, map_sky, map_gain, procmask, call timer%stop(TOD_ZODI, tod%band) end if end if - !if (.true. .or. tod%myid == 78) write(*,*) 'c10', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires ! Construct sidelobe template !if (.true. .or. tod%myid == 78) write(*,*) 'd', tod%myid, tod%correct_sl, tod%ndet, tod%slconv(1)%p%psires @@ -602,8 +567,6 @@ subroutine dealloc_scan_data(sd) if (allocated(sd%s_mono)) deallocate(sd%s_mono) if (allocated(sd%mask2)) deallocate(sd%mask2) if (allocated(sd%s_zodi)) deallocate(sd%s_zodi) - if (allocated(sd%s_zodi_scat)) deallocate(sd%s_zodi_scat) - if (allocated(sd%s_zodi_therm)) deallocate(sd%s_zodi_therm) if (allocated(sd%mask_zodi)) deallocate(sd%mask_zodi) if (allocated(sd%s_totA)) deallocate(sd%s_totA) if (allocated(sd%s_totB)) deallocate(sd%s_totB) @@ -1017,11 +980,11 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) ! d_calib(8,:,:) - instrument correction ! d_calib(9 - 9 + n_zodi_comps,:,:) - zodiacal light components implicit none - class(comm_tod), intent(in) :: tod - integer(i4b), intent(in) :: scan - type(comm_scandata), intent(in) :: sd - real(sp), dimension(:,:,:), intent(out) :: d_calib - real(sp), dimension(:,:), intent(in), optional :: jump_template + class(comm_tod), intent(inout) :: tod + integer(i4b), intent(in) :: scan + type(comm_scandata), intent(in) :: sd + real(sp), dimension(:,:,:), intent(out) :: d_calib + real(sp), dimension(:,:), intent(in), optional :: jump_template integer(i4b) :: i, j, k, nout real(dp) :: inv_gain ! write(*, *) "s_bp:", sd%s_sky(:,1) @@ -1053,10 +1016,9 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) if (tod%output_n_maps > 5) d_calib(6,:,j) = sd%s_sl(:,j) if ((tod%output_n_maps > 6) .and. allocated(sd%s_zodi)) d_calib(7,:,j) = sd%s_zodi(:,j) ! zodi if ((tod%output_n_maps > 7) .and. allocated(sd%s_inst)) d_calib(8,:,j) = (sd%s_inst(:,j) - sum(real(sd%s_inst(:,j),dp)/sd%ntod)) * inv_gain ! instrument specific - if ((tod%output_n_maps > 8) .and. allocated(sd%s_zodi_scat) .and. allocated(sd%s_zodi_therm)) then - do i = 1, size(sd%s_zodi_therm, dim=2) - !write(*,*) 'b',j,i, tod%scanid(scan), any(sd%s_zodi_scat(:,i:i,j)/=sd%s_zodi_scat(:,i:i,j)), any(sd%s_zodi_therm(:,i:i,j)/=sd%s_zodi_therm(:,i:i,j)) - call get_s_zodi(tod%id, sd%s_zodi_therm(:, i:i, j), sd%s_zodi_scat(:, i:i, j), d_calib(8 + i, :, j), comp_id=i) + if (tod%output_n_maps > 8) then + do i = 1, zodi_model%n_comps + call get_s_tot_zodi(zodi_model, tod, j, scan, d_calib(8+i,:,j), pix_dynamic=sd%pix(:,j,:), exclude_static='all', comp=i) end do end if ! Bandpass proposals diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 0c169c69e..d96d40b4a 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -32,7 +32,7 @@ module comm_tod_mod implicit none private - public comm_tod, comm_scan, comm_scandata, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer, distribute_sky_maps + public comm_tod, comm_scan, comm_detscan, comm_scandata, initialize_tod_mod, fill_masked_region, fill_all_masked, tod_pointer, distribute_sky_maps ! Structure for individual detectors type :: comm_detscan @@ -62,7 +62,7 @@ module comm_tod_mod real(sp), allocatable, dimension(:,:) :: earth_elon ! Earth elongation, for sidelobe mapping and masking ! Zodi sampling structures (downsampled and precomputed quantities. only allocated if zodi sampling is true) - logical(lgt), allocatable, dimension(:,:) :: zodi_glitch_mask + logical(lgt), allocatable, dimension(:,:) :: zodi_sampgroup_mask integer(i4b), allocatable, dimension(:) :: downsamp_pix_full real(sp), allocatable, dimension(:) :: downsamp_tod_full real(sp), allocatable, dimension(:) :: downsamp_sky_full @@ -271,10 +271,8 @@ module comm_tod_mod ! Zodi parameters and spline objects integer(i4b) :: zodi_n_comps ! real(sp), allocatable, dimension(:, :, :) :: zodi_scat_cache, zodi_therm_cache ! Cached s_zodi array for a given processor - real(sp), allocatable, dimension(:, :, :) :: zodi_scat_cache, zodi_therm_cache ! Cache for zodi - real(sp), allocatable, dimension(:, :, :) :: zodi_scat_cache_lowres, zodi_therm_cache_lowres ! Cache for lowresolution zodi (used for sampling) - real(dp) :: zodi_cache_time, zodi_init_cache_time! Time of cached zodi array !real(dp), allocatable, dimension(:) :: zodi_emissivity, zodi_albedo ! sampled parameters + integer(i4b) :: zodi_cache_nobs_lowres real(dp), allocatable, dimension(:, :) :: zodi_spl_phase_coeffs real(dp), allocatable, dimension(:) :: zodi_spl_solar_irradiance, zodi_phase_func_normalization type(spline_type), allocatable :: zodi_b_nu_spl_obj(:) @@ -315,7 +313,6 @@ module comm_tod_mod procedure :: apply_map_precond procedure :: collect_v_sun procedure :: precompute_zodi_lookups - procedure :: clear_zodi_cache procedure :: create_dynamic_mask procedure :: report_dynamic_mask_stats procedure :: get_s_static @@ -357,8 +354,6 @@ end subroutine process_tod real(sp), allocatable, dimension(:,:) :: s_bp ! Bandpass correction real(sp), allocatable, dimension(:,:,:) :: s_bp_prop ! Bandpass correction proposal real(sp), allocatable, dimension(:,:) :: s_zodi ! Zodiacal emission - real(sp), allocatable, dimension(:,:,:) :: s_zodi_scat ! Scattered sunlight contribution to zodi - real(sp), allocatable, dimension(:,:,:) :: s_zodi_therm ! Thermal zodiacal emission real(sp), allocatable, dimension(:,:) :: s_inst ! Instrument-specific correction template real(sp), allocatable, dimension(:,:) :: s_tot ! Total signal real(sp), allocatable, dimension(:,:) :: s_gain ! Absolute calibrator @@ -3180,18 +3175,11 @@ subroutine precompute_zodi_lookups(self, cpar) call spline_simple(self%x_earth_spline(i), time, x_earth(i, :)) end do - self%zodi_init_cache_time = self%scans(1)%t0(1) - call self%clear_zodi_cache() - !allocate spectral quantities allocate(self%zodi_b_nu_spl_obj(self%ndet)) - ! allocate cache files and precompute ecliptic unit vectors + ! precompute ecliptic unit vectors call ecl_to_gal_rot_mat(rotation_matrix) - allocate(self%zodi_scat_cache(self%nobs, self%zodi_n_comps, self%ndet)) - allocate(self%zodi_therm_cache(self%nobs, self%zodi_n_comps, self%ndet)) - self%zodi_scat_cache = -1.d0 - self%zodi_therm_cache = -1.d0 allocate(self%ind2vec_ecl(3, self%nobs)) do i = 1, self%nobs self%ind2vec_ecl(:,i) = matmul(self%ind2vec(:,i), rotation_matrix) @@ -3200,7 +3188,7 @@ subroutine precompute_zodi_lookups(self, cpar) ! If zodi sampling is turned on we precompute lowres zodi lookups if (.not. cpar%sample_zodi) return ! Skip if zodi nside = tod nside - if (self%nside == zodi_nside) return + !if (self%nside == zodi_nside) return n_subpix = (self%nside / zodi_nside)**2 npix_lowres = 12*zodi_nside**2 @@ -3216,28 +3204,6 @@ subroutine precompute_zodi_lookups(self, cpar) end subroutine precompute_zodi_lookups - subroutine clear_zodi_cache(self, obs_time) - ! Clears the zodi tod cache used to look up already computed zodi values. - ! - ! This cache has an associate time of observation since the cache is only valid - ! if the time between the observations are small enough for the observer to not - ! have moved significantly. - class(comm_tod), intent(inout) :: self - real(dp), intent(in), optional :: obs_time - - self%zodi_scat_cache = -1.d0 - self%zodi_therm_cache = -1.d0 - if (present(obs_time)) then - self%zodi_cache_time = obs_time - else - self%zodi_cache_time = self%zodi_init_cache_time - end if - if (allocated(self%zodi_therm_cache_lowres)) then - self%zodi_scat_cache_lowres = -1.d0 - self%zodi_therm_cache_lowres = -1.d0 - end if - end subroutine clear_zodi_cache - ! Cut definitions: ! threshold(1) = Pixel histogram outliers; tod%pixhist must be allocated; any positive value enables this ! threshold(2) = Extreme outlier in white noise sigma; inside flagging mask; typically set to a high value diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index da57396ba..f76cf49ca 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -5,7 +5,7 @@ module comm_zodi_mod implicit none private - public initialize_zodi_mod, get_s_zodi, zodi_model, get_zodi_emission, update_zodi_splines, output_tod_params_to_hd5, read_tod_zodi_params, get_zodi_emissivity_albedo + public initialize_zodi_mod, zodi_model, get_zodi_emission, update_zodi_splines, output_tod_params_to_hd5, read_tod_zodi_params public get_s_tot_zodi, ZodiModel, zodi_model_to_ascii, ascii_to_zodi_model, print_zodi_model public band_monopole, band_update_monopole @@ -863,45 +863,45 @@ subroutine comp_from_chain(self, cpar, params, comp_idx) ! end subroutine model_from_chain - subroutine get_s_zodi(band, s_therm, s_scat, s_zodi, comp_id) - ! Evaluates the zodiacal signal (eq. 20 in ZodiPy paper [k98 model]) given - ! integrated thermal zodiacal emission and scattered zodiacal light. - ! - ! Parameters: - ! ----------- - ! s_scat : - ! Integrated contribution from scattered sunlight light. - ! s_therm : - ! Integrated contribution from thermal interplanetary dust emission. - ! s_zodi : - ! Zodiacal signal. - ! emissivity : - ! Emissivity of the zodiacal components. - ! albedo : - ! Albedo of the zodiacal components. - implicit none - integer(i4b), intent(in) :: band - real(sp), dimension(:, :), intent(in) :: s_scat, s_therm - real(sp), dimension(:), intent(out) :: s_zodi - integer(i4b), intent(in), optional :: comp_id - - integer(i4b) :: i, first - real(dp) :: al, em - - first = 1; if (present(comp_id)) first = comp_id - - s_zodi = 0. - do i = first, first+size(s_therm,2)-1 - al = zodi_model%comps(i)%c%albedo(band) - em = zodi_model%comps(i)%c%emissivity(band) - !write(*,*) i, em, al, any(s_scat(:,i)/=s_scat(:,i)), any(s_therm(:,i)/=s_therm(:,i)) - if (trim(zodi_model%phasefunc_type) == 'Wright') then - s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + em * s_therm(:,i-first+1)) - else - s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + (1. - al) * em * s_therm(:,i-first+1)) - end if - end do - end subroutine get_s_zodi +!!$ subroutine get_s_zodi(band, s_therm, s_scat, s_zodi, comp_id) +!!$ ! Evaluates the zodiacal signal (eq. 20 in ZodiPy paper [k98 model]) given +!!$ ! integrated thermal zodiacal emission and scattered zodiacal light. +!!$ ! +!!$ ! Parameters: +!!$ ! ----------- +!!$ ! s_scat : +!!$ ! Integrated contribution from scattered sunlight light. +!!$ ! s_therm : +!!$ ! Integrated contribution from thermal interplanetary dust emission. +!!$ ! s_zodi : +!!$ ! Zodiacal signal. +!!$ ! emissivity : +!!$ ! Emissivity of the zodiacal components. +!!$ ! albedo : +!!$ ! Albedo of the zodiacal components. +!!$ implicit none +!!$ integer(i4b), intent(in) :: band +!!$ real(sp), dimension(:, :), intent(in) :: s_scat, s_therm +!!$ real(sp), dimension(:), intent(out) :: s_zodi +!!$ integer(i4b), intent(in), optional :: comp_id +!!$ +!!$ integer(i4b) :: i, first +!!$ real(dp) :: al, em +!!$ +!!$ first = 1; if (present(comp_id)) first = comp_id +!!$ +!!$ s_zodi = 0. +!!$ do i = first, first+size(s_therm,2)-1 +!!$ al = zodi_model%comps(i)%c%albedo(band) +!!$ em = zodi_model%comps(i)%c%emissivity(band) +!!$ !write(*,*) i, em, al, any(s_scat(:,i)/=s_scat(:,i)), any(s_therm(:,i)/=s_therm(:,i)) +!!$ if (trim(zodi_model%phasefunc_type) == 'Wright') then +!!$ s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + em * s_therm(:,i-first+1)) +!!$ else +!!$ s_zodi = s_zodi + ((s_scat(:,i-first+1) * al) + (1. - al) * em * s_therm(:,i-first+1)) +!!$ end if +!!$ end do +!!$ end subroutine get_s_zodi function get_par_ind(self, comp, comp_str, param, em_band, al_band, em_string, al_string, mono_band, mono_string) @@ -1247,7 +1247,7 @@ end subroutine samp_group2stat - subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, model, use_lowres_pointing, comp) + subroutine get_zodi_emission(tod, pix, scan, det, model, s_zodi, use_lowres_pointing, comp) implicit none ! Returns the predicted zodiacal emission for a scan (chunk of time-ordered data). ! @@ -1279,93 +1279,84 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod ! s_zodi_therm : real(sp), dimension(ntod, ncomps, ndet) ! Contribution from thermal interplanetary dust emission. ! - class(comm_tod), intent(inout) :: tod - integer(i4b), intent(in) :: pix(:), scan, det - real(sp), dimension(:, :), intent(inout) :: s_zodi_scat, s_zodi_therm - type(ZodiModel), intent(in) :: model - logical(lgt), intent(in), optional :: use_lowres_pointing - integer(i4b), intent(in), optional :: comp - - integer(i4b) :: i, j, k, l, pix_at_zodi_nside, lookup_idx, n_tod, ierr, cache_hits + class(comm_tod), intent(inout) :: tod + integer(i4b), dimension(:), intent(in) :: pix + integer(i4b), intent(in) :: scan, det + type(ZodiModel), intent(in) :: model + real(sp), dimension(:), intent(out) :: s_zodi + logical(lgt), intent(in), optional :: use_lowres_pointing + integer(i4b), intent(in), optional :: comp + + integer(i4b) :: i, j, k, l, pix_at_zodi_nside, lookup_idx, n_tod, ierr logical(lgt) :: scattering, thermal, use_lowres - real(dp) :: earth_lon, R_obs, R_min, R_max, dt_tod, obs_time, lat, lon + real(dp) :: earth_lon, R_obs, R_min, R_max, dt_tod, obs_time, lat, lon, s_tot, s_scat, s_therm, al, em real(dp) :: unit_vector(3), obs_pos(3), earth_pos(3) - real(dp), allocatable, dimension(:) :: b_nu - !real(dp), dimension(gauss_degree) :: R_LOS, T_LOS, density_LOS, solar_flux_LOS, scattering_angle, phase_function, b_nu_LOS - - s_zodi_scat = 0. - s_zodi_therm = 0. - n_tod = size(pix, dim=1) - - dt_tod = (1./tod%samprate)*SECOND_TO_DAY ! dt between two samples in units of days (assumes equispaced tods) - obs_pos = tod%scans(scan)%x0_obs - earth_pos = tod%scans(scan)%x0_earth - R_obs = norm2(obs_pos) - obs_time = tod%scans(scan)%t0(1) - earth_lon = atan(earth_pos(2), earth_pos(1)) + real(dp), allocatable, dimension(:) :: b_nu + integer(i4b) :: cache_hits + real(sp), allocatable, dimension(:,:) :: cache + real(dp) :: cache_time, init_cache_time + + use_lowres = .false.; if (present(use_lowres_pointing)) use_lowres = use_lowres_pointing + n_tod = size(pix) + dt_tod = (1./tod%samprate)*SECOND_TO_DAY ! dt between two samples in units of days (assumes equispaced tods) + obs_pos = tod%scans(scan)%x0_obs + earth_pos = tod%scans(scan)%x0_earth + R_obs = norm2(obs_pos) + obs_time = tod%scans(scan)%t0(1) + earth_lon = atan(earth_pos(2), earth_pos(1)) scattering = tod%central_freq >= model%nu_min_scatter thermal = tod%central_freq <= model%nu_max_thermal - ! select the correct cache - if (present(use_lowres_pointing)) then - if (tod%nside == zodi_nside) then - use_lowres = .false. - else - if (.not. allocated(tod%zodi_therm_cache_lowres)) stop "zodi cache not allocated. `use_lowres_pointing` should only be true when sampling zodi." - if (.not. allocated(tod%scans(scan)%downsamp_obs_time_full)) then - print *, tod%zodiband, scan, "lowres obs_time not allocated" - stop - end if - use_lowres = .true. - end if + ! Initialize cache + if (use_lowres) then + allocate(cache(tod%zodi_cache_nobs_lowres, tod%ndet)) else - use_lowres = .false. + allocate(cache(tod%nobs, tod%ndet)) end if - + cache_time = tod%scans(1)%t0(1) + cache = -1 + cache_hits = 0 !!$ open(58,file="zodi.dat",recl=1024) do i = 1, n_tod ! Reset cache if time between last cache update and current time is larger than `delta_t_reset`. ! NOTE: this cache is only effective if the scans a core handles are in chronological order. if (use_lowres) then - obs_time = tod%scans(scan)%downsamp_obs_time_full(i) + obs_time = tod%scans(scan)%d(det)%downsamp_obs_time_full(i) else obs_time = obs_time + dt_tod ! assumes a time continuous TOD end if - if ((obs_time - tod%zodi_cache_time) >= delta_t_reset) then + + ! Reset cache + if ((obs_time - cache_time) >= delta_t_reset) then do j = 1, 3 earth_pos(j) = splint_simple(tod%x_earth_spline(j), obs_time) - obs_pos(j) = splint_simple(tod%x_obs_spline(j), obs_time) + obs_pos(j) = splint_simple(tod%x_obs_spline(j), obs_time) end do - R_obs = norm2(obs_pos) - earth_lon = atan(earth_pos(2), earth_pos(1)) - call tod%clear_zodi_cache(obs_time) + R_obs = norm2(obs_pos) + earth_lon = atan(earth_pos(2), earth_pos(1)) + cache = -1 + cache_time = obs_time end if ! Get lookup index for cache. If the pixel is already cached, used that value. if (use_lowres) then - lookup_idx = tod%pix2ind_lowres(tod%udgrade_pix_zodi(pix(i))) - if (tod%zodi_therm_cache_lowres(lookup_idx, 1, det) > 0.d0) then - if (scattering) s_zodi_scat(i,:) = tod%zodi_scat_cache_lowres(lookup_idx, :, det) - if (thermal) s_zodi_therm(i,:) = tod%zodi_therm_cache_lowres(lookup_idx, :, det) - cache_hits = cache_hits + 1 - cycle - end if + lookup_idx = tod%pix2ind_lowres(tod%udgrade_pix_zodi(pix(i))) unit_vector = tod%ind2vec_ecl_lowres(:, lookup_idx) else - lookup_idx = tod%pix2ind(pix(i)) - !write(*,*) 'q1', tod%scanid(scan), lookup_idx - !write(*,*) 'q2', tod%scanid(scan), lookup_idx, pix(i), det, tod%zodi_therm_cache(lookup_idx, 1, det) - if (tod%zodi_therm_cache(lookup_idx, 1, det) > 0.d0) then - if (scattering) s_zodi_scat(i,:) = tod%zodi_scat_cache(lookup_idx, :, det) - if (thermal) s_zodi_therm(i,:) = tod%zodi_therm_cache(lookup_idx, :, det) - cache_hits = cache_hits + 1 - cycle - end if + lookup_idx = tod%pix2ind(pix(i)) unit_vector = tod%ind2vec_ecl(:, lookup_idx) end if + + if (cache(lookup_idx, det) > 0.d0) then + s_zodi(i) = cache(lookup_idx, det) + cache_hits = cache_hits + 1 + cycle + end if + ! If not present in cache, compute signal for each zodi component from scratch, and add signals together + s_tot = 0. do k = 1, model%n_comps ! If comp is present we only evaluate the zodi emission for that component. ! If comp == 0 then we evaluate the zodi emission for all components. @@ -1379,9 +1370,9 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod do l = 1, 3 ! Convert quadrature range from [-1, 1] to [R_min, R_max] - comp_LOS(k)%X_unit(l, :) = (0.5 * (R_max - R_MIN)) * comp_LOS(k)%gauss_nodes + (0.5 * (R_max + R_MIN)) - comp_LOS(k)%X_unit(l, :) = comp_LOS(k)%X_unit(l, :) * unit_vector(l) - comp_LOS(k)%X(l, :) = comp_LOS(k)%X_unit(l, :) + obs_pos(l) + comp_LOS(k)%X_unit(l,:) = (0.5 * (R_max - R_MIN)) * comp_LOS(k)%gauss_nodes + (0.5 * (R_max + R_MIN)) + comp_LOS(k)%X_unit(l,:) = comp_LOS(k)%X_unit(l, :) * unit_vector(l) + comp_LOS(k)%X(l,:) = comp_LOS(k)%X_unit(l, :) + obs_pos(l) end do comp_LOS(k)%R = norm2(comp_LOS(k)%X, dim=1) !!$ do l = 1, size(comp_LOS(k)%R) @@ -1393,7 +1384,8 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !!$ write(*,*) 'X_unit', comp_LOS(k)%X_unit(:,l) !!$ end if !!$ end do - + + ! Compute phase function if scattering is included if (scattering) then if (trim(model%phasefunc_type) == 'Wright') then allocate(b_nu(size(tod%bp(0)%p%nu))) @@ -1407,7 +1399,7 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod call model%get_phase_function(comp_LOS(k)%Theta, tod%zodiband, comp_LOS(k)%Phi) end if - ! Get dust grain temperature, and compute splined blackbody emission + ! Get dust grain temperature along the line of sight, and compute splined blackbody emission if (trim(model%phasefunc_type) == 'Wright' .and. k > 1) then comp_LOS(k)%T = exp(5.5301d0) * comp_LOS(k)%R**(-0.5d0) else @@ -1415,33 +1407,29 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod end if call splint_simple_multi(tod%zodi_b_nu_spl_obj(det), comp_LOS(k)%T, comp_LOS(k)%B_nu) - ! Compute predicted signal; store computed signal in cache + ! Compute density along line of sight call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) - if (scattering) then - if (trim(model%phasefunc_type) == 'Wright') then - s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 - else - s_zodi_scat(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5*(R_max - R_MIN) * 1d20 - end if - if (use_lowres) then - tod%zodi_scat_cache_lowres(lookup_idx, k, det) = s_zodi_scat(i, k) - else - tod%zodi_scat_cache(lookup_idx, k, det) = s_zodi_scat(i, k) - end if - end if - if (thermal) then - if (trim(model%phasefunc_type) == 'Wright') then - s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 - else - s_zodi_therm(i, k) = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5 * (R_max - R_MIN) * 1d20 - end if - if (use_lowres) then - tod%zodi_therm_cache_lowres(lookup_idx, k, det) = s_zodi_therm(i, k) - else - tod%zodi_therm_cache(lookup_idx, k, det) = s_zodi_therm(i, k) - end if + + ! Compute predicted signal in MJy/sr; store computed signal in cache + call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) + s_scat = 0.; s_therm = 0. + if (scattering) s_scat = sum(comp_LOS(k)%n*comp_LOS(k)%F_sol*comp_LOS(k)%Phi*comp_LOS(k)%gauss_weights) * 0.5d0*(R_max-R_MIN)*1d20 + if (thermal) s_therm = sum(comp_LOS(k)%n*comp_LOS(k)%B_nu*comp_LOS(k)%gauss_weights) * 0.5d0*(R_max-R_MIN)*1d20 + + al = zodi_model%comps(k)%c%albedo(tod%id) + em = zodi_model%comps(k)%c%emissivity(tod%id) + if (trim(zodi_model%phasefunc_type) == 'Wright') then + s_tot = s_tot + al*s_scat + em *s_therm + else + s_tot = s_tot + al*s_scat + em*(1.d0-al)*s_therm end if end do + + ! Return total zodi signal, and store final value in cache for later use + s_zodi(i) = s_tot + cache(lookup_idx, det) = s_tot + + !!$ call vec2ang(unit_vector, lat, lon) !!$ write(58,*) i, lon*180.d0/pi, 90.d0-180.d0/pi*lat, 0.958*sum(s_zodi_therm(i,:)), sum(s_zodi_scat(i,:)), sum(s_zodi_therm(i,:))+sum(s_zodi_scat(i,:)) !!$ @@ -1460,8 +1448,88 @@ subroutine get_zodi_emission(tod, pix, scan, det, s_zodi_scat, s_zodi_therm, mod !!$ write(*,*) "s", comp_LOS(1)%B_nu*0.958 end do + deallocate(cache) + end subroutine get_zodi_emission + subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s_zodi_tot, pix_dynamic, exclude_static, comp) + implicit none + class(ZodiModel), intent(in) :: zodi_model + class(comm_tod), intent(inout) :: tod + integer(i4b), intent(in) :: det, scan + real(sp), dimension(:), intent(out) :: s_zodi_tot + integer(i4b), dimension(:,:), intent(in), optional :: pix_dynamic + character(len=*), intent(in), optional :: exclude_static + integer(i4b), intent(in), optional :: comp + + integer(i4b) :: i, j, h, ntod, nhorn, ncomp, band + real(sp) :: w + real(dp) :: t1, t2 + real(sp), allocatable, dimension(:) :: s_zodi + real(sp), allocatable, dimension(:,:) :: s_scat_, s_therm_ + + ntod = size(s_zodi_tot) + ncomp = zodi_model%n_comps + band = tod%id + + ! Initialize + s_zodi_tot = 0. + + ! Compute non-stationary zodi TOD through line-of-sight integration for each horn, and add together + call wall_time(t1) + if (present(pix_dynamic)) then + allocate(s_zodi(ntod)) + do h = 1, size(pix_dynamic,2) + call get_zodi_emission(tod, pix_dynamic(:,h), scan, det, zodi_model, s_zodi, comp=comp) + w = 1.d0; if (h > 1) w = -1.d0 + s_zodi_tot = s_zodi_tot + w * s_zodi + end do + deallocate(s_zodi) + end if + call wall_time(t2) + + ! Add solar component by Healpix map lookup + if (trim(exclude_static) /= 'all' .and. associated(tod%map_solar) .and. trim(exclude_static) /= 'solar') then + do h = 1, tod%nhorn + do i = 1, ntod + j = tod%scans(scan)%d(det)%pix_sol(i,h) + if (tod%map_solar(j,1) > -1.d30) then + w = 1.d0; if (h > 1) w = -1.d0 + s_zodi_tot(i) = s_zodi_tot(i) + w * tod%map_solar(j,1) + end if + end do + end do + end if + return + + ! Add Moon component by Healpix map lookup + if (trim(exclude_static) /= 'all' .and. trim(exclude_static) /= 'moon') then + do h = 1, tod%nhorn + do i = 1, ntod + j = tod%scans(scan)%d(det)%pix_moon(i,h) + if (tod%map_moon(j,1) > -1.d30) then + w = 1.d0; if (h > 1) w = -1.d0 + s_zodi_tot(i) = s_zodi_tot(i) + w * tod%map_moon(j,1) + end if + end do + end do + end if + + ! Add Earth component by Healpix map lookup + if (trim(exclude_static) /= 'all' .and. trim(exclude_static) /= 'earth') then + do h = 1, tod%nhorn + do i = 1, ntod + j = max(min(int(tod%scans(scan)%d(det)%earth_elon(i,h)/(pi/NBIN_EARTH_ELON)),NBIN_EARTH_ELON),1) + if (tod%map_earth(j) > -1.d30) then + w = 1.d0; if (h > 1) w = -1.d0 + s_zodi_tot(i) = s_zodi_tot(i) + w * tod%map_earth(j) + end if + end do + end do + end if + + end subroutine get_s_tot_zodi + ! Functions for evaluating the zodiacal emission ! ----------------------------------------------------------------------------------- ! Computes R_max (the length of the LOS such that it stops exactly at los_cutoff_radius). @@ -1770,105 +1838,9 @@ subroutine read_tod_zodi_params(cpar, model, tod) !call mpi_bcast(tod%zodi_albedo, size(tod%zodi_albedo), MPI_DOUBLE_PRECISION, cpar%root, cpar%comm_chain, ierr) end subroutine read_tod_zodi_params + ! Get total zodi for a given TOD, including (optionally) both dynamic and static components, and accounting for horns - subroutine get_s_tot_zodi(zodi_model, tod, det, scan, s, pix_dynamic, s_therm, s_scat, exclude_static) - implicit none - class(ZodiModel), intent(in) :: zodi_model - class(comm_tod), intent(inout) :: tod - integer(i4b), intent(in) :: det, scan - real(sp), dimension(:), intent(out) :: s - integer(i4b), dimension(:,:), intent(in), optional :: pix_dynamic - real(sp), dimension(:,:), intent(out), optional :: s_therm, s_scat - character(len=*), intent(in), optional :: exclude_static - - integer(i4b) :: i, j, h, ntod, nhorn, ncomp, band - real(sp) :: w - real(sp), allocatable, dimension(:) :: s_zodi - real(sp), allocatable, dimension(:,:) :: s_scat_, s_therm_ - - ntod = size(s,1) - ncomp = zodi_model%n_comps - band = tod%id - - s = 0. - if (present(pix_dynamic)) then - ! Get pointing - nhorn = size(pix_dynamic,2) - allocate(s_scat_(ntod,ncomp), s_therm_(ntod,ncomp), s_zodi(ntod)) - - ! Compute non-stationary zodi TOD through line-of-sight integration - do h = 1, nhorn - call get_zodi_emission(tod=tod, pix=pix_dynamic(:,h), scan=scan, & - & det=det, s_zodi_scat=s_scat_, s_zodi_therm=s_therm_, model=zodi_model) - call get_s_zodi(band, s_therm=s_therm_, s_scat=s_scat_, s_zodi=s_zodi) - w = 1.d0; if (h > 1) w = -1.d0 - s = s + w * s_zodi - if (present(s_scat)) s_scat = s_scat_ ! Only works for nhorn=1 - if (present(s_therm)) s_therm = s_therm_ - end do - - deallocate(s_scat_, s_therm_, s_zodi) - end if - !return - - ! Add solar component by Healpix map lookup - if (associated(tod%map_solar) .and. trim(exclude_static) /= 'solar') then - do h = 1, tod%nhorn - do i = 1, ntod - j = tod%scans(scan)%d(det)%pix_sol(i,h) - if (tod%map_solar(j,1) > -1.d30) then - w = 1.d0; if (h > 1) w = -1.d0 - s(i) = s(i) + w * tod%map_solar(j,1) - end if - end do - end do - end if - return - - ! Add Moon component by Healpix map lookup - if (trim(exclude_static) /= 'moon') then - do h = 1, tod%nhorn - do i = 1, ntod - j = tod%scans(scan)%d(det)%pix_moon(i,h) - if (tod%map_moon(j,1) > -1.d30) then - w = 1.d0; if (h > 1) w = -1.d0 - s(i) = s(i) + w * tod%map_moon(j,1) - end if - end do - end do - end if - - ! Add Earth component by Healpix map lookup - if (trim(exclude_static) /= 'earth') then - do h = 1, tod%nhorn - do i = 1, ntod - j = max(min(int(tod%scans(scan)%d(det)%earth_elon(i,h)/(pi/NBIN_EARTH_ELON)),NBIN_EARTH_ELON),1) - if (tod%map_earth(j) > -1.d30) then - w = 1.d0; if (h > 1) w = -1.d0 - s(i) = s(i) + w * tod%map_earth(j) - end if - end do - end do - end if - - end subroutine get_s_tot_zodi - - subroutine get_zodi_emissivity_albedo(zodi, band, emissivity, albedo) - implicit none - class(ZodiModel), intent(in) :: zodi - integer(i4b), intent(in) :: band - real(dp), dimension(:), intent(out), optional :: emissivity, albedo - - integer(i4b) :: i - - do i = 1, zodi%n_comps - if (present(emissivity)) emissivity(i) = zodi%comps(i)%c%emissivity(band) - if (present(albedo)) albedo(i) = zodi%comps(i)%c%albedo(band) - end do - - end subroutine get_zodi_emissivity_albedo - - subroutine zodi_model_to_ascii(cpar, model, filename, overwrite) + subroutine zodi_model_to_ascii(cpar, model, filename, overwrite) ! Dumps the zodi model to an ascii file on the format {COMP}_{PARAM} = {VALUE}. class(ZodiModel), target, intent(in) :: model type(comm_params), intent(in) :: cpar diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 026d1324b..006b7ea8f 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -5,7 +5,7 @@ module comm_zodi_samp_mod implicit none private - public initialize_zodi_samp_mod, downsamp_invariant_structs, project_and_downsamp_sky, compute_downsamp_zodi + public initialize_zodi_samp_mod, downsamp_invariant_structs, project_and_downsamp_sky public minimize_zodi_with_powell, get_chisq_priors, precompute_lowres_zodi_lookups, create_zodi_sampgroup_mask public apply_zodi_sampgroup_mask, sample_static_zodi_map!, sample_static_zodi_amps @@ -137,7 +137,7 @@ subroutine downsamp_invariant_structs(cpar) if (.not. data(i)%tod%subtract_zodi) cycle nside = data(i)%map%info%nside - npix = nside + npix = 12*nside**2 nmaps = data(i)%map%info%nmaps ndet = data(i)%tod%ndet nhorn = data(i)%tod%nhorn @@ -153,17 +153,11 @@ subroutine downsamp_invariant_structs(cpar) if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle ntod = data(i)%tod%scans(scan)%ntod ntod_lowres = ntod/thin - - do k = 1, ntod_lowres - - end do ! Initialize detector specific downsampled quantities do j = 1, data(i)%tod%ndet d => data(i)%tod%scans(scan)%d(j) allocate(d%downsamp_pix_full(ntod_lowres)) - allocate(d%downsamp_psi_full(ntod_lowres)) - allocate(d%downsamp_mask_full(ntod_lowres)) allocate(d%downsamp_tod_full(ntod_lowres)) allocate(d%downsamp_obs_time_full(ntod_lowres)) @@ -193,9 +187,11 @@ subroutine downsamp_invariant_structs(cpar) deallocate(tod, s_static) ! Remove masked samples + ntod_lowres = count(mask) d%downsamp_pix_full = pack(d%downsamp_pix_full, mask) d%downsamp_tod_full = pack(d%downsamp_tod_full, mask) d%downsamp_obs_time_full = pack(d%downsamp_obs_time_full, mask) + deallocate(mask) ! write timestreams to files ! call int2string(data(i)%tod%scanid(scan), scan_str) @@ -208,10 +204,6 @@ subroutine downsamp_invariant_structs(cpar) ! call close_hdf_file(tod_file) ! Allocate other downsampled quantities with same shape - ntod_lowres = count(mask) - allocate(d%downsamp_zodi_full(ntod_lowres)) - allocate(d%downsamp_scat_full(ntod_lowres)) - allocate(d%downsamp_therm_full(ntod_lowres)) allocate(d%downsamp_point_full(ntod_lowres,5)) do k = 1, ntod_lowres call pix2ang_ring(nside, d%downsamp_pix_full(k), lat, lon) @@ -269,6 +261,7 @@ subroutine precompute_lowres_zodi_lookups(cpar) end do nobs_downsamp = count(pix2ind_highres == 1) + data(i)%tod%zodi_cache_nobs_lowres = nobs_downsamp allocate(ind2vec_zodi_temp(3, nobs_downsamp)) allocate(ind2pix_highres(nobs_downsamp)) @@ -296,15 +289,10 @@ subroutine precompute_lowres_zodi_lookups(cpar) j = j + 1 end do - nobs_lowres = j - 1 + nobs_lowres = j-1 allocate(data(i)%tod%ind2vec_ecl_lowres(3, nobs_lowres)) data(i)%tod%ind2vec_ecl_lowres = ind2vec_zodi_temp(:, 1:nobs_lowres) - allocate(data(i)%tod%zodi_scat_cache_lowres(nobs_lowres, data(i)%tod%zodi_n_comps, data(i)%tod%ndet)) - allocate(data(i)%tod%zodi_therm_cache_lowres(nobs_lowres, data(i)%tod%zodi_n_comps, data(i)%tod%ndet)) - data(i)%tod%zodi_scat_cache_lowres = -1.d0 - data(i)%tod%zodi_therm_cache_lowres = -1.d0 - do k = 1, nobs_lowres data(i)%tod%ind2vec_ecl_lowres(:, k) = matmul(data(i)%tod%ind2vec_ecl_lowres(:, k), rotation_matrix) end do @@ -316,14 +304,13 @@ subroutine project_and_downsamp_sky(cpar) implicit none type(comm_params), intent(in) :: cpar - integer(i4b) :: i, j, k, scan, ext(2), upper_bound, padding, ierr, ntod, nhorn, npix, ndet, nmaps, thin, ntod_lowres + integer(i4b) :: i, j, k, scan, ext(2), upper_bound, padding, ierr, ntod, nhorn, npix, ndet, nmaps, thin, ntod_lowres, pix type(map_ptr), allocatable, dimension(:, :) :: sky_signal real(sp), allocatable, dimension(:) :: downsamp_sky, downsamp_mask logical(lgt), allocatable, dimension(:) :: downsamp_mask_idx real(sp), allocatable, dimension(:, :, :, :) :: map_sky real(dp), allocatable, dimension(:, :) :: m_buf type(hdf_file) :: tod_file - integer(i4b), allocatable :: pix(:, :), psi(:, :), flag(:) real(sp), allocatable :: mask(:), sky(:) real(sp), allocatable, dimension(:) :: procmask_zodi @@ -349,13 +336,14 @@ subroutine project_and_downsamp_sky(cpar) ! Project sky signal into already downsampled data structures do scan = 1, data(i)%tod%nscan if (.not. any(data(i)%tod%scans(scan)%d%accept)) cycle - ntod = data(i)%tod%scans(scan)%ntod - do j = 1, ndet ntod_lowres = size(data(i)%tod%scans(scan)%d(j)%downsamp_pix_full) - allocate(data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(ntod_lowres)) + if (.not. allocated(data(i)%tod%scans(scan)%d(j)%downsamp_sky_full)) then + allocate(data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(ntod_lowres)) + end if do k = 1, ntod_lowres - data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(k) = map_sky(1, data(i)%tod%pix2ind(pix(k, 1)), j, 1) !zodi is only temperature (for now) + pix = data(i)%tod%scans(scan)%d(j)%downsamp_pix_full(k) + data(i)%tod%scans(scan)%d(j)%downsamp_sky_full(k) = map_sky(1, data(i)%tod%pix2ind(pix), j, 1) !zodi is only temperature (for now) end do end do end do @@ -405,7 +393,6 @@ subroutine create_zodi_sampgroup_mask(cpar, handle) integer(i4b) :: i, j, k, l, scan, ierr, non_glitch_size, thinstep, offset, ntod, ngood real(dp) :: rms, frac, thin_frac - logical(lgt), allocatable, dimension(:) :: basemask real(sp), allocatable :: res(:) real(sp), allocatable :: downsamp_scat_comp(:, :), downsamp_therm_comp(:, :) @@ -418,7 +405,7 @@ subroutine create_zodi_sampgroup_mask(cpar, handle) if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle ! Initialize masks - ntod = size(data(i)%tod%scans(scan)%d(j)%downsamp_tod) + ntod = size(data(i)%tod%scans(scan)%d(j)%downsamp_tod_full) allocate(data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(ntod,cpar%zs_num_samp_groups)) data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask = .true. @@ -433,10 +420,11 @@ subroutine create_zodi_sampgroup_mask(cpar, handle) ! Apply TOD thinning; may be different for each sampling group do l = 1, cpar%zs_num_samp_groups + ! Remove samples at high latitudes, if requested by user - if (cpar%zs_samp_group_max_b_ecl(i) < 0.5d0*pi) then + if (cpar%zs_samp_group_max_b_ecl(l) < 90.d0) then do k = 1, ntod - if (abs(data(i)%tod%scans(scan)%d(j)%downsamp_point_full(k,3)) > cpar%zs_samp_group_max_b_ecl(i)) then + if (abs(data(i)%tod%scans(scan)%d(j)%downsamp_point_full(k,3)) > cpar%zs_samp_group_max_b_ecl(l)) then data(i)%tod%scans(scan)%d(j)%zodi_sampgroup_mask(k,l) = .false. end if end do @@ -455,7 +443,6 @@ subroutine create_zodi_sampgroup_mask(cpar, handle) k = k+1 end do end do - deallocate(basemask) end do end do end do @@ -631,6 +618,7 @@ function lnL_zodi(p) logical(lgt) :: accept character(len=4) :: scan_str type(hdf_file) :: tod_file + real(sp), allocatable, dimension(:) :: s_zodi call wall_time(t1) @@ -674,36 +662,19 @@ function lnL_zodi(p) ! Get monopole mono = band_monopole(i) - ! Make sure that the zodi cache is cleared before each new band - call data(i)%tod%clear_zodi_cache() - ! Evaluate zodi model with newly proposed values for each band and calculate chisq - chisq_prev(i) = 0.d0 do scan = 1, nscan ! Skip scan if no accepted data do j = 1, ndet if (.not. data(i)%tod%scans(scan)%d(j)%accept) cycle + allocate(s_zodi(size(data(i)%tod%scans(scan)%d(j)%downsamp_tod))) + call wall_time(t3) - call get_zodi_emission(& - & tod=data(i)%tod, & - & pix=data(i)%tod%scans(scan)%d(j)%downsamp_pix, & - & scan=scan, & - & det=j, & - & s_zodi_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & model=zodi_model, & - & use_lowres_pointing=.true. & - &) + call get_zodi_emission(data(i)%tod, data(i)%tod%scans(scan)%d(j)%downsamp_pix, & + & scan, j, zodi_model, s_zodi, use_lowres_pointing=.true.) call wall_time(t4) !if (data(1)%tod%myid == 10) write(*,*) ' CPU1 = ', t4-t3 - call get_s_zodi(i, & - & s_therm=data(i)%tod%scans(scan)%d(j)%downsamp_therm, & - & s_scat=data(i)%tod%scans(scan)%d(j)%downsamp_scat, & - & s_zodi=data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - &) - call wall_time(t3) - !if (data(1)%tod%myid == 10) write(*,*) ' CPU2 = ', t3-t4 !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'tod ', minval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)), maxval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)) !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'sky ', minval((data(i)%tod%scans(scan)%d(j)%downsamp_tod)), maxval((data(i)%tod%scans(scan)%d(j)%downsamp_sky)) @@ -711,15 +682,9 @@ function lnL_zodi(p) !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'mono ', mono !write(*,*) data(i)%tod%scanid(scan), data(1)%tod%myid, 'noise', data(i)%tod%scans(scan)%d(j)%N_psd%sigma0 chisq = sum( & - & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod & - & - data(i)%tod%scans(scan)%d(j)%gain * & - & (data(i)%tod%scans(scan)%d(j)%downsamp_sky & - & + data(i)%tod%scans(scan)%d(j)%downsamp_zodi & - & + mono) & - & )/(data(i)%tod%scans(scan)%d(j)%N_psd%sigma0))**2 & - &) + & ((data(i)%tod%scans(scan)%d(j)%downsamp_tod - data(i)%tod%scans(scan)%d(j)%gain * & + & (data(i)%tod%scans(scan)%d(j)%downsamp_sky + s_zodi + mono))/data(i)%tod%scans(scan)%d(j)%N_psd%sigma0)**2) chisq_tot = chisq_tot + chisq - chisq_prev(i) = chisq_prev(i) + chisq call wall_time(t4) !if (data(1)%tod%myid == 10) write(*,*) ' CPU3 = ', t4-t3 @@ -745,7 +710,7 @@ function lnL_zodi(p) write(58,*) data(i)%tod%scans(scan)%d(j)%downsamp_point(k,:), data(i)%tod%scans(scan)%d(j)%downsamp_tod(k) & & - data(i)%tod%scans(scan)%d(j)%gain * & & (data(i)%tod%scans(scan)%d(j)%downsamp_sky(k) & - & + data(i)%tod%scans(scan)%d(j)%downsamp_zodi(k) & + & + s_zodi(k) & & + mono) end do close(58) @@ -753,12 +718,11 @@ function lnL_zodi(p) call wall_time(t3) !if (data(1)%tod%myid == 10) write(*,*) ' CPU4 = ', t3-t4 + deallocate(s_zodi) end do end do end do - !write(*,*) data(1)%tod%myid, ' -- recomputed =', chisq_prev - ! Reduce chisq to root process call mpi_reduce(chisq_tot, chisq, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, data(1)%tod%comm, ierr) call mpi_reduce(ndof, ndof_tot, 1, MPI_INTEGER, MPI_SUM, 0, data(1)%tod%comm, ierr) @@ -774,7 +738,6 @@ function lnL_zodi(p) write(unit,*) chisq/ndof_tot, real(theta,sp) end if - theta_prev = theta end function end subroutine minimize_zodi_with_powell diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 82d003e27..be85dd9f9 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -277,9 +277,8 @@ program commander if (cpar%enable_tod_simulations) exit ! Sample zodi parameters - if (mod(iter,modfact) == 0 .and. iter > 1 .and. cpar%enable_TOD_analysis .and. cpar%sample_zodi) then + if (mod(iter,modfact) == 0 .and. iter > 0 .and. cpar%enable_TOD_analysis .and. cpar%sample_zodi) then call timer%start(TOT_ZODI_SAMP) - call project_and_downsamp_sky(cpar) if (first_zodi) then ! in the first tod gibbs iter we precompute timeinvariant downsampled quantities call downsamp_invariant_structs(cpar) @@ -288,13 +287,14 @@ program commander call create_zodi_sampgroup_mask(cpar, handle) first_zodi = .false. end if + call project_and_downsamp_sky(cpar) ! Sample non-stationary zodi components with geometric 3D model do i = 1, cpar%zs_num_samp_groups call apply_zodi_sampgroup_mask(cpar, i) select case (trim(adjustl(cpar%zs_sample_method))) case ("powell") - if (iter > 1) call minimize_zodi_with_powell(cpar, iter, handle, i) + call minimize_zodi_with_powell(cpar, iter, handle, i) end select end do @@ -559,9 +559,6 @@ subroutine process_all_TODs(cpar, chain, iter, handle) rms => comm_map(data(i)%rmsinfo) call data(i)%tod%process_tod(cpar%outdir, chain, iter, handle, s_sky, delta, data(i)%map, rms, s_gain) - ! Clear zodi cache for next band - if (data(i)%subtract_zodi) call data(i)%tod%clear_zodi_cache() - call timer%incr_numsamp(data(i)%id_abs) if (cpar%myid_chain == 0) then From 9f32525ba85c76690edf6577fea0876e3bb18d6f Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 15 Apr 2025 23:06:59 +0200 Subject: [PATCH 146/171] Removed duplicate function call --- commander3/src/comm_zodi_mod.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index f76cf49ca..6d634f054 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -1407,8 +1407,8 @@ subroutine get_zodi_emission(tod, pix, scan, det, model, s_zodi, use_lowres_poin end if call splint_simple_multi(tod%zodi_b_nu_spl_obj(det), comp_LOS(k)%T, comp_LOS(k)%B_nu) - ! Compute density along line of sight - call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) +!!$ ! Compute density along line of sight +!!$ call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) ! Compute predicted signal in MJy/sr; store computed signal in cache call model%comps(k)%c%get_density(comp_LOS(k)%X, earth_lon, comp_LOS(k)%n) From 47c48ae701fe1d5ef8f42ea34bc7a0a9a570b65b Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Tue, 29 Apr 2025 16:40:28 +0200 Subject: [PATCH 147/171] fixed version of n+2 mapmaking, running for LFI 30GHz --- commander3/src/comm_tod_lfi_smod.f90 | 24 +++++++------ commander3/src/comm_tod_mapmaking_mod.f90 | 43 +++++++++++++++++++---- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index e669a2e5c..ebe347bfa 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -673,13 +673,13 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d ! Toggle optional operations sample_rel_bandpass = .false. !.not. self%sample_abs_bp .or. (size(delta,3) > 1 .and. mod(iter,2) == 0) ! Sample relative bandpasses if more than one proposal sky - sample_abs_bandpass = .false. ! self%sample_abs_bp .and. (size(delta,3) > 1 .and. mod(iter,2) == 1) ! sample absolute bandpasses + sample_abs_bandpass = self%sample_abs_bp .and. (size(delta,3) > 1 .and. mod(iter,2) == 1) ! sample absolute bandpasses sample_polang = .false. select_data = self%first_call ! only perform data selection the first time output_scanlist = mod(iter-1,1) == 0 ! only output scanlist every 10th iteration sample_rel_bandpass = .false. !sample_rel_bandpass .and. .not. self%enable_tod_simulations - sample_abs_bandpass = .false.!sample_abs_bandpass .and. .not. self%enable_tod_simulations + sample_abs_bandpass = sample_abs_bandpass .and. .not. self%enable_tod_simulations ! Initialize local variables ndelta = size(delta,3) @@ -694,6 +694,8 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d if (self%output_aux_maps > 0) then if (mod(iter-1,self%output_aux_maps) == 0) self%output_n_maps = 8 end if + !self%output_n_maps = 1 + call int2string(chain, ctext) call int2string(iter, samptext) @@ -768,12 +770,12 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d ! end if ! Sample gain components in separate TOD loops; marginal with respect to n_corr - !if (.not. self%enable_tod_simulations) then - ! call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain1") - ! call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain2") - ! call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain3") - !call sample_gain_psd(self, handle) - !end if + if (.not. self%enable_tod_simulations) then + call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain1") + call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain2") + call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2); call update_status(status, "tod_gain3") + call sample_gain_psd(self, handle) + end if ! Prepare intermediate data structures if(self%map_type == 'nplus2') then @@ -816,11 +818,11 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d else call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) end if - !sd%n_corr = 0. - !sd%s_bp = 0. + sd%n_corr = 0. + sd%s_bp = 0. ! Compute noise spectrum parameters - !call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) + call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) ! Compute chisquare do j = 1, sd%ndet diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index a5de5d6d5..a5d40c3a7 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -73,9 +73,9 @@ subroutine init_binmap(self, tod, shared, solve_S, nplus2) write(*,*) "Cannot use n+2 mapmaking for nmaps=", tod%nmaps stop end if - self%ncol = tod%nmaps + tod%ndet - 1 + self%ncol = tod%nmaps - 1 self%n_A = 3*tod%ndet + 3 - self%nout = tod%output_n_maps *(tod%ndet+2) + self%nout = tod%output_n_maps *tod%ndet else self%ncol = tod%nmaps self%n_A = tod%nmaps*(tod%nmaps+1)/2 @@ -254,6 +254,15 @@ subroutine bin_TOD(tod, scan, pix, psi, flag, data, binmap) binmap%A_map(off+2,pix_) = binmap%A_map(off+2,pix_) + tod%cos2psi(psi_) * inv_sigmasq binmap%A_map(off+3,pix_) = binmap%A_map(off+3,pix_) + tod%sin2psi(psi_) * inv_sigmasq end if + +! if(pix_ == 1 .and. det==2) then +! write(*,*) "Id", tod%myid +! write(*,*) "A" +! write(*,*) binmap%A_map(:,pix_) +! write(*,*) "B" +! write(*,*) binmap%b_map(1, :, pix_) +! end if + end do end do @@ -682,6 +691,11 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, mask, correct_tra allocate(b_copy(ndet+2)) + if(tod%myid == 0) then + write(*,*) 'A_start', tod%myid, binmap%sA_map%a(:,1) + write(*,*) 'B_start', tod%myid, binmap%sb_map%a(1,:,1) + end if + ! Collect contributions from all nodes call mpi_win_fence(0, binmap%sA_map%win, ierr) if (binmap%sA_map%myid_shared == 0) then @@ -700,9 +714,9 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, mask, correct_tra end if call mpi_win_fence(0, binmap%sb_map%win, ierr) - allocate (A_tot(n_A, 0:np0 - 1), b_tot(nout, nmaps, 0:np0 - 1), bs_tot(nout, ncol, 0:np0 - 1), W(nmaps), eta(nmaps)) + allocate (A_tot(n_A, 0:np0 - 1), b_tot(nout, ndet+2, 0:np0 - 1), bs_tot(nout, ncol, 0:np0 - 1), W(nmaps), eta(nmaps)) A_tot = binmap%sA_map%a(:, tod%info%pix + 1) - b_tot = binmap%sb_map%a(:, 1:nmaps, tod%info%pix + 1) + b_tot(:,:,0:np0-1) = binmap%sb_map%a(:, 1:ndet+2, tod%info%pix + 1) bs_tot = binmap%sb_map%a(:, :, tod%info%pix + 1) ! Solve for local map and rms @@ -725,9 +739,9 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, mask, correct_tra A_inv(ndet+2, 1) = A_tot(4,i) ! Other detectors T do j=2, ndet - A_inv(j,j) = A_tot(7+3*(ndet-2), i) - A_inv(j,ndet+1) = A_tot(8+3*(ndet-2), i) - A_inv(j,ndet+2) = A_tot(9+3*(ndet-2), i) + A_inv(j,j) = A_tot(7+3*(j-2), i) + A_inv(j,ndet+1) = A_tot(8+3*(j-2), i) + A_inv(j,ndet+2) = A_tot(9+3*(j-2), i) A_inv(ndet+1,j) = A_inv(j,ndet+1) A_inv(ndet+2,j) = A_inv(j,ndet+2) end do @@ -738,16 +752,31 @@ subroutine finalize_binned_map_nplus2(tod, binmap, rms, scale, mask, correct_tra A_inv(ndet+1,ndet+2) = A_tot(5, i) A_inv(ndet+2,ndet+1) = A_tot(5, i) + if(tod%myid == 0 .and. i==0) write(*,*) "A for pix=", i + do j=1, ndet+2 + if(tod%myid == 0 .and. i==0) write(*,*) A_inv(:, j) + end do + ! Can I return the condition number? call invert_singular_matrix(A_inv, 1d-12) + if(tod%myid == 0 .and. i==0) write(*,*) "A^-1" + do j=1, ndet+2 + if(tod%myid == 0 .and. i ==0) write(*,*) A_inv(:, j) + end do + do k = 1, tod%output_n_maps b_copy(1) = b_tot(k, 1, i) b_copy(2:ndet) = b_tot(k, 4:ndet+2, i) b_copy(ndet+1) = b_tot(k, 2, i) b_copy(ndet+2) = b_tot(k, 3, i) + if(tod%myid == 0 .and. k == 1 .and. i == 0) write(*,*) "B" + if(tod%myid == 0 .and. k == 1 .and. i == 0) write(*,*) b_copy b_tot(k, 1:ndet+2, i) = matmul(A_inv, b_copy) end do + if(tod%myid == 0 .and. i == 0) write(*,*) "A^-1 B" + if(tod%myid == 0 .and. i == 0) write(*,*) b_tot(1,:,i) + ! Store map in correct units do p = 1, tod%ndet do k = 1, tod%output_n_maps From cc1f76374f97976f98834e1fbe5807c9b0320dd2 Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Wed, 30 Apr 2025 14:40:13 +0200 Subject: [PATCH 148/171] Added new HFI single horn parameter files and fixed file read in for mono_prior_map to correctly append the data directory in comm_diffuse_comp_smod when necessary. --- .../defaults/bands/HFI/HFI_100-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_100-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_100-3_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_100-4_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-3_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-4_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-5_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-6_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_143-7_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-3_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-4_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-5_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-6_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-7_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_217-8_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-3_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-4_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-5_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-6_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-7_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_353-8_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_545-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_545-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_545-4_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_857-1_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_857-2_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_857-3_HFI.defaults | 2 +- .../defaults/bands/HFI/HFI_857-4_HFI.defaults | 2 +- commander3/src/comm_diffuse_comp_smod.f90 | 18 ++++++++---------- 35 files changed, 42 insertions(+), 44 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults index 7ed7b7c0e..9bfd981f8 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 100 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-1_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults index fadec4378..a4a02dd57 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 100 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-2_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults index 9e6796bbc..402b3ece5 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-3_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 100 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-3_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults index 3930a360d..3d2a14352 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 100 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_100-4_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults index e15c420eb..54a3d60e0 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-1_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults index d532aa608..e4d7fc507 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-2_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults index 3d221f35c..44f3cc262 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-3_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-3_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults index bac570a3c..fe2696233 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-4_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults index 9ac7e08d9..318e7a6bd 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-5_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-5.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults index cd08e90e4..44c35c3a1 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-6_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-6.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults index a1acb0872..2f7607a91 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_143-7_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 143 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_143-7.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults index 7166bcce3..7c7cbb9cb 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-1.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults index c9acf759d..60fbe00b9 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-2.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults index b01768a2f..8a6c443c7 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-3_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-3.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults index 0d9a4c4d8..af94547ce 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-4.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults index 8746bb6a9..e2b35c304 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-5_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-5_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults index 8e8bcb262..792594497 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-6_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-6_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults index b4bc26885..d75da31f5 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-7_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-7_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults index c85bb1b1f..bc8e5af1d 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_217-8_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 217 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_217-8_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults index 653a36452..c5286da02 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-1.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults index 659037c3e..bb7ba14ca 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-2.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults index 1484602b3..d6b1b89b2 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-3_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-3_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults index 54d2f08cc..0e9aa1693 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-4_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults index 6f22a6ca2..f8522dda7 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-5_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-5_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults index 0d15ef1ba..88b207b7c 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-6_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-6_SHORN.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults index c0d389109..4cca6b0cf 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-7_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-7.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults index 5990448bd..816b14b50 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353-8_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 353 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_353-8.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults index 6fb6e31c0..656beabf5 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 545 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-1.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults index ff3940e8f..b7ea987f1 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 545 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-2.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults index fe57cf01b..fbe65df3d 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 545 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_545-4.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults index c1d6e0547..745d6dc3d 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-1_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 857 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-1.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults index eea68e6bd..67819cb48 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-2_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 857 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-2.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults index ddcd233bc..6799282c6 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-3_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 857 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-3.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults index 5c01d6cb6..80e39daf6 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857-4_HFI.defaults @@ -21,7 +21,7 @@ BAND_SAMP_NOISE_AMP&&& = .false. BAND_BANDPASS_TYPE&&& = HFI_cmb BAND_BANDPASS_MODEL&&& = additive_shift BAND_NOMINAL_FREQ&&& = 857 -BAND_SAMP_BANDPASS&&& = .false +BAND_SAMP_BANDPASS&&& = .false. BAND_BANDPASSFILE&&& = bp_RIMO_v2.0_857-4.dat BAND_SAMP_GAIN&&& = .false. BAND_GAIN_PRIOR_MEAN&&& = 1. diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 9a70716ec..c51c24bad 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -276,7 +276,8 @@ module subroutine initDiffuse(self, cpar, id, id_abs) if (trim(self%mono_prior_type) /= 'none') then self%cg_samp_group_md = cpar%cg_samp_group_md temp_filename = get_token(cpar%cs_mono_prior(id_abs), ":", 2) - if(temp2(1:1) /= '/') then + !!raelyn changed temp2 (never initialized) to temp_filename, needed to add the data directroy to the file names + if(temp_filename(1:1) /= '/') then if(trim(self%mono_prior_type) /= 'bandmono') then temp_filename = trim(cpar%datadir)// '/' // trim(temp_filename) end if @@ -1819,8 +1820,8 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) do j = 1,self%npar info => comm_mapinfo(data(i)%info%comm, data(i)%info%nside, & & self%theta(j)%p%info%lmax, nmaps, data(i)%info%pol) - td => comm_map(info) - + td => comm_map(info) !empty array, commander type map + ! if self%theta(j)%p%info%lmax=0 constant on the sky ! if any polarization is alm sampled. Only use alms to set polarizations with alm sampling if (any(self%lmax_ind_pol(1:self%poltype(j),j) >= 0)) then t => comm_map(info) @@ -1921,7 +1922,6 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) cycle end if - ! Loop over all pixels, computing mixing matrix for each !allocate(theta_p(self%npar,self%nmaps)) call wall_time(t1) @@ -1935,14 +1935,14 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) end if end if -! if (all(self%lmax_ind_mix(1:min(self%nmaps,data(i)%info%nmaps)) == 0)) then !if (self%lmax_ind == 0) then -! cycle -! end if + !if (all(self%lmax_ind_mix(1:min(self%nmaps,data(i)%info%nmaps)) == 0)) then !if (self%lmax_ind == 0) then + ! cycle + !end if ! NEW ! Check band sensitivity before mixing matrix update ! Possible labels are "broadband", "cmb", "synch", "dust", "co10", "co21", "co32", "ff", "ame" if (data(i)%comp_sens == "broadband") then - ! If broadband, calculate mixing matrix + ! If broadband, calculate mixing matrix mixmatnull = .false. else ! If component sensitivity, only calculate mixmat on that component. @@ -2024,8 +2024,6 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) end if end do - - call wall_time(t2) !if (self%x%info%myid == 0) write(*,*) 'eval = ', t2-t1 ! Compute mixing matrix average; for preconditioning only From 767df8963dd6f0597d6ab268b647c489a9767df4 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Sat, 10 May 2025 09:08:22 +0200 Subject: [PATCH 149/171] Enabled ptsrc positivity prior --- commander3/src/comm_ptsrc_comp_mod.f90 | 23 +++++++++++----- commander3/src/comm_signal_mod.f90 | 38 +++++++++++++------------- commander3/src/commander.f90 | 2 +- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index c116b59cf..3e58acd39 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -265,7 +265,7 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) end do ! Disable CG search when asking for positivity prior - if (c%apply_pos_prior) c%active_samp_group = .false. + !if (c%apply_pos_prior) c%active_samp_group = .false. ! Read and allocate source structures call update_status(status, "init_ptsrc2") @@ -453,7 +453,7 @@ function evalPtsrcBand(self, band, amp_in, pix, alm_out, det) do j = 1, self%src(i)%T(band_active)%nmaps if(self%precomputed_amps) then ! so far just used for stars - m = self%src(i)%amp_precomp(band_active) * amp(i,j) + m = self%src(i)%amp_precomp(band_active) * amp(i,j) * data(band)%gain else m = self%src(i)%T(band_active)%F(j,d) * amp(i,j) end if @@ -510,7 +510,7 @@ function projectPtsrcBand(self, band, map, alm_in, det) if(self%precomputed_amps) then ! so far just used for stars - m = self%src(i)%amp_precomp(band_active) !*self%x(i,j) + m = self%src(i)%amp_precomp(band_active) * data(band)%gain else m = self%src(i)%T(band_active)%F(j,d) end if @@ -975,6 +975,13 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) call read_alloc_hdf(stars_file, '/reported_values', catalog) !nstars, nbands call read_alloc_hdf(stars_file, '/band_column_mapping', band_list) + if (.not. allocated(npre)) then + allocate(npre(cpar%cg_num_samp_groups)) + allocate(nmaps_pre(cpar%cg_num_samp_groups)) + npre = 0 + nmaps_pre = 1 + end if + ! trim unused bands from star catalog allocate(star_catalog(self%nactive, size(catalog(1,:)))) @@ -1000,6 +1007,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) self%nsrc = size(star_catalog(1, :)) call read_alloc_hdf(stars_file, 'coordinates', coords) + !coords = coords * DEG2RAD ! Convention now in degrees allocate(self%x(self%nsrc,self%nmaps), self%x_buff(self%nsrc,self%nmaps), self%src(self%nsrc)) @@ -1018,7 +1026,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) ii = ii+1 self%src(ii)%glon = coords(1,i) - self%src(ii)%glat = coords(2,i) + self%src(ii)%glat = coords(2,i) call ang2vec(0.5d0*pi-coords(2,i), coords(1,i), self%src(ii)%vec) ! Check for too close neighbours skip_src = .false. @@ -1071,7 +1079,7 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) !load in the beam information call init_beam_templates(self, cpar, id, id_abs) - ! Update mixing matrix + ! Update mixing matrix -- HKE: GAIN IS MISSING do i=1, self%nsrc do j=1, numband !self%nactive ja = self%b2a(j) @@ -2042,7 +2050,7 @@ subroutine samplePtsrcAmp(self, cpar, handle, samp_group) if (p == 1 .and. data(l)%pol_only) cycle la = self%b2a(l) do q = 1, self%src(i)%T(la)%np - src_amp = self%src(i)%amp_precomp(la) + src_amp = self%src(i)%amp_precomp(la) * data(l)%gain beam = self%src(i)%T(la)%map(q,p) pix = self%src(i)%T(la)%pix(q,1) noise = data(l)%N%rms_pix(pix, p) @@ -2083,8 +2091,9 @@ subroutine samplePtsrcAmp(self, cpar, handle, samp_group) else x_tot = 0.d0 end if + if (self%apply_pos_prior) x_tot = max(x_tot, 0.d0) if (mod(i,10000) == 0) then - write(*,fmt='(a,i8,a,f8.3,a,f8.3)') "Star ", i, " a_old = ", self%x(i,P), " a_new = ", x_tot + write(*,fmt='(a,i8,a,f8.3,a,f8.3,a,f16.8)') "Star ", i, " a_old = ", self%x(i,P), " a_new = ", x_tot, ', sigma = ', 1.d0/sqrt(A_tot) end if self%x(i,p) = x_tot end if diff --git a/commander3/src/comm_signal_mod.f90 b/commander3/src/comm_signal_mod.f90 index d377ac3f3..d5857f86f 100644 --- a/commander3/src/comm_signal_mod.f90 +++ b/commander3/src/comm_signal_mod.f90 @@ -253,25 +253,25 @@ subroutine sample_amps_by_CG(cpar, samp_group, handle, handle_noise, verbosity) end if ! Sample point source amplitudes with precomputed amplitudes -!!$ c => compList -!!$ do while (associated(c)) -!!$ select type (c) -!!$ class is (comm_ptsrc_comp) -!!$ if(c%precomputed_amps .and. c%active_samp_group(samp_group)) then -!!$ ! Initialize residual maps -!!$ do l = 1, numband -!!$ res => compute_residual(l) -!!$ data(l)%res%map = res%map -!!$ call res%dealloc(); deallocate(res) -!!$ nullify(res) -!!$ end do -!!$ ! Perform sampling -!!$ call c%samplePtsrcAmp(cpar, handle, samp_group) -!!$ return -!!$ end if -!!$ end select -!!$ c => c%nextComp() -!!$ end do + c => compList + do while (associated(c)) + select type (c) + class is (comm_ptsrc_comp) + if(c%precomputed_amps .and. c%active_samp_group(samp_group)) then + ! Initialize residual maps + do l = 1, numband + res => compute_residual(l) + data(l)%res%map = res%map + call res%dealloc(); deallocate(res) + nullify(res) + end do + ! Perform sampling + call c%samplePtsrcAmp(cpar, handle, samp_group) + return + end if + end select + c => c%nextComp() + end do ! If mono-/dipole are sampled, check if they are priors for a component zero-level c => compList diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index be85dd9f9..74936aac3 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -267,7 +267,7 @@ program commander !---------------------------------------------------------------------------------- ! Process TOD structures if (iter > 0 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then - !if (iter == 1 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then + !if (mod(iter,10) == 1 .and. cpar%enable_TOD_analysis .and. (iter <= 2 .or. mod(iter,cpar%tod_freq) == 0)) then call timer%start(TOT_TODPROC) call process_all_TODs(cpar, cpar%mychain, iter, handle) call timer%stop(TOT_TODPROC) From 9deb4567287ca4103e9717a2431850ba6820f450 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 13 May 2025 12:55:31 +0200 Subject: [PATCH 150/171] Added support for dust extinction; set EXTINCTION_E(B-V)_MAP = none if you don't want this --- cmake/projects/commander3.cmake | 1 + .../dust/dust_DIRBE_localsampler.defaults | 6 +- commander3/src/Makefile | 8 +- commander3/src/comm_data_mod.f90 | 14 +- commander3/src/comm_diffuse_comp_smod.f90 | 45 ++- commander3/src/comm_dust_extinction_mod.f90 | 329 ++++++++++++++++++ commander3/src/comm_mbbtab_comp_mod.f90 | 8 +- commander3/src/comm_param_mod.f90 | 8 + commander3/src/comm_ptsrc_comp_mod.f90 | 91 +++-- commander3/src/comm_utils.f90 | 39 ++- commander3/src/commander.f90 | 16 +- 11 files changed, 491 insertions(+), 74 deletions(-) create mode 100644 commander3/src/comm_dust_extinction_mod.f90 diff --git a/cmake/projects/commander3.cmake b/cmake/projects/commander3.cmake index 93762d87e..6cc673ddc 100644 --- a/cmake/projects/commander3.cmake +++ b/cmake/projects/commander3.cmake @@ -101,6 +101,7 @@ set(sources ${COMMANDER3_SOURCE_DIR}/comm_utils.f90 ${COMMANDER3_SOURCE_DIR}/comm_bp_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_f_mod.f90 + ${COMMANDER3_SOURCE_DIR}/comm_dust_extinction_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_ptsrc_comp_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_zodi_mod.f90 ${COMMANDER3_SOURCE_DIR}/comm_zodi_samp_mod.f90 diff --git a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults index e565381cf..64fe7c3d9 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults @@ -1,6 +1,6 @@ # New Local sampling parameters, 'dust' -COMP_BETA_INT_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat -COMP_BETA_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat COMP_BETA_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_BETA_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_BETA_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. @@ -36,7 +36,7 @@ COMP_BETA_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp COMP_BETA_CORRELATION_CONVERGENCE_SAMPLING&& = .false. COMP_BETA_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 -COMP_T_INT_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat COMP_T_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat COMP_T_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_T_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling diff --git a/commander3/src/Makefile b/commander3/src/Makefile index a504a5402..463181576 100644 --- a/commander3/src/Makefile +++ b/commander3/src/Makefile @@ -55,6 +55,7 @@ F90SOURCES=hashtbl.f90 \ comm_bp_utils.f90 \ comm_param_mod.f90 \ comm_comp_mod.f90 \ + comm_dust_extinction_mod.f90 \ comm_diffuse_comp_mod.f90 comm_diffuse_comp_smod.f90 \ comm_comp_interface_mod.f90 \ comm_cmb_comp_mod.f90 \ @@ -190,7 +191,8 @@ comm_cr_precond_mod.o : comm_utils.o comm_cr_utils.o : comm_utils.o comm_curvature_comp_mod.o : comm_comp_interface_mod.o comm_data_mod.o : comm_bp_mod.o comm_noise_mod.o comm_beam_mod.o comm_tod_inst_mod.o -comm_diffuse_comp_mod.o : comm_comp_mod.o comm_cl_mod.o comm_f_mod.o +comm_dust_extinction_mod.o : comm_map_mod.o +comm_diffuse_comp_mod.o : comm_comp_mod.o comm_cl_mod.o comm_f_mod.o comm_dust_extinction_mod.o comm_diffuse_comp_smod.o : comm_diffuse_comp_mod.o comm_exp_comp_mod.o : comm_comp_interface_mod.o comm_fft_mod.o : comm_param_mod.o @@ -225,7 +227,7 @@ comm_param_mod.o : comm_status_mod.o hashtbl.o comm_physdust_comp_mod.o : comm_comp_interface_mod.o comm_powlaw_break_comp_mod.o : comm_comp_interface_mod.o comm_powlaw_comp_mod.o : comm_comp_interface_mod.o -comm_ptsrc_comp_mod.o : comm_f_mod.o +comm_ptsrc_comp_mod.o : comm_f_mod.o comm_dust_extinction_mod.f90 comm_shared_arr_mod.o : comm_utils.o comm_shared_output_mod.o : comm_utils.o comm_signal_mod.o : comm_chisq_mod.o comm_cr_mod.o comm_cmb_comp_mod.o comm_cmb_relquad_comp_mod.o comm_mbb_comp_mod.o comm_mbbtab_comp_mod.o comm_powlaw_comp_mod.o comm_curvature_comp_mod.o comm_spindust_comp_mod.o comm_spindust2_comp_mod.o comm_md_comp_mod.o comm_line_comp_mod.o comm_freefree_comp_mod.o comm_freefreeEM_comp_mod.o comm_exp_comp_mod.o comm_physdust_comp_mod.o comm_pah_comp_mod.o comm_powlaw_break_comp_mod.o comm_ame_lognormal_mod.o @@ -283,7 +285,7 @@ comm_tod_dirbe_mod.o : comm_tod_driver_mod.o comm_tod_pixhist_mod.o comm_tod_hfi_mod.o : comm_tod_driver_mod.o comm_tod_inst_mod.o : comm_tod_lb_mod.o comm_tod_lfi_mod.o comm_tod_spider_mod.o comm_tod_wmap_mod.o comm_tod_dirbe_mod.o comm_tod_hfi_mod.o #comm_tod_quiet_mod.o -comm_data_mod.o : comm_noise_mod.o comm_bp_mod.o comm_beam_mod.o comm_tod_inst_mod.o +comm_data_mod.o : comm_noise_mod.o comm_bp_mod.o comm_beam_mod.o comm_tod_inst_mod.o comm_dust_extinction_mod.o comm_comp_mod.o : comm_cr_utils.o comm_cr_precond_mod.o comm_data_mod.o spline_2d_mod.o comm_f_int_mod.o : comm_bp_mod.o comm_comp_mod.o diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index f542a73dc..4597011e1 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -23,6 +23,7 @@ module comm_data_mod use comm_noise_mod use comm_beam_mod use comm_tod_inst_mod + use comm_dust_extinction_mod implicit none type comm_data_set @@ -55,6 +56,7 @@ module comm_data_mod class(comm_map), pointer :: mask => null() class(comm_map), pointer :: procmask => null() class(comm_map), pointer :: gainmask => null() + class(comm_map), pointer :: A_ext => null() class(comm_tod), pointer :: tod => null() class(comm_N), pointer :: N => null() class(B_ptr), allocatable, dimension(:) :: B @@ -87,7 +89,7 @@ subroutine initialize_data_mod(cpar, handle) class(comm_N), pointer :: tmp => null() class(comm_map), pointer :: smoothed_rms => null() class(comm_mapinfo), pointer :: info_smooth => null(), info_postproc => null() - class(comm_mapinfo), pointer :: smoothed_rms_info => null() + class(comm_mapinfo), pointer :: smoothed_rms_info => null(), info_ext => null() real(dp), allocatable, dimension(:) :: nu real(dp), allocatable, dimension(:,:) :: regnoise, mask_misspix @@ -320,7 +322,15 @@ subroutine initialize_data_mod(cpar, handle) end do end if - + ! Initialize dust extinction map + if (active_dust_ext_model(data(i)%bp(0)%p%nu_c)) then + info_smooth => comm_mapinfo(data(n)%info%comm, data(n)%info%nside, & + & -1, 1, .false.) + data(n)%A_ext => comm_map(data(n)%info) + call get_dust_attenuation_map(data(n)%bp(0)%p%nu_c, data(n)%A_ext) + call data(n)%A_ext%writeFITS(trim(cpar%outdir)//'/dust_ext_'//trim(data(n)%label)//'.fits') + end if + ! Initialize smoothed data structures allocate(data(n)%B_smooth(cpar%num_smooth_scales)) allocate(data(n)%B_postproc(cpar%num_smooth_scales)) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 52109fef4..5e47d0d3d 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -72,12 +72,6 @@ module subroutine initDiffuse(self, cpar, id, id_abs) self%nu_min = cpar%cs_nu_min(id_abs) self%nu_max = cpar%cs_nu_max(id_abs) - if(self%npar == 0) then - self%lmax_ind = 0 !default - allocate(self%lmax_ind_mix(3,1)) - self%lmax_ind_mix = 0 - end if - self%cltype = cpar%cs_cltype(id_abs) self%cg_scale(1:3) = cpar%cs_cg_scale(1:3,id_abs) self%nmaps = 1; if (self%pol) self%nmaps = 3 @@ -358,7 +352,12 @@ module subroutine initLmaxSpecind(self, cpar, id, id_abs) nmaps = 1 if (cpar%cs_polarization(id_abs)) nmaps=3 - if (self%npar==0) return !do not go further, lmax_ind is set in initDiffuse + if (self%npar==0) then + allocate(self%lmax_ind_mix(3,1)) + self%lmax_ind = cpar%cs_lmax_ind_pol(p,i,id_abs) + self%lmax_ind_mix = cpar%cs_lmax_ind_pol(p,i,id_abs) + return !do not go further, lmax_ind is set in initDiffuse + end if allocate(self%lmax_ind_pol(3,self%npar)) ! {integer}: lmax per. polarization (poltype index) per spec. ind. @@ -369,7 +368,7 @@ module subroutine initLmaxSpecind(self, cpar, id, id_abs) do i = 1,self%npar do p = 1, self%poltype(i) l = cpar%cs_lmax_ind_pol(p,i,id_abs) - + !assign lmax per spec ind per polarization (poltype) if (self%poltype(i)==1) then !all polarizations have the same lmax self%lmax_ind_pol(:,i) = l @@ -1155,7 +1154,9 @@ module subroutine initPixregSampling(self, cpar, id, id_abs) if (self%lmax_ind_pol(j,i) >= 0) then self%lmax_ind_mix(p_min:p_max,i) = self%lmax_ind_pol(j,i) !in case only_pol and poltype = 2 has lmax > 0 else if (self%pol_pixreg_type(j,i)==1) then !pixel region is defined fullsky - self%lmax_ind_mix(p_min:p_max,i) = 0 + do k = p_min, p_max + self%lmax_ind_mix(k,i) = min(self%lmax_ind_pol(k,i), 0) + end do else self%lmax_ind_mix(p_min:p_max,i) = self%lmax_ind_pol(j,i) end if @@ -1781,7 +1782,7 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) integer(i4b), intent(in), optional :: par ! Parameter ID for derivative integer(i4b) :: i, j, k, l, n, p, p_min, p_max, nmaps, ierr - real(dp) :: lat, lon, t1, t2 + real(dp) :: lat, lon, t1, t2, A_ext logical(lgt) :: precomp, mixmatnull, bad ! NEW character(len=2) :: ctext real(dp), allocatable, dimension(:,:,:) :: theta_p @@ -1809,7 +1810,7 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) if (present(band)) then if (i /= band) cycle end if - + ! Compute spectral parameters at the correct resolution for this channel if (self%npar > 0) then nmaps = min(data(i)%info%nmaps, self%theta(1)%p%info%nmaps) @@ -1935,6 +1936,14 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) end if end if + ! Initialize dust extinction + if (associated(data(i)%A_ext)) then + A_ext = data(i)%A_ext%map(j,1) + else + A_ext = 1.d0 + end if + + ! if (all(self%lmax_ind_mix(1:min(self%nmaps,data(i)%info%nmaps)) == 0)) then !if (self%lmax_ind == 0) then ! cycle ! end if @@ -1963,14 +1972,14 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) write(*,*) i, l, j, real(theta_p(j,1,:),sp) stop !debug, replace by proper stop and error message end if - self%F(i,l)%p%map(j,1) = self%F_int(1,i,l)%p%eval(theta_p(j,1,:)) * data(i)%gain * self%cg_scale(1) + self%F(i,l)%p%map(j,1) = self%F_int(1,i,l)%p%eval(theta_p(j,1,:)) * data(i)%gain * self%cg_scale(1) * A_ext !write(*,*) i, j, theta_p(j,1,:), self%F_int(1,i,l)%p%eval(theta_p(j,1,:)), self%F(i,l)%p%map(j,1) end if else if (mixmatnull) then self%F(i,l)%p%map(j,1) = 0.0 else - self%F(i,l)%p%map(j,1) = self%F_int(1,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(1) + self%F(i,l)%p%map(j,1) = self%F_int(1,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(1) * A_ext end if end if end if @@ -1987,9 +1996,9 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) write(*,*) i, l, j, real(theta_p(j,1,:),sp) end if if (self%npar > 0) then - self%F(i,l)%p%map(j,2) = self%F_int(2,i,l)%p%eval(theta_p(j,2,:)) * data(i)%gain * self%cg_scale(2) + self%F(i,l)%p%map(j,2) = self%F_int(2,i,l)%p%eval(theta_p(j,2,:)) * data(i)%gain * self%cg_scale(2) * A_ext else - self%F(i,l)%p%map(j,2) = self%F_int(2,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(2) + self%F(i,l)%p%map(j,2) = self%F_int(2,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(2) * A_ext end if end if @@ -2003,9 +2012,9 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) write(*,*) i, l, j, real(theta_p(j,1,:),sp) end if if (self%npar > 0) then - self%F(i,l)%p%map(j,3) = self%F_int(3,i,l)%p%eval(theta_p(j,3,:)) * data(i)%gain * self%cg_scale(3) + self%F(i,l)%p%map(j,3) = self%F_int(3,i,l)%p%eval(theta_p(j,3,:)) * data(i)%gain * self%cg_scale(3) * A_ext else - self%F(i,l)%p%map(j,3) = self%F_int(3,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(3) + self%F(i,l)%p%map(j,3) = self%F_int(3,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(3) * A_ext end if end if end if @@ -2015,7 +2024,7 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) if (self%npar > 0) then do k = 1, nmaps if (k <= self%poltype(par)) then - df(i)%p%map(j,k) = self%F_int(k,i,l)%p%eval_deriv(theta_p(j,k,:),par) * data(i)%gain * self%cg_scale(k) + df(i)%p%map(j,k) = self%F_int(k,i,l)%p%eval_deriv(theta_p(j,k,:),par) * data(i)%gain * self%cg_scale(k) * A_ext end if end do else diff --git a/commander3/src/comm_dust_extinction_mod.f90 b/commander3/src/comm_dust_extinction_mod.f90 new file mode 100644 index 000000000..f65bb79a3 --- /dev/null +++ b/commander3/src/comm_dust_extinction_mod.f90 @@ -0,0 +1,329 @@ +!================================================================================ +! +! Copyright (C) 2020 Institute of Theoretical Astrophysics, University of Oslo. +! +! This file is part of Commander3 +! +! Commander3 is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! Commander3 is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with Commander3. If not, see . +! +!================================================================================ +module comm_dust_extinction_mod + use comm_utils + use comm_map_mod + implicit none + + private + public initialize_dust_extinction_mod, get_dust_attenuation_map, get_dust_attenuation_pos, active_dust_ext_model + + integer(i4b), parameter :: NPAR_EXT = 47 + + integer(i4b), parameter :: UV_C1_A = 1 + integer(i4b), parameter :: UV_C1_B = 2 + integer(i4b), parameter :: UV_C2_A = 3 + integer(i4b), parameter :: UV_C2_B = 4 + integer(i4b), parameter :: UV_C3_A = 5 + integer(i4b), parameter :: UV_C3_B = 6 + integer(i4b), parameter :: UV_C4_A = 7 + integer(i4b), parameter :: UV_C4_B = 8 + integer(i4b), parameter :: UV_X0 = 9 + integer(i4b), parameter :: UV_GAMMA = 10 + + integer(i4b), parameter :: OPT_E0_A = 11 + integer(i4b), parameter :: OPT_E0_B = 12 + integer(i4b), parameter :: OPT_E1_A = 13 + integer(i4b), parameter :: OPT_E1_B = 14 + integer(i4b), parameter :: OPT_E2_A = 15 + integer(i4b), parameter :: OPT_E2_B = 16 + integer(i4b), parameter :: OPT_E3_A = 17 + integer(i4b), parameter :: OPT_E3_B = 18 + integer(i4b), parameter :: OPT_E4_A = 19 + integer(i4b), parameter :: OPT_E4_B = 20 + integer(i4b), parameter :: OPT_F1_A = 21 + integer(i4b), parameter :: OPT_F1_B = 22 + integer(i4b), parameter :: OPT_F2_A = 23 + integer(i4b), parameter :: OPT_F2_B = 24 + integer(i4b), parameter :: OPT_F3_A = 25 + integer(i4b), parameter :: OPT_F3_B = 26 + integer(i4b), parameter :: OPT_X1 = 27 + integer(i4b), parameter :: OPT_X2 = 28 + integer(i4b), parameter :: OPT_X3 = 29 + integer(i4b), parameter :: OPT_GAMMA1 = 30 + integer(i4b), parameter :: OPT_GAMMA2 = 31 + integer(i4b), parameter :: OPT_GAMMA3 = 32 + + integer(i4b), parameter :: IR_G1_A = 33 + integer(i4b), parameter :: IR_G1_B = 34 + integer(i4b), parameter :: IR_ALPHA1_A = 35 + integer(i4b), parameter :: IR_ALPHA1_B = 36 + integer(i4b), parameter :: IR_ALPHA2 = 37 + integer(i4b), parameter :: IR_LAMBDAB = 38 + integer(i4b), parameter :: IR_DELTA = 39 + integer(i4b), parameter :: IR_S1 = 40 + integer(i4b), parameter :: IR_LAMBDAO1 = 41 + integer(i4b), parameter :: IR_GAMMAO1 = 42 + integer(i4b), parameter :: IR_A1 = 43 + integer(i4b), parameter :: IR_S2 = 44 + integer(i4b), parameter :: IR_LAMBDAO2 = 45 + integer(i4b), parameter :: IR_GAMMAO2 = 46 + integer(i4b), parameter :: IR_A2 = 47 + + type comm_dustext_model + integer(i4b) :: nside = 512 + real(dp), dimension(NPAR_EXT) :: p + real(sp), allocatable, dimension(:,:) :: EBV + end type comm_dustext_model + + real(dp) :: nu_V, nu_B, R + type(comm_dustext_model) :: ext_model + +contains + + subroutine initialize_dust_extinction_mod(cpar) + implicit none + type(comm_params), intent(in) :: cpar + + real(dp) :: aB, bB, aV, bV + + if (trim(cpar%EBVmap) == 'none') return + + ! Initialize sky model + allocate(ext_model%EBV(0:12*ext_model%nside**2-1,1)) + call read_map(trim(cpar%EBVmap), ext_model%EBV) + !info => comm_mapinfo(cpar%comm_chain, nside, lmax, 1, .false.) + !EBV_map => comm_map(info, trim(cpar%EBVmap)) + + ! Initialize parametric model + ext_model%p(UV_C1_A) = 0.81297d0 + ext_model%p(UV_C1_B) = -2.97868d0 + ext_model%p(UV_C2_A) = 0.2775d0 + ext_model%p(UV_C2_B) = 1.89808d0 + ext_model%p(UV_C3_A) = 1.06295d0 + ext_model%p(UV_C3_B) = 3.10334d0 + ext_model%p(UV_C4_A) = 0.11303d0 + ext_model%p(UV_C4_B) = 0.65484d0 + ext_model%p(UV_X0) = 4.60d0 + ext_model%p(UV_GAMMA) = 0.99d0 + + ext_model%p(OPT_E0_A) = -0.35848d0 + ext_model%p(OPT_E0_B) = 0.12354d0 + ext_model%p(OPT_E1_A) = 0.7122d0 + ext_model%p(OPT_E1_B) = -2.68335d0 + ext_model%p(OPT_E2_A) = 0.08746d0 + ext_model%p(OPT_E2_B) = 2.01901d0 + ext_model%p(OPT_E3_A) = -0.05403d0 + ext_model%p(OPT_E3_B) = -0.39299d0 + ext_model%p(OPT_E4_A) = 0.00674d0 + ext_model%p(OPT_E4_B) = 0.03355d0 + ext_model%p(OPT_F1_A) = 0.03893d0 + ext_model%p(OPT_F1_B) = 0.18453d0 + ext_model%p(OPT_F2_A) = 0.02965d0 + ext_model%p(OPT_F2_B) = 0.19728d0 + ext_model%p(OPT_F3_A) = 0.01747d0 + ext_model%p(OPT_F3_B) = 0.1713d0 + ext_model%p(OPT_X1) = 2.288d0 + ext_model%p(OPT_X2) = 2.054d0 + ext_model%p(OPT_X3) = 1.587d0 + ext_model%p(OPT_GAMMA1) = 0.243d0 + ext_model%p(OPT_GAMMA2) = 0.179d0 + ext_model%p(OPT_GAMMA3) = 0.243d0 + + ! Typo in paper -- extra minus in exponent in alpha1? + ext_model%p(IR_G1_A) = 0.38526d0 + ext_model%p(IR_G1_B) = -1.01251d0 + ext_model%p(IR_ALPHA1_A) = 1.68467d0 + ext_model%p(IR_ALPHA1_B) = 1.06099d0 ! Sign change + ext_model%p(IR_ALPHA2) = 0.78791d0 + ext_model%p(IR_LAMBDAB) = 4.30578d0 + ext_model%p(IR_DELTA) = 4.78338d0 + ext_model%p(IR_S1) = 0.06652d0 + ext_model%p(IR_LAMBDAO1) = 9.8434d0 + ext_model%p(IR_GAMMAO1) = 2.21205d0 + ext_model%p(IR_A1) = -0.24703d0 + ext_model%p(IR_S2) = 0.0267d0 + ext_model%p(IR_LAMBDAO2) = 19.258294d0 + ext_model%p(IR_GAMMAO2) = 17.0d0 + ext_model%p(IR_A2) = -0.27d0 + + nu_V = c/551d-9 + nu_B = c/445d-9 + call compute_dust_ext_linfit(nu_V, aV, bV) + call compute_dust_ext_linfit(nu_B, aB, bB) + !R = (1.d0-(bB-bV))/((aB-aV)-(bB-bV)/3.1d0) + R = 3.1d0 !(1.d0-bB)/(aB-bB/3.1d0) + !R = 6.0d0 !(1.d0-bB)/(aB-bB/3.1d0) +!!$ write(*,*) 'a, b, V = ', aV, bV +!!$ write(*,*) 'a, b, B = ', aB, bB +!!$ write(*,*) 'R = ', R + + end subroutine initialize_dust_extinction_mod + + subroutine get_dust_attenuation_map(nu, A_ext) + implicit none + real(dp), intent(in) :: nu + class(comm_map), intent(inout) :: A_ext + + integer(i4b) :: i + real(dp) :: f, a, b + real(sp), allocatable, dimension(:) :: EBV + + ! Get A_V = R*E(B-V) at correct resolution + if (A_ext%info%nside /= ext_model%nside) then + allocate(EBV(0:A_ext%info%npix-1)) + call udgrade_ring(ext_model%EBV(:,1), ext_model%nside, EBV, A_ext%info%nside) + A_ext%map(:,1) = R*EBV(A_ext%info%pix) + else + A_ext%map(:,1) = R*ext_model%EBV(A_ext%info%pix,1) + end if + + ! Convert to attenuation + call compute_dust_ext_linfit(nu, a, b) + f = a + b * (1d0/R - 1d0/3.1d0) + A_ext%map = exp(-A_ext%map*f/2.5d0) + +!!$ call A_ext%writeFITS('A.fits') +!!$ call mpi_finalize(i) +!!$ stop + end subroutine get_dust_attenuation_map + + subroutine get_dust_attenuation_pos(vec, nu, A_ext) + implicit none + real(dp), intent(in) :: vec(3) + real(dp), intent(in) :: nu + real(dp), intent(out) :: A_ext + + integer(i4b) :: i, pix + real(dp) :: A_V, a, b + + if (.not. allocated(ext_model%EBV)) then + A_ext = 1.d0 + return + end if + + call vec2pix_ring(ext_model%nside, vec, pix) + A_V = R * ext_model%EBV(pix,1) + call compute_dust_ext_linfit(nu, a, b) + A_ext = exp(-0.4d0 * A_V * (a + b * (1d0/R - 1d0/3.1d0))) + end subroutine get_dust_attenuation_pos + + + subroutine compute_dust_ext_linfit(nu, a, b) + implicit none + real(dp), intent(in) :: nu + real(dp), intent(out) :: a, b + + real(dp) :: lambda, lam0, lamb, a_uv, b_uv, a_opt, b_opt, a_ir, b_ir, x, D, W, Dm1, Dm2, z, g1, F, delta, gamma + + lambda = c/nu * 1d6 ! wavelength in micron + x = 1d0/lambda + D = x*x / ((x-ext_model%p(UV_X0))**2 + (x*ext_model%p(UV_GAMMA))**2) + + ! Compute basic linear coefficients for each range + if (lambda >= 0.091d0 .and. lambda < 0.33d0) then + ! Ultra-violet + F = 0.5392d0*(x-5.9d0)**2 + 0.05644d0*(x-5.9d0)**3 + a_uv = ext_model%p(UV_C1_A) + ext_model%p(UV_C2_A)*x + & + & ext_model%p(UV_C3_A)*D + ext_model%p(UV_C4_A)*F + b_uv = ext_model%p(UV_C1_B) + ext_model%p(UV_C2_B)*x + & + & ext_model%p(UV_C3_B)*D + ext_model%p(UV_C4_B)*F + end if + if (lambda >= 0.3d0 .and. lambda < 1.1d0) then + ! Optical + a_opt = ext_model%p(OPT_E0_A) + ext_model%p(OPT_E1_A)*x + & + & ext_model%p(OPT_E2_A)*x**2 + ext_model%p(OPT_E3_A)*x**3 + & + & ext_model%p(OPT_E4_A)*x**4 + & + & ext_model%p(OPT_F1_A)*D*ext_model%p(OPT_GAMMA1) + & + & ext_model%p(OPT_F2_A)*D*ext_model%p(OPT_GAMMA2) + & + & ext_model%p(OPT_F3_A)*D*ext_model%p(OPT_GAMMA3) + b_opt = ext_model%p(OPT_E0_B) + ext_model%p(OPT_E1_B)*x + & + & ext_model%p(OPT_E2_B)*x**2 + ext_model%p(OPT_E3_B)*x**3 + & + & ext_model%p(OPT_E4_B)*x**4 + & + & ext_model%p(OPT_F1_B)*D*ext_model%p(OPT_GAMMA1)**2 + & + & ext_model%p(OPT_F2_B)*D*ext_model%p(OPT_GAMMA2)**2 + & + & ext_model%p(OPT_F3_B)*D*ext_model%p(OPT_GAMMA3)**2 + end if + if (lambda >= 0.9d0 .and. lambda < 32d0) then + ! Infrared + lamb = ext_model%p(IR_LAMBDAB) + lam0 = ext_model%p(IR_LAMBDAO1) + delta = ext_model%p(IR_DELTA) + gamma = 2.d0*ext_model%p(IR_GAMMAO1)/(1.d0+exp(ext_model%p(IR_A1)*(lambda-lam0))) + Dm1 = (gamma/lam0)**2 / ((lambda/lam0-lam0/lambda)**2 + (gamma/lam0)**2) + lam0 = ext_model%p(IR_LAMBDAO2) + gamma = 2.d0*ext_model%p(IR_GAMMAO2)/(1.d0+exp(ext_model%p(IR_A2)*(lambda-lam0))) + Dm2 = (gamma/lam0)**2 / ((lambda/lam0-lam0/lambda)**2 + (gamma/lam0)**2) + W = get_W_smooth_step(lambda, lamb, delta) + g1 = ext_model%p(IR_G1_A) + a_ir = g1*lambda**(-ext_model%p(IR_ALPHA1_A))*(1.d0-W) + & + & g1*lamb**(ext_model%p(IR_ALPHA2)-ext_model%p(IR_ALPHA1_A)) * & + & lambda**(-ext_model%p(IR_ALPHA2)) * W + & + & ext_model%p(IR_S1)*Dm1 + ext_model%p(IR_S2)*Dm2 + b_ir = ext_model%p(IR_G1_B)*lambda**(-ext_model%p(IR_ALPHA1_B)) + end if + + ! Generate smooth function + if (lambda >= 0.091d0 .and. lambda < 0.30d0) then + a = a_uv + b = b_uv + else if (lambda >= 0.30d0 .and. lambda < 0.33d0) then + W = get_W_smooth_step(lambda, 0.315d0, 0.03d0) + a = (1.d0-W)*a_uv + W*a_opt + b = (1.d0-W)*b_uv + W*b_opt + else if (lambda >= 0.33d0 .and. lambda < 0.90d0) then + a = a_opt + b = b_opt + else if (lambda >= 0.90d0 .and. lambda < 1.1d0) then + W = get_W_smooth_step(lambda, 1.d0, 0.2d0) + a = (1.d0-W)*a_opt + W*a_ir + b = (1.d0-W)*b_opt + W*b_ir + else if (lambda >= 1.10d0 .and. lambda < 32d0) then + a = a_ir + b = b_ir + else + a = 0.d0 + b = 0.d0 + end if + end subroutine compute_dust_ext_linfit + + function get_W_smooth_step(lambda, lambda_b, delta) + implicit none + real(dp), intent(in) :: lambda, lambda_b, delta + real(dp) :: get_W_smooth_step + + real(dp) :: z + + z = (lambda - lambda_b + 0.5d0*delta)/delta + if (z >= 0.d0 .and. z <= 1.d0) then + get_W_smooth_step = 3.d0*z**2 -2.d0*z**3 + else + get_W_smooth_step = 0.d0 + end if + end function get_W_smooth_step + + function active_dust_ext_model(nu) + implicit none + real(dp), intent(in) :: nu + logical(lgt) :: active_dust_ext_model + + real(dp) :: lambda + + lambda = c/nu * 1d6 ! wavelength in microns + if (allocated(ext_model%EBV) .and. lambda >= 0.091d0 .and. lambda < 32.d0) then + active_dust_ext_model = .true. + else + active_dust_ext_model = .false. + end if + + end function active_dust_ext_model + +end module comm_dust_extinction_mod diff --git a/commander3/src/comm_mbbtab_comp_mod.f90 b/commander3/src/comm_mbbtab_comp_mod.f90 index ec2f1fbc9..b7e62e264 100644 --- a/commander3/src/comm_mbbtab_comp_mod.f90 +++ b/commander3/src/comm_mbbtab_comp_mod.f90 @@ -75,7 +75,7 @@ function constructor_mbbtab(cpar, id, id_abs) result(c) call c%initLmaxSpecind(cpar, id, id_abs) call c%initDiffuse(cpar, id, id_abs) - + ! Set up MBBtab type c%mbbtab_type = cpar%cs_mbbtab_type(id_abs) if (trim(c%mbbtab_type) == 'binned') then @@ -140,16 +140,16 @@ function constructor_mbbtab(cpar, id, id_abs) result(c) call c%initPixregSampling(cpar, id, id_abs) ! Init alm if (c%lmax_ind >= 0) call c%initSpecindProp(cpar, id, id_abs) - + ! Read SED table call c%read_SED_table(cpar%cs_SED_template(1,id_abs)) - + allocate(c%theta_steplen(2+c%ntab, cpar%mcmc_num_samp_groups)) c%theta_steplen = 0d0 ! Initialize SED priors c%SEDtab_prior = cpar%cs_SED_prior(id_abs) - + ! Initialize mixing matrix call c%updateMixmat diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index fb61efc71..b98a5fe56 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -280,6 +280,9 @@ module comm_param_mod real(dp), allocatable, dimension(:,:) :: cs_auxpar logical(lgt), allocatable, dimension(:) :: cs_apply_jeffreys + ! Exctinction parameters + character(len=2048) :: EBVmap + ! Zodi parameters integer(i4b) :: zs_ncomps, zs_num_samp_groups, zs_covar_first, zs_covar_last character(len=24) :: zs_phasefunc, zs_bandpass @@ -360,6 +363,11 @@ subroutine read_comm_params(cpar) call read_global_params_hash(htable,cpar) call read_data_params_hash(htable,cpar) call read_component_params_hash(htable,cpar) + + ! Read extinction parameters + call get_parameter_hashtable(htable, 'EXTINCTION_E(B-V)_MAP', par_string=cpar%EBVmap, path=.true.) + + ! Read zodi parameters if (cpar%include_tod_zodi) call read_zodi_params_hash(htable, cpar) !output parameter file to output directory diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 3e58acd39..bd2b9e0c5 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -20,6 +20,7 @@ !================================================================================ module comm_ptsrc_comp_mod use comm_F_mod + use comm_dust_extinction_mod implicit none private @@ -30,6 +31,7 @@ module comm_ptsrc_comp_mod !************************************************** type Tnu integer(i4b) :: nside, nside_febecop, np, nmaps + real(dp) :: A_ext ! Dust extinction, absolute attenuation integer(i4b), allocatable, dimension(:,:) :: pix ! Pixel list, both absolute and relative real(dp), allocatable, dimension(:,:) :: map ! (0:np-1,nmaps) real(dp), allocatable, dimension(:,:) :: F ! Mixing matrix (nmaps,ndet) @@ -276,6 +278,16 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) call read_sources(c, cpar, id, id_abs) end if + ! Initialize dust extinction correction + do j = 1, c%nsrc + do i = 1, numband + if (c%F_null(i)) cycle + ia = c%b2a(i) + call get_dust_attenuation_pos(c%src(j)%vec, data(i)%bp(0)%p%nu_c, c%src(j)%T(ia)%A_ext) + if(cpar%myid == 0) write(*,*) j, i, c%src(j)%T(ia)%A_ext + end do + end do + ! Update mixing matrix call update_status(status, "init_ptsrc3") call c%updateMixmat @@ -298,7 +310,7 @@ subroutine updateF(self, theta, beta, band, df, par) integer(i4b) :: i, ia, j, k ! if we have fixed precomputed amps, we don't change mixing matrix - if(self%precomputed_amps) return + !if(self%precomputed_amps) return do j = 1, self%nsrc @@ -319,25 +331,29 @@ subroutine updateF(self, theta, beta, band, df, par) do k = 0, data(i)%ndet ! Temperature - self%src(j)%T(ia)%F(1,k) = & - & self%F_int(1,ia,k)%p%eval(self%src(j)%theta(:,1)) * data(i)%gain * self%cg_scale + if(self%precomputed_amps) then + self%src(j)%T(ia)%F(1,k) = self%src(j)%amp_precomp(ia) * data(i)%gain * self%cg_scale * self%src(j)%T(ia)%A_ext + else + self%src(j)%T(ia)%F(1,k) = & + & self%F_int(1,ia,k)%p%eval(self%src(j)%theta(:,1)) * data(i)%gain * self%cg_scale * self%src(j)%T(ia)%A_ext + end if ! Polarization if (self%nmaps == 3) then ! Stokes Q - if (self%poltype(1) < 2) then + if (self%poltype(1) < 2 .or. self%precomputed_amps) then self%src(j)%T(ia)%F(2,k) = self%src(j)%T(ia)%F(1,k) else self%src(j)%T(ia)%F(2,k) = & - & self%F_int(2,ia,k)%p%eval(self%src(j)%theta(:,2)) * data(i)%gain * self%cg_scale + & self%F_int(2,ia,k)%p%eval(self%src(j)%theta(:,2)) * data(i)%gain * self%cg_scale * self%src(j)%T(ia)%A_ext end if ! Stokes U - if (self%poltype(1) < 3) then + if (self%poltype(1) < 3 .or. self%precomputed_amps) then self%src(j)%T(ia)%F(3,k) = self%src(j)%T(ia)%F(2,k) else self%src(j)%T(ia)%F(3,k) = & - & self%F_int(3,ia,k)%p%eval(self%src(j)%theta(:,3)) * data(i)%gain * self%cg_scale + & self%F_int(3,ia,k)%p%eval(self%src(j)%theta(:,3)) * data(i)%gain * self%cg_scale * self%src(j)%T(ia)%A_ext end if end if end do @@ -451,12 +467,12 @@ function evalPtsrcBand(self, band, amp_in, pix, alm_out, det) evalPtsrcBand = 0.d0 do i = 1, self%nsrc do j = 1, self%src(i)%T(band_active)%nmaps - if(self%precomputed_amps) then - ! so far just used for stars - m = self%src(i)%amp_precomp(band_active) * amp(i,j) * data(band)%gain - else +! if(self%precomputed_amps) then +! ! so far just used for stars +! m = self%src(i)%amp_precomp(band_active) * amp(i,j) * data(band)%gain +! else m = self%src(i)%T(band_active)%F(j,d) * amp(i,j) - end if +! end if ! Scale to correct frequency through multiplication with mixing matrix a = self%getScale(band,i,j) * m @@ -508,12 +524,12 @@ function projectPtsrcBand(self, band, map, alm_in, det) val = val + self%src(i)%T(band_active)%map(q,j) * map%map(p,j) end do - if(self%precomputed_amps) then - ! so far just used for stars - m = self%src(i)%amp_precomp(band_active) * data(band)%gain - else +! if(self%precomputed_amps) then +! ! so far just used for stars +! m = self%src(i)%amp_precomp(band_active) * data(band)%gain +! else m = self%src(i)%T(band_active)%F(j,d) - end if +! end if ! Scale to correct frequency through multiplication with mixing matrix val = self%getScale(band,i,j) * m * val @@ -1080,15 +1096,15 @@ subroutine read_star_catalogue(self, cpar, id, id_abs) call init_beam_templates(self, cpar, id, id_abs) ! Update mixing matrix -- HKE: GAIN IS MISSING - do i=1, self%nsrc - do j=1, numband !self%nactive - ja = self%b2a(j) - if (ja == -1) cycle - do k = 0, data(j)%ndet ! Only T for now - self%src(i)%T(ja)%F(1,k) = self%src(i)%amp_precomp(self%b2a(j)) - end do - end do - end do +!!$ do i=1, self%nsrc +!!$ do j=1, numband !self%nactive +!!$ ja = self%b2a(j) +!!$ if (ja == -1) cycle +!!$ do k = 0, data(j)%ndet ! Only T for now +!!$ self%src(i)%T(ja)%F(1,k) = self%src(i)%amp_precomp(self%b2a(j)) +!!$ end do +!!$ end do +!!$ end do end subroutine read_star_catalogue @@ -2190,7 +2206,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) if (p == 1 .and. data(l)%pol_only) cycle if (data(l)%bp(0)%p%nu_c < self%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > self%nu_max_ind(1)) cycle ! Compute mixing matrix - s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext do q = 1, self%src(k)%T(la)%np pix = self%src(k)%T(la)%pix(q,1) data(l)%res%map(pix,p) = data(l)%res%map(pix,p) + s*self%src(k)%T(la)%map(q,p) * a @@ -2250,7 +2266,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) la = self%b2a(l) if (p == 1 .and. data(l)%pol_only) cycle if (data(l)%bp(0)%p%nu_c < self%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > self%nu_max_ind(1)) cycle - s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext do q = 1, self%src(k)%T(la)%np pix = self%src(k)%T(la)%pix(q,1) data(l)%res%map(pix,p) = data(l)%res%map(pix,p) - a*s*self%src(k)%T(la)%map(q,p) @@ -2375,7 +2391,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) la = self%b2a(l) if (p == 1 .and. data(l)%pol_only) cycle if (data(l)%bp(0)%p%nu_c < self%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > self%nu_max_ind(1)) cycle - s = self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext a_curr(l) = self%getScale(l,k,p) * s * amp(k,p) !if (self%myid == 0) write(*,*) 'l numband', l, numband end do @@ -2404,7 +2420,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) ! Compute mixing matrix theta(j) = x(i) - s = self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext ! Compute predicted source amplitude for current band a = self%getScale(l,k,p) * s * amp(k,p) @@ -2493,7 +2509,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) if (self%F_null(l)) cycle la = self%b2a(l) ! Compute mixing matrix - s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext ! Compute likelihood by summing over pixels do q = 1, self%src(k)%T(la)%np @@ -2529,7 +2545,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) if (data(l)%bp(0)%p%nu_c < self%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > self%nu_max_ind(1)) cycle ! Compute mixing matrix - s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext ! Compute likelihood by summing over pixels do q = 1, self%src(k)%T(la)%np @@ -2591,7 +2607,7 @@ subroutine samplePtsrcSpecInd(self, cpar, handle, id, iter) if (p == 1 .and. data(l)%pol_only) cycle ! Compute mixing matrix - s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale + s = self%getScale(l,k,p) * self%F_int(p,la,0)%p%eval(theta) * data(l)%gain * self%cg_scale * self%src(k)%T(la)%A_ext ! Compute likelihood by summing over pixels do q = 1, self%src(k)%T(la)%np @@ -2668,7 +2684,7 @@ function lnL_ptsrc_total(p) if (data(l)%bp(0)%p%nu_c < c_lnL%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > c_lnL%nu_max_ind(1)) cycle ! Compute mixing matrix - s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale + s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale * c_lnL%src(k_lnL)%T(la)%A_ext ! Compute predicted source amplitude for current band a = c_lnL%getScale(l,k_lnL,p_lnL) * s * amp @@ -2708,7 +2724,7 @@ function grad_lnL_ptsrc_total(p) if (data(l)%bp(0)%p%nu_c < c_lnL%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > c_lnL%nu_max_ind(1)) cycle ! Compute mixing matrix - s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale + s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale * c_lnL%src(k_lnL)%T(la)%A_ext ! Compute predicted source amplitude for current band a = c_lnL%getScale(l,k_lnL,p_lnL) * s * amp @@ -2777,7 +2793,7 @@ function lnL_ptsrc_multi(p) if (data(l)%bp(0)%p%nu_c < c_lnL%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > c_lnL%nu_max_ind(1)) cycle ! Compute mixing matrix - s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale + s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale * c_lnL%src(k_lnL)%T(la)%A_ext ! Compute predicted source amplitude for current band a = c_lnL%getScale(l,k_lnL,p_lnL) * s * amp @@ -2875,9 +2891,10 @@ function lnL_ptsrc_multi_grad(p) if (data(l)%bp(0)%p%nu_c < c_lnL%nu_min_ind(1) .or. data(l)%bp(0)%p%nu_c > c_lnL%nu_max_ind(1)) cycle ! Compute mixing matrix - s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale + s = c_lnL%F_int(1,la,0)%p%eval(theta) * data(l)%gain * c_lnL%cg_scale * c_lnL%src(k_lnL)%T(la)%A_ext ! Compute predicted source amplitude for current band + ! HKE: Fix extinction correction below? a = c_lnL%getScale(l,k_lnL,p_lnL) * s * amp if (j .eq. 1) then a_grad = c_lnL%getScale(l,k_lnL,p_lnL) * s diff --git a/commander3/src/comm_utils.f90 b/commander3/src/comm_utils.f90 index 3523ea743..65ced8c75 100644 --- a/commander3/src/comm_utils.f90 +++ b/commander3/src/comm_utils.f90 @@ -46,8 +46,12 @@ module comm_utils interface median module procedure median_sp, median_dp - end interface - + end interface median + + interface read_map + module procedure read_map_dp, read_map_sp + end interface read_map + contains function median_dp(array) result(res) @@ -542,7 +546,7 @@ subroutine touch(file) !!$ end subroutine allocate_map - subroutine read_map(filename, map) + subroutine read_map_dp(filename, map) implicit none character(len=*), intent(in) :: filename @@ -567,7 +571,34 @@ subroutine read_map(filename, map) end do end if - end subroutine read_map + end subroutine read_map_dp + + subroutine read_map_sp(filename, map) + implicit none + + character(len=*), intent(in) :: filename + real(sp), dimension(0:,1:), intent(out) :: map + + integer(i4b) :: nside, nmaps, ordering, i, npix, nmaps_in, nside_in + integer(i8b) :: temp_i + + npix = size(map(:,1)) + nmaps = size(map(0,:)) + nside = nint(sqrt(real(npix,sp)/12.)) + + temp_i = getsize_fits(trim(filename), ordering=ordering, nside=nside_in, nmaps=nmaps_in) + if ((nmaps_in < nmaps) .or. (nside_in /= nside)) then + write(*,*) 'Incorrect nside or nmaps for file called ', trim(filename) + end if + + call input_map(filename, map, npix, nmaps, ignore_polcconv=.true.) + if (ordering == 2) then + do i = 1, nmaps + call convert_nest2ring(nside, map(:,i)) + end do + end if + + end subroutine read_map_sp ! Routine for initializing the monopole and dipoles subroutine initialize_mono_dipole(nside, pix, monopole, dipole) diff --git a/commander3/src/commander.f90 b/commander3/src/commander.f90 index 74936aac3..20f926440 100644 --- a/commander3/src/commander.f90 +++ b/commander3/src/commander.f90 @@ -23,6 +23,7 @@ program commander use comm_mh_specind_mod use comm_zodi_samp_mod use comm_sparse_mod + use comm_dust_extinction_mod implicit none integer(i4b) :: i, j, l, iargc, ierr, iter, stat, first_sample, samp_group, curr_samp, tod_freq, modfact @@ -43,7 +44,7 @@ program commander integer :: arg_indx real(dp), allocatable :: param_test(:) - real(dp) :: time_step + real(dp) :: time_step, lambda, A_ext(1) integer(i4b), dimension(2) :: bands_to_sample, bands_to_calibrate_against real(dp), allocatable :: theta(:), theta_new(:), theta_old(:), scale(:) @@ -99,6 +100,14 @@ program commander status%active = cpar%myid_chain == 0 !.false. call timer%start(TOT_RUNTIME); call timer%start(TOT_INIT) +!!$ call initialize_dust_extinction_mod(cpar) +!!$ do i = 1, 1000 +!!$ lambda = 0.09 + (i-1)/(1000-1.d0)*33.d0 +!!$ call get_dust_attenuation_pos([0.d0,1.d0,0.d0], [c/(lambda*1d-6)], A_ext) +!!$ end do +!!$ call mpi_finalize(ierr) +!!$ stop + !!! if (cpar%myid == cpar%root) then !!! allocate(param_test(200)) !!! param_test = 0.5d0 @@ -147,8 +156,9 @@ program commander end if call define_cg_samp_groups(cpar) - call initialize_bp_mod(cpar); call update_status(status, "init_bp") - call initialize_data_mod(cpar, handle); call update_status(status, "init_data") + call initialize_bp_mod(cpar); call update_status(status, "init_bp") + call initialize_dust_extinction_mod(cpar); call update_status(status, "init_ext") + call initialize_data_mod(cpar, handle); call update_status(status, "init_data") call initialize_inter_tod_params(cpar) From 30b02894b72e60e6e247cf6782902dd5a89315a4 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 19 May 2025 14:20:46 +0200 Subject: [PATCH 151/171] fixed version of n+2 mapmaking look for LFI --- commander3/src/comm_tod_gain_smod.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index b216476cb..0fa2cf512 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -1564,8 +1564,10 @@ module function psd_loglike(sigma_0, fknee, alpha, gain_ps, freqs) end if !lambda = 1e8 call calculate_invcov(sigma_0, alpha, fknee, freqs, inv_N_corr) - - psd_loglike = -sum(gain_ps(1:2000) * inv_N_corr(1:2000) - log(inv_N_corr(1:2000))) !- lambda*sigma_0 + + + !TODO: fix this hardcoding issue here + psd_loglike = -sum(gain_ps(2:2000) * inv_N_corr(2:2000) - log(inv_N_corr(2:2000))) !- lambda*sigma_0 !write(*,*) sigma_0, sum(gain_ps(2:) * inv_N_corr(2:) - log(inv_N_corr(2:)))!, lambda*sigma_0 end function psd_loglike From 7683715b38216fd72dde0a48b8eebb6fa8090fc9 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 19 May 2025 15:50:14 +0200 Subject: [PATCH 152/171] possible fix to python map reading issue --- commander3/src/comm_map_mod.f90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_map_mod.f90 b/commander3/src/comm_map_mod.f90 index f1857abe1..035c79540 100644 --- a/commander3/src/comm_map_mod.f90 +++ b/commander3/src/comm_map_mod.f90 @@ -1083,6 +1083,7 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, character(len=80), dimension(1:120) :: header character(len=16) :: unit_, ttype_ + character(len=8) :: headernum npix = size(map(:,1)) nside = nint(sqrt(real(npix,sp)/12.)) @@ -1149,7 +1150,7 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, call add_card(header,"TUNIT4", unit_//'^2',"Map unit") call add_card(header) - else + else if(nmaps <= 3) then call add_card(header) ! blank line call add_card(header,"TTYPE1", "I_"//ttype_,"Stokes I") call add_card(header,"TUNIT1", unit_,"Map unit") @@ -1164,6 +1165,13 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, call add_card(header,"TUNIT3", unit_,"Map unit") call add_card(header) endif + else !Something weird with a nonstandard number of maps, add dummy header + call add_card(header) + do i = 1, nmaps + write(headernum, *) i + call add_card(header, "TTYPE"//trim(headernum), "unknown"//trim(headernum), "Unknown datatype") + call add_card(header, "TUNIT"//trim(headernum), unit_, "Map Unit") + end do end if call add_card(header,"COMMENT","-----------------------------------------------") call add_card(header,"COMMENT"," Commander Keywords ") From c5ee5035a1cd19cee7a72eb72c4145e557969d3e Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 19 May 2025 15:51:16 +0200 Subject: [PATCH 153/171] possible running n+2 mapmaking with write file output --- commander3/src/comm_tod_mapmaking_mod.f90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_tod_mapmaking_mod.f90 b/commander3/src/comm_tod_mapmaking_mod.f90 index a5d40c3a7..fd629ca00 100644 --- a/commander3/src/comm_tod_mapmaking_mod.f90 +++ b/commander3/src/comm_tod_mapmaking_mod.f90 @@ -48,6 +48,7 @@ subroutine init_binmap(self, tod, shared, solve_S, nplus2) logical(lgt), optional, intent(in) :: nplus2 integer(i4b) :: i, ierr + class(comm_mapinfo), allocatable :: mapinfo_nplus2 call timer%start(TOD_ALLOC, tod%band) self%nobs = tod%nobs @@ -76,6 +77,9 @@ subroutine init_binmap(self, tod, shared, solve_S, nplus2) self%ncol = tod%nmaps - 1 self%n_A = 3*tod%ndet + 3 self%nout = tod%output_n_maps *tod%ndet + + mapinfo_nplus2 = comm_mapinfo(tod%info%comm, tod%info%nside, tod%info%lmax, 3, tod%info%pol) + else self%ncol = tod%nmaps self%n_A = tod%nmaps*(tod%nmaps+1)/2 @@ -84,7 +88,11 @@ subroutine init_binmap(self, tod, shared, solve_S, nplus2) !write(*,*) 'nout = ', tod%output_n_maps, self%nout allocate(self%outmaps(self%nout)) do i = 1, self%nout - self%outmaps(i)%p => comm_map(tod%info) + if(self%solve_nplus2)then + self%outmaps(i)%p => comm_map(mapinfo_nplus2) + else + self%outmaps(i)%p => comm_map(tod%info) + end if end do allocate(self%A_map(self%n_A,self%nobs), self%b_map(self%nout,self%ncol,self%nobs)) self%A_map = 0.d0; self%b_map = 0.d0 From 9344a9224d35117f49da41c35d490c8d71567434 Mon Sep 17 00:00:00 2001 From: Mathew Galloway Date: Mon, 19 May 2025 15:50:14 +0200 Subject: [PATCH 154/171] possible fix to python map reading issue --- commander3/src/comm_map_mod.f90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_map_mod.f90 b/commander3/src/comm_map_mod.f90 index 3a574bd2e..2bd9c8909 100644 --- a/commander3/src/comm_map_mod.f90 +++ b/commander3/src/comm_map_mod.f90 @@ -1028,6 +1028,7 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, character(len=80), dimension(1:120) :: header character(len=16) :: unit_, ttype_ + character(len=8) :: headernum npix = size(map(:,1)) nside = nint(sqrt(real(npix,sp)/12.)) @@ -1094,7 +1095,7 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, call add_card(header,"TUNIT4", unit_//'^2',"Map unit") call add_card(header) - else + else if(nmaps <= 3) then call add_card(header) ! blank line call add_card(header,"TTYPE1", "I_"//ttype_,"Stokes I") call add_card(header,"TUNIT1", unit_,"Map unit") @@ -1109,6 +1110,13 @@ subroutine write_map(filename, map, comptype, nu_ref, unit, ttype, spectrumfile, call add_card(header,"TUNIT3", unit_,"Map unit") call add_card(header) endif + else !Something weird with a nonstandard number of maps, add dummy header + call add_card(header) + do i = 1, nmaps + write(headernum, *) i + call add_card(header, "TTYPE"//trim(headernum), "unknown"//trim(headernum), "Unknown datatype") + call add_card(header, "TUNIT"//trim(headernum), unit_, "Map Unit") + end do end if call add_card(header,"COMMENT","-----------------------------------------------") call add_card(header,"COMMENT"," Commander Keywords ") From c2c1acd0905df48fb2d40f342592828a61564413 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Mon, 2 Jun 2025 22:56:22 +0200 Subject: [PATCH 155/171] Reverted compressed output; enabled detector gains --- .../defaults/bands/HFI/HFI_100_TOD.defaults | 23 +++--- commander3/src/comm_tod_hfi_smod.f90 | 20 +++--- commander3/src/comm_tod_mod.f90 | 72 ++++++++----------- 3 files changed, 50 insertions(+), 65 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults index b08a8c6d9..f7f2cd1c8 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults @@ -12,7 +12,7 @@ BAND_NOISE_UNIFORMIZE_FSKY&&& = 0.0 1 BAND_MASKFILE&&& = fullsky BAND_MASKFILE_CALIB&&& = mask_common_dx12_n1024_TQU.fits fullsky BAND_BEAMTYPE&&& = b_l # {b_l, febecop} -BAND_BEAM_B_L_FILE&&& = Bl_TEB_npipe6v19_100-ds2x100-ds2.fits +BAND_BEAM_B_L_FILE&&& = Bl_TEB_npipe6v19_100-ds2x100-ds2.fits BAND_BEAM_B_PTSRC_FILE&&& = none BAND_PIXEL_WINDOW&&& = pixel_window_n1024.fits BAND_SAMP_NOISE_AMP&&& = .false. @@ -43,7 +43,8 @@ BAND_TOD_END_SCANID&&& = 18300 #53724 BAND_TOD_TOT_NUMSCAN&&& = 18338 #53724 BAND_TOD_FLAG&&& = 0 BAND_TOD_ABSCAL_COMP&&& = full -BAND_TOD_DETECTOR_LIST&&& = 100-1a,100-1b,100-2a,100-2b,100-3a,100-3b,100-4a,100-4b +#BAND_TOD_DETECTOR_LIST&&& = 100-1a,100-1b,100-2a,100-2b,100-3a,100-3b,100-4a,100-4b +BAND_TOD_DETECTOR_LIST&&& = 100-1a,100-1b,100-4a,100-4b BAND_TOD_ORBITAL_ONLY_ABSCAL&&& =.false. BAND_TOD_INIT_FROM_HDF&&& = default @@ -59,22 +60,22 @@ BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none #TODO: make these paths into real defaults in the Oslo legacy archive -BAND_MAPFILE&&& = HFI_SkyMap_100-BPassCorrected-field-IQU_1024_R4.00_full.fits -BAND_NOISEFILE&&& = npipe6v20_100_wcov_1024.fits -BAND_REG_NOISEFILE&&& = npipe6v20_100_wcov_1024.fits -BAND_NOISE_RMS&&&_SMOOTH01 = npipe6v20_100_wcov_1024.fits -BAND_NOISE_RMS&&&_SMOOTH02 = npipe6v20_100_wcov_1024.fits -BAND_NOISE_RMS&&&_SMOOTH03 = npipe6v20_100_wcov_1024.fits +BAND_MAPFILE&&& = HFI_SkyMap_100-BPassCorrected_1024_R4.00_full.fits +BAND_NOISEFILE&&& = HFI_SkyMap_100-BPassCorrected_1024_R4.00_full_rms_uK.fits +BAND_REG_NOISEFILE&&& = none +BAND_NOISE_RMS&&&_SMOOTH01 = none +BAND_NOISE_RMS&&&_SMOOTH02 = none +BAND_NOISE_RMS&&&_SMOOTH03 = none BAND_BANDPASSFILE&&& = HFI_instrument_v3.h5 -BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_100_n2048_mask.fits -BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_100_n2048_mask.fits +BAND_TOD_MAIN_PROCMASK&&& = npipe6v20_100_n1024_mask.fits +BAND_TOD_SMALL_PROCMASK&&& = npipe6v20_100_n1024_mask.fits N_GIBBS_PER_TOD&&& = 1 BAND_TOD_RIMO&&& = HFI_instrument_v3.h5 BAND_TOD_FILELIST&&& = filelist_100.txt BAND_TOD_ZODI_SUBTRACTION&&& = .false. -BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n2048_TQU.fits +BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n1024_TQU.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. diff --git a/commander3/src/comm_tod_hfi_smod.f90 b/commander3/src/comm_tod_hfi_smod.f90 index 09d48ee99..c55c76f14 100644 --- a/commander3/src/comm_tod_hfi_smod.f90 +++ b/commander3/src/comm_tod_hfi_smod.f90 @@ -383,8 +383,8 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (sample_gain) then ! TODO: Also sample non-linear gain response here? call sample_calibration(self, 'abscal', handle, map_sky, m_gain, procmask2, procmask2) - !call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) - !call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) + call sample_calibration(self, 'relcal', handle, map_sky, m_gain, procmask, procmask2) + call sample_calibration(self, 'deltaG', handle, map_sky, m_gain, procmask, procmask2) end if @@ -470,7 +470,7 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (self%scanid(i) == 500) then open(58,file='res'//samptext//'.dat', recl=1024) do j = 1, sd%ntod - write(58,*) j, sd%tod(j,1), sd%n_corr(j,1), d_calib(1,j,1), d_calib(2,j,1), 1-(sd%flag(j,1)/maxval(sd%flag(:,1))) + write(58,*) j, sd%tod(j,1), sd%n_corr(j,1), d_calib(1,j,1), d_calib(2,j,1), 1-(sd%flag(j,1)/maxval(sd%flag(:,1))), self%psi(sd%psi(j,1,1))*RAD2DEG, self%psi(sd%psi(j,2,1))*RAD2DEG, self%psi(sd%psi(j,3,1))*RAD2DEG, self%psi(sd%psi(j,4,1))*RAD2DEG end do close(58) end if @@ -533,13 +533,13 @@ module subroutine process_HFI_tod(self, chaindir, chain, iter, handle, map_in, d if (self%output_n_maps > 2) call binmap%outmaps(3)%p%writeFITS(trim(prefix)//'ncorr'//trim(postfix)) if (self%output_n_maps > 3) call binmap%outmaps(4)%p%writeFITS(trim(prefix)//'bpcorr'//trim(postfix)) if (self%output_n_maps > 4) call binmap%outmaps(5)%p%writeFITS(trim(prefix)//'orb'//trim(postfix)) - if (self%output_n_maps > 5) call binmap%outmaps(6)%p%writeFITS(trim(prefix)//'sl'//trim(postfix)) - if (self%output_n_maps > 6) call binmap%outmaps(7)%p%writeFITS(trim(prefix)//'zodi'//trim(postfix)) - if (self%output_n_maps > 8 .and. self%subtract_zodi .and. output_zodi_comps) then - do i = 1, zodi_model%n_comps - call binmap%outmaps(8+i)%p%writeFITS(trim(prefix)//'zodi_'//trim(zodi_model%comp_labels(i))//trim(postfix)) - end do - endif +!!$ if (self%output_n_maps > 5) call binmap%outmaps(6)%p%writeFITS(trim(prefix)//'sl'//trim(postfix)) +!!$ if (self%output_n_maps > 6) call binmap%outmaps(7)%p%writeFITS(trim(prefix)//'zodi'//trim(postfix)) +!!$ if (self%output_n_maps > 8 .and. self%subtract_zodi .and. output_zodi_comps) then +!!$ do i = 1, zodi_model%n_comps +!!$ call binmap%outmaps(8+i)%p%writeFITS(trim(prefix)//'zodi_'//trim(zodi_model%comp_labels(i))//trim(postfix)) +!!$ end do +!!$ endif ! Clean up call binmap%dealloc() diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 9a579f3ad..7b217d348 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -1622,7 +1622,6 @@ subroutine get_scan_ids(self, filelist) end subroutine get_scan_ids - subroutine dumpToHDF(self, chainfile, iter, map, rms) implicit none class(comm_tod), intent(inout) :: self @@ -1634,17 +1633,13 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) real(dp) :: mu character(len=6) :: itext character(len=512) :: path - real(dp), allocatable, dimension(:,:,:) :: output, condensed_output - real(dp), allocatable, dimension(:) :: mjds, condensed_mjds + real(dp), allocatable, dimension(:,:,:) :: output + real(dp), allocatable, dimension(:) :: mjds npar = 3+self%n_xi if (self%baseline_order >= 0) npar = npar + self%baseline_order + 1 - allocate(output(self%last_scan,self%ndet,npar+1)) - allocate( mjds(self%last_scan)) - - allocate(condensed_output(self%nscan_tot, self%ndet,npar+1)) - allocate(condensed_mjds(self%nscan_tot)) - + allocate(output(self%nscan_tot,self%ndet,npar)) + allocate( mjds(self%nscan_tot)) ! Collect all parameters output = 0.d0 @@ -1652,13 +1647,12 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) do j = 1, self%ndet do i = 1, self%nscan k = self%scanid(i) - output(k,j,1) = k - output(k,j,2) = self%scans(i)%d(j)%gain - output(k,j,3) = merge(1.d0,0.d0,self%scans(i)%d(j)%accept) - output(k,j,4) = self%scans(i)%d(j)%chisq - output(k,j,5:4+self%n_xi) = self%scans(i)%d(j)%N_psd%xi_n + output(k,j,1) = self%scans(i)%d(j)%gain + output(k,j,2) = merge(1.d0,0.d0,self%scans(i)%d(j)%accept) + output(k,j,3) = self%scans(i)%d(j)%chisq + output(k,j,4:3+self%n_xi) = self%scans(i)%d(j)%N_psd%xi_n if (self%baseline_order >= 0) then - output(k,j,5+self%n_xi:npar+1) = self%scans(i)%d(j)%baseline + output(k,j,4+self%n_xi:npar) = self%scans(i)%d(j)%baseline end if if (j == 1) then mjds(k) = self%scans(i)%t0(1) @@ -1706,17 +1700,6 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) end do end do - ! cut missing scan ids from output and mjd before we write it to disk - j = 1 - do i = 1, self%last_scan - if(mjds(i) > 0) then !this scanid exists - condensed_output(j,:,:) = output(i,:,:) - condensed_mjds(j) = mjds(i) - j = j+1 - end if - end do - - !!$ do j = 1, self%ndet !!$ do i = 1, 4 !!$ mu = sum(output(:,j,i)) / count(output(:,j,i) /= 0.d0) @@ -1730,12 +1713,11 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) path = trim(adjustl(itext))//'/tod/'//trim(adjustl(self%freq))//'/' !write(*,*) 'path', trim(path) call create_hdf_group(chainfile, trim(adjustl(path))) - call write_hdf(chainfile, trim(adjustl(path))//'scanid', condensed_output(:,:,1)) - call write_hdf(chainfile, trim(adjustl(path))//'gain', condensed_output(:,:,2)) - call write_hdf(chainfile, trim(adjustl(path))//'accept', condensed_output(:,:,3)) - call write_hdf(chainfile, trim(adjustl(path))//'chisq', condensed_output(:,:,4)) - call write_hdf(chainfile, trim(adjustl(path))//'xi_n', condensed_output(:,:,5:4+self%n_xi)) - call write_hdf(chainfile, trim(adjustl(path))//'MJD', condensed_mjds) + call write_hdf(chainfile, trim(adjustl(path))//'gain', output(:,:,1)) + call write_hdf(chainfile, trim(adjustl(path))//'accept', output(:,:,2)) + call write_hdf(chainfile, trim(adjustl(path))//'chisq', output(:,:,3)) + call write_hdf(chainfile, trim(adjustl(path))//'xi_n', output(:,:,4:3+self%n_xi)) + call write_hdf(chainfile, trim(adjustl(path))//'MJD', mjds) if (self%baseline_order >= 0) call write_hdf(chainfile, trim(adjustl(path))//'baseline', output(:,:,4+self%n_xi:npar)) call write_hdf(chainfile, trim(adjustl(path))//'polang', self%polang) call write_hdf(chainfile, trim(adjustl(path))//'gain0', self%gain0) @@ -1754,10 +1736,12 @@ subroutine dumpToHDF(self, chainfile, iter, map, rms) ! Write instrument-specific parameters call self%dumpToHDF_inst(chainfile, path) - deallocate(output, mjds, condensed_output, condensed_mjds) + deallocate(output, mjds) end subroutine dumpToHDF + + subroutine initHDF(self, chainfile, iter, map, rms) implicit none class(comm_tod), intent(inout) :: self @@ -3340,17 +3324,17 @@ subroutine create_dynamic_mask(self, scan, det, pix, tod, res, mask, flag, thres ncut = 0 if (output_scan == self%scanid(scan)) open(58, file='flag_stage2.dat') do iter = 1, 1 - ! Compute full-scan, masked rms0 - rms0 = 0.d0 - n = 0 - do i = 1, ntod - if (mask(i) == 1.) then - rms0 = rms0 + res(i)**2 - n = n + 1 - end if - end do - rms0 = sqrt(rms0/(n-1)) - !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 +!!$ ! Compute full-scan, masked rms0 +!!$ rms0 = 0.d0 +!!$ n = 0 +!!$ do i = 1, ntod +!!$ if (mask(i) == 1.) then +!!$ rms0 = rms0 + res(i)**2 +!!$ n = n + 1 +!!$ end if +!!$ end do +!!$ rms0 = 0.; if (n > 1) rms0 = sqrt(rms0/(n-1)) +!!$ !write(*,*) 'iter = ', iter, ' -- rms0 = ', rms0 do i = 1, ntod cut(i) = (mask(i) == 1. .and. abs(res(i)) > threshold(3)) From 46a9649e9807647d8c787f81946f30fc58d1168a Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Tue, 17 Jun 2025 10:02:06 +0200 Subject: [PATCH 156/171] Add owls 42-46 and owl 38 to cmake --- install_ita.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install_ita.sh b/install_ita.sh index 9bf467a6a..a52ba6f37 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -20,6 +20,8 @@ owl2528="$prefix+(2[5-8])+$suffix" owl2930="$prefix+(29|30)+$suffix" owl3135="$prefix+(3[1-5])+$suffix" owl3637="$prefix+(3[6-7])+$suffix" +owl38="$prefix+(38)+$suffix" +owl4246="$prefix+(4[2-6])+$suffix" # Using regex to figure out which beehive I am on. prefix="beehive" bee0123="$prefix+(\d{0}|[1-9](?!\d)|1[0-9]|2[0-3])+$suffix" @@ -94,6 +96,10 @@ then build_dir="build_owl3135_${toolchain}_${buildtype}" elif [[ "${HOSTNAME}" =~ $owl3637 ]]; then build_dir="build_owl3637_${toolchain}_${buildtype}" + elif [[ "${HOSTNAME}" =~ $owl4246 ]]; then + build_dir="build_owl4246_${toolchain}_${buildtype}" + elif [[ "${HOSTNAME}" =~ $owl38 ]]; then + build_dir="build_owl38_${toolchain}_${buildtype}" elif [[ "${HOSTNAME}" =~ $bee0123 ]]; then build_dir="build_bee0123_${toolchain}_${buildtype}" elif [[ "${HOSTNAME}" =~ $bee2631 ]]; then From 6cb7336d53042e651b8a9855536a1384c6d90b7a Mon Sep 17 00:00:00 2001 From: Raelyn Sullivan Date: Tue, 17 Jun 2025 10:37:12 +0200 Subject: [PATCH 157/171] Fix merge conflics --- commander3/src/comm_line_comp_mod.f90 | 348 +------------------------- 1 file changed, 1 insertion(+), 347 deletions(-) diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index 0c267796c..65f4f1f26 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -19,7 +19,6 @@ ! !================================================================================ module comm_line_comp_mod -<<<<<< precond use comm_comp_interface_mod implicit none @@ -357,347 +356,6 @@ subroutine sampleLineRatios(self, cpar, handle, id, iter) end subroutine sampleLineRatios -end module comm_line_comp_mod -====== - use comm_comp_interface_mod - implicit none - - private - public comm_line_comp - - !************************************************** - ! Line emission component - !************************************************** - type, extends (comm_diffuse_comp) :: comm_line_comp - integer(i4b) :: ref_band - real(dp) :: line2RJ_ref - integer(i4b), allocatable, dimension(:) :: ind2band - real(dp), allocatable, dimension(:) :: line2RJ - contains - procedure :: S => evalSED_line - procedure :: sampleSpecInd => sampleLineRatios - procedure :: updateMixmat => updateMixmatLineRatios - end type comm_line_comp - - interface comm_line_comp - procedure constructor_line - end interface comm_line_comp - - contains - - !************************************************** - ! Routine definitions - !************************************************** - function constructor_line(cpar, id, id_abs) result(c) - implicit none - type(comm_params), intent(in) :: cpar - integer(i4b), intent(in) :: id, id_abs - class(comm_line_comp), pointer :: c - - integer(i4b) :: i, j, k, l, m, nline, b, n, ierr - real(dp) :: f - logical(lgt) :: ref_exist - character(len=512), allocatable, dimension(:) :: label - real(dp), allocatable, dimension(:) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:) :: poltype - type(comm_mapinfo), pointer :: info - - ! General parameters - allocate(c) - c%npar = 0 !temporary value so that lmax_ind is correcty set (to 0) in initDiffuse - call c%initDiffuse(cpar, id, id_abs) - - ! Read line template file - call read_line_template(trim(cpar%cs_SED_template(1,id_abs)), & - & nline, label, mu, sigma, line2RJ, poltype) - - ! Check how many lines are included in current run - n = 0 - ref_exist = .false. - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) n = n+1 - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) ref_exist = .true. - end do - if (.not. ref_exist) call report_error("Line component reference band does not exist, need "//trim(cpar%cs_band_ref(id_abs))) - - allocate(c%ind2band(n)) - c%npar = n - - allocate(c%lmax_ind_pol(3,c%npar)) - c%lmax_ind_pol = 0 !always fullsky (lmax=0) for line component - if (allocated(c%lmax_ind_mix)) deallocate(c%lmax_ind_mix) - allocate(c%lmax_ind_mix(3,c%npar)) - c%lmax_ind_mix = 0 !always fullsky (lmax=0) for line component - allocate(c%pol_pixreg_type(3,c%npar)) - c%pol_pixreg_type = 0 - - allocate(c%theta_def(n), c%p_gauss(2,n), c%p_uni(2,n)) - allocate(c%poltype(n), c%indlabel(n), c%line2RJ(n)) - n = 0 - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) then - n = n+1 - c%ind2band(n) = i - c%theta_def(n) = mu(j) - c%p_gauss(1,n) = mu(j) - c%p_gauss(2,n) = sigma(j) - c%p_uni(1,n) = -100.d30 !mu(j)-5*sigma(j) - c%p_uni(2,n) = 100.d30 !mu(j)+5*sigma(j) - c%poltype(n) = poltype(j) - c%indlabel(n) = label(j) - c%line2RJ(n) = line2RJ(j) - exit - end if - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) then - c%ref_band = i - c%line2RJ_ref = c%line2RJ(n) - end if - end do - - ! Update reference band unit conversion - do i = 1, c%x%info%nmaps - c%RJ2unit_(i) = 1.d0 / c%line2RJ_ref - c%x%map(:,i) = c%x%map(:,i) / c%RJ2unit_(i) - c%x%alm(:,i) = c%x%alm(:,i) / c%RJ2unit_(i) - end do - - ! Initialize spectral index maps - info => comm_mapinfo(cpar%comm_chain, c%nside, c%lmax_ind, & - & c%nmaps, c%pol) - - allocate(c%theta(n)) - do i = 1, n - c%theta(i)%p => comm_map(info) - c%theta(i)%p%map = c%theta_def(i) - if (c%lmax_ind >= 0) call c%theta(i)%p%YtW_scalar - end do - - - ! Precompute mixmat integrator for each band - allocate(c%F_int(3,numband,0:c%ndet)) - j = 1 - do l = 1, 3 - do i = 1, numband - if (l > 1) then - do m = 0,c%ndet - c%F_int(l,i,m)%p => c%F_int(l-1,i,m)%p - end do - cycle - end if - if (any(c%ind2band == i)) then - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & - & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) - end do - j = j+1 - else - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .false., 0.d0, j) - end do - end if - end do - end do - - ! Initialize mixing matrix - if (trim(cpar%init_chain_prefix) == 'none' & - & .or. trim(c%init_from_HDF) == 'none') & - & call c%updateMixmat - - deallocate(label, mu, sigma, line2RJ, poltype) - - end function constructor_line - - ! Definition: - ! SED = delta_{band, - function evalSED_line(self, nu, band, pol, theta) - class(comm_line_comp), intent(in) :: self - real(dp), intent(in), optional :: nu - integer(i4b), intent(in), optional :: band - integer(i4b), intent(in), optional :: pol - real(dp), dimension(1:), intent(in), optional :: theta - real(dp) :: evalSED_line - - integer(i4b) :: i, ind - - if (band == self%ref_band) then - evalSED_line = 1.d0 - else - do i = 1, self%npar - if (band == self%ind2band(i)) exit - end do - if (i > self%npar) then - evalSED_line = 0.d0 - else - evalSED_line = theta(i) * self%line2RJ(i) / self%line2RJ_ref - end if - end if - - end function evalSED_line - - subroutine read_line_template(filename, nline, label, mu, sigma, line2RJ, poltype) - implicit none - character(len=*), intent(in) :: filename - integer(i4b), intent(out) :: nline - character(len=512), allocatable, dimension(:), intent(out) :: label - real(dp), allocatable, dimension(:), intent(out) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:), intent(out) :: poltype - - integer(i4b) :: i, unit - character(len=1024) :: line - - unit = getlun() - - ! Find number of lines - nline = 0 - open(unit, file=trim(filename), recl=1024) - do while (.true.) - read(unit,'(a)', end=1) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - end do - 1 close(unit) - - allocate(label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline)) - open(unit, file=trim(filename), recl=1024) - nline = 0 - do while (.true.) - read(unit,'(a)', end=2) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - read(line,*) label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline) - end do - 2 close(unit) - - end subroutine read_line_template - - ! Sample line ratios - subroutine sampleLineRatios(self, cpar, handle, id, iter) - implicit none - class(comm_line_comp), intent(inout) :: self - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: id - integer(i4b), intent(in) :: iter !Gibbs iteration - - integer(i4b) :: i, j, l, n, m, band, ierr - real(dp) :: A, b, mu, sigma, par, sigma_p, scale, w - class(comm_map), pointer :: invN_amp, amp - character(len=2) :: id_text - - band = self%ind2band(id) - !if (band == self%ref_band) return - - - ! Compute likelihood term - w = self%theta(id)%p%map(1,1) - amp => comm_map(data(band)%info) - invN_amp => comm_map(data(band)%info) - amp%map = self%getBand(band)/w - invN_amp%map = amp%map - call data(band)%N%invN(invN_amp) ! Inverse noise variance weighted amplitude map - - !!$ call int2string(id, id_text) - !!$ call mask%writeFITS('co_mask'//id_text//'.fits') - !!$ call amp%writeFITS('co_amp'//id_text//'.fits') - !!$ call data(band)%res%writeFITS('co_res'//id_text//'.fits') - !!$ call data(band)%N%invN_diag%writeFITS('co_invN'//id_text//'.fits') - - ! Reduce across processors - if (associated(self%indmask(band)%p)) then - A = sum(invN_amp%map * self%indmask(band)%p%map * amp%map) - b = sum(invN_amp%map * self%indmask(band)%p%map * data(band)%res%map) - else - A = sum(invN_amp%map * amp%map) - b = sum(invN_amp%map * data(band)%res%map) - end if - call mpi_allreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - call mpi_allreduce(MPI_IN_PLACE, b, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - - call amp%dealloc(); deallocate(amp) - call invN_amp%dealloc(); deallocate(invN_amp) - - ! Compute new line ratio; just root processor - if (self%x%info%myid == 0) then - - if (A > 0.d0) then - mu = b / A - sigma = sqrt(1.d0 / A) - else if (self%p_gauss(2,id) > 0.d0) then - mu = 0.d0 - sigma = 1.d30 - else - mu = self%p_uni(1,id) + (self%p_uni(2,id)-self%p_uni(1,id))*rand_uni(handle) - sigma = 0.d0 - end if - - ! Add prior - if (self%p_gauss(2,id) > 0.d0) then - sigma_p = self%p_gauss(2,id) !/ sqrt(real(npix_reg,dp)) - mu = (mu*sigma_p**2 + self%p_gauss(1,id) * sigma**2) / (sigma_p**2 + sigma**2) - sigma = sqrt(sigma**2 * sigma_p**2 / (sigma**2 + sigma_p**2)) - end if - - ! Draw sample - par = -1.d300 - if (trim(self%operation) == 'optimize') then - if (mu < self%p_uni(1,id)) then - par = self%p_uni(1,id) - else if (mu > self%p_uni(2,id)) then - par = self%p_uni(2,id) - else - par = mu - end if - else - do while (par < self%p_uni(1,id) .or. par > self%p_uni(2,id)) - if (mu < self%p_uni(1,id)) then - par = rand_trunc_gauss(handle, mu, self%p_uni(1,id), sigma) - else if (mu > self%p_uni(2,id)) then - par = 2.d0*mu-rand_trunc_gauss(handle, mu, 2.d0*mu-self%p_uni(2,id), sigma) - else - par = mu + sigma * rand_gauss(handle) - end if - end do - end if - - if (band == self%ref_band) then - write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' - else - write(*,*) ' Line ratio i = ', id, ' = ', par - end if - end if - - ! Distribute new relative line ratio, and update - call mpi_bcast(par, 1, MPI_DOUBLE_PRECISION, 0, self%x%info%comm, ierr) - - if (band == self%ref_band) then - self%x%map = self%x%map * par ! Rescale amplitude map, but leave mixing matrix - self%x%alm = self%x%alm * par - do i = 1, self%npar ! Rescale line ratios at other frequencies - if (self%ind2band(i) == self%ref_band) cycle - self%theta(i)%p%map = self%theta(i)%p%map / par - if (self%lmax_ind >= 0) then - self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) / par - end if - end do - else - self%theta(id)%p%map = par - if (self%lmax_ind >= 0) then - self%theta(id)%p%alm(:,1) = par * sqrt(4.d0*pi) - end if - end if - call self%updateMixmat() - - end subroutine sampleLineRatios - - ! update the mixing matrix, assumes only temperature and constant across the whole map subroutine updateMixmatLineRatios(self, theta, beta, band, df, par) @@ -818,10 +476,6 @@ subroutine updateMixmatLineRatios(self, theta, beta, band, df, par) end subroutine updateMixmatLineRatios - - end module comm_line_comp_mod - - ->>>>>> devel + From 33ab34b4c3e7556df8a41fa1bda64bb7620ae843 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 23 Jun 2025 12:30:26 +0200 Subject: [PATCH 158/171] Fixed http error with wget --- cmake/sources.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/sources.cmake b/cmake/sources.cmake index 13adc538d..86983c30c 100644 --- a/cmake/sources.cmake +++ b/cmake/sources.cmake @@ -80,7 +80,7 @@ set(blas_md5 "5cd5df5a1541ad414f5874aaae17730f") # FFTW #------------------------------------------------------------------------------ #set(fftw_url "http://fftw.org/fftw-3.3.8.tar.gz") -set(fftw_url "http://fftw.org/fftw-3.3.9.tar.gz") +set(fftw_url "https://fftw.org/fftw-3.3.9.tar.gz") #set(fftw_md5 "8aac833c943d8e90d51b697b27d4384d") set(fftw_md5 "50145bb68a8510b5d77605f11cadf8dc") #------------------------------------------------------------------------------ @@ -104,7 +104,11 @@ set(hdf5_md5 "9e22217d22eb568e09f0cc15fb641d7c") #------------------------------------------------------------------------------ #set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz") #set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.49.tar.gz") -set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.0.0.tar.gz") +set(cfitsio_url "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.0.0.tar.gz") +#set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.6.2.tar.gz") +# See https://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html for latest +# versions + #------------------------------------------------------------------------------ # HEALPix #------------------------------------------------------------------------------ From 50f32788f4f0a01e1b7714c0593c947804038598 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 23 Jun 2025 13:06:32 +0200 Subject: [PATCH 159/171] Fixed merge issue --- commander3/src/comm_line_comp_mod.f90 | 468 -------------------------- 1 file changed, 468 deletions(-) diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index 0c267796c..f2e9bb6f0 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -19,7 +19,6 @@ ! !================================================================================ module comm_line_comp_mod -<<<<<< precond use comm_comp_interface_mod implicit none @@ -358,470 +357,3 @@ subroutine sampleLineRatios(self, cpar, handle, id, iter) end subroutine sampleLineRatios end module comm_line_comp_mod -====== - use comm_comp_interface_mod - implicit none - - private - public comm_line_comp - - !************************************************** - ! Line emission component - !************************************************** - type, extends (comm_diffuse_comp) :: comm_line_comp - integer(i4b) :: ref_band - real(dp) :: line2RJ_ref - integer(i4b), allocatable, dimension(:) :: ind2band - real(dp), allocatable, dimension(:) :: line2RJ - contains - procedure :: S => evalSED_line - procedure :: sampleSpecInd => sampleLineRatios - procedure :: updateMixmat => updateMixmatLineRatios - end type comm_line_comp - - interface comm_line_comp - procedure constructor_line - end interface comm_line_comp - - contains - - !************************************************** - ! Routine definitions - !************************************************** - function constructor_line(cpar, id, id_abs) result(c) - implicit none - type(comm_params), intent(in) :: cpar - integer(i4b), intent(in) :: id, id_abs - class(comm_line_comp), pointer :: c - - integer(i4b) :: i, j, k, l, m, nline, b, n, ierr - real(dp) :: f - logical(lgt) :: ref_exist - character(len=512), allocatable, dimension(:) :: label - real(dp), allocatable, dimension(:) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:) :: poltype - type(comm_mapinfo), pointer :: info - - ! General parameters - allocate(c) - c%npar = 0 !temporary value so that lmax_ind is correcty set (to 0) in initDiffuse - call c%initDiffuse(cpar, id, id_abs) - - ! Read line template file - call read_line_template(trim(cpar%cs_SED_template(1,id_abs)), & - & nline, label, mu, sigma, line2RJ, poltype) - - ! Check how many lines are included in current run - n = 0 - ref_exist = .false. - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) n = n+1 - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) ref_exist = .true. - end do - if (.not. ref_exist) call report_error("Line component reference band does not exist, need "//trim(cpar%cs_band_ref(id_abs))) - - allocate(c%ind2band(n)) - c%npar = n - - allocate(c%lmax_ind_pol(3,c%npar)) - c%lmax_ind_pol = 0 !always fullsky (lmax=0) for line component - if (allocated(c%lmax_ind_mix)) deallocate(c%lmax_ind_mix) - allocate(c%lmax_ind_mix(3,c%npar)) - c%lmax_ind_mix = 0 !always fullsky (lmax=0) for line component - allocate(c%pol_pixreg_type(3,c%npar)) - c%pol_pixreg_type = 0 - - allocate(c%theta_def(n), c%p_gauss(2,n), c%p_uni(2,n)) - allocate(c%poltype(n), c%indlabel(n), c%line2RJ(n)) - n = 0 - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) then - n = n+1 - c%ind2band(n) = i - c%theta_def(n) = mu(j) - c%p_gauss(1,n) = mu(j) - c%p_gauss(2,n) = sigma(j) - c%p_uni(1,n) = -100.d30 !mu(j)-5*sigma(j) - c%p_uni(2,n) = 100.d30 !mu(j)+5*sigma(j) - c%poltype(n) = poltype(j) - c%indlabel(n) = label(j) - c%line2RJ(n) = line2RJ(j) - exit - end if - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) then - c%ref_band = i - c%line2RJ_ref = c%line2RJ(n) - end if - end do - - ! Update reference band unit conversion - do i = 1, c%x%info%nmaps - c%RJ2unit_(i) = 1.d0 / c%line2RJ_ref - c%x%map(:,i) = c%x%map(:,i) / c%RJ2unit_(i) - c%x%alm(:,i) = c%x%alm(:,i) / c%RJ2unit_(i) - end do - - ! Initialize spectral index maps - info => comm_mapinfo(cpar%comm_chain, c%nside, c%lmax_ind, & - & c%nmaps, c%pol) - - allocate(c%theta(n)) - do i = 1, n - c%theta(i)%p => comm_map(info) - c%theta(i)%p%map = c%theta_def(i) - if (c%lmax_ind >= 0) call c%theta(i)%p%YtW_scalar - end do - - - ! Precompute mixmat integrator for each band - allocate(c%F_int(3,numband,0:c%ndet)) - j = 1 - do l = 1, 3 - do i = 1, numband - if (l > 1) then - do m = 0,c%ndet - c%F_int(l,i,m)%p => c%F_int(l-1,i,m)%p - end do - cycle - end if - if (any(c%ind2band == i)) then - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & - & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) - end do - j = j+1 - else - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .false., 0.d0, j) - end do - end if - end do - end do - - ! Initialize mixing matrix - if (trim(cpar%init_chain_prefix) == 'none' & - & .or. trim(c%init_from_HDF) == 'none') & - & call c%updateMixmat - - deallocate(label, mu, sigma, line2RJ, poltype) - - end function constructor_line - - ! Definition: - ! SED = delta_{band, - function evalSED_line(self, nu, band, pol, theta) - class(comm_line_comp), intent(in) :: self - real(dp), intent(in), optional :: nu - integer(i4b), intent(in), optional :: band - integer(i4b), intent(in), optional :: pol - real(dp), dimension(1:), intent(in), optional :: theta - real(dp) :: evalSED_line - - integer(i4b) :: i, ind - - if (band == self%ref_band) then - evalSED_line = 1.d0 - else - do i = 1, self%npar - if (band == self%ind2band(i)) exit - end do - if (i > self%npar) then - evalSED_line = 0.d0 - else - evalSED_line = theta(i) * self%line2RJ(i) / self%line2RJ_ref - end if - end if - - end function evalSED_line - - subroutine read_line_template(filename, nline, label, mu, sigma, line2RJ, poltype) - implicit none - character(len=*), intent(in) :: filename - integer(i4b), intent(out) :: nline - character(len=512), allocatable, dimension(:), intent(out) :: label - real(dp), allocatable, dimension(:), intent(out) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:), intent(out) :: poltype - - integer(i4b) :: i, unit - character(len=1024) :: line - - unit = getlun() - - ! Find number of lines - nline = 0 - open(unit, file=trim(filename), recl=1024) - do while (.true.) - read(unit,'(a)', end=1) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - end do - 1 close(unit) - - allocate(label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline)) - open(unit, file=trim(filename), recl=1024) - nline = 0 - do while (.true.) - read(unit,'(a)', end=2) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - read(line,*) label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline) - end do - 2 close(unit) - - end subroutine read_line_template - - ! Sample line ratios - subroutine sampleLineRatios(self, cpar, handle, id, iter) - implicit none - class(comm_line_comp), intent(inout) :: self - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: id - integer(i4b), intent(in) :: iter !Gibbs iteration - - integer(i4b) :: i, j, l, n, m, band, ierr - real(dp) :: A, b, mu, sigma, par, sigma_p, scale, w - class(comm_map), pointer :: invN_amp, amp - character(len=2) :: id_text - - band = self%ind2band(id) - !if (band == self%ref_band) return - - - ! Compute likelihood term - w = self%theta(id)%p%map(1,1) - amp => comm_map(data(band)%info) - invN_amp => comm_map(data(band)%info) - amp%map = self%getBand(band)/w - invN_amp%map = amp%map - call data(band)%N%invN(invN_amp) ! Inverse noise variance weighted amplitude map - - !!$ call int2string(id, id_text) - !!$ call mask%writeFITS('co_mask'//id_text//'.fits') - !!$ call amp%writeFITS('co_amp'//id_text//'.fits') - !!$ call data(band)%res%writeFITS('co_res'//id_text//'.fits') - !!$ call data(band)%N%invN_diag%writeFITS('co_invN'//id_text//'.fits') - - ! Reduce across processors - if (associated(self%indmask(band)%p)) then - A = sum(invN_amp%map * self%indmask(band)%p%map * amp%map) - b = sum(invN_amp%map * self%indmask(band)%p%map * data(band)%res%map) - else - A = sum(invN_amp%map * amp%map) - b = sum(invN_amp%map * data(band)%res%map) - end if - call mpi_allreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - call mpi_allreduce(MPI_IN_PLACE, b, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - - call amp%dealloc(); deallocate(amp) - call invN_amp%dealloc(); deallocate(invN_amp) - - ! Compute new line ratio; just root processor - if (self%x%info%myid == 0) then - - if (A > 0.d0) then - mu = b / A - sigma = sqrt(1.d0 / A) - else if (self%p_gauss(2,id) > 0.d0) then - mu = 0.d0 - sigma = 1.d30 - else - mu = self%p_uni(1,id) + (self%p_uni(2,id)-self%p_uni(1,id))*rand_uni(handle) - sigma = 0.d0 - end if - - ! Add prior - if (self%p_gauss(2,id) > 0.d0) then - sigma_p = self%p_gauss(2,id) !/ sqrt(real(npix_reg,dp)) - mu = (mu*sigma_p**2 + self%p_gauss(1,id) * sigma**2) / (sigma_p**2 + sigma**2) - sigma = sqrt(sigma**2 * sigma_p**2 / (sigma**2 + sigma_p**2)) - end if - - ! Draw sample - par = -1.d300 - if (trim(self%operation) == 'optimize') then - if (mu < self%p_uni(1,id)) then - par = self%p_uni(1,id) - else if (mu > self%p_uni(2,id)) then - par = self%p_uni(2,id) - else - par = mu - end if - else - do while (par < self%p_uni(1,id) .or. par > self%p_uni(2,id)) - if (mu < self%p_uni(1,id)) then - par = rand_trunc_gauss(handle, mu, self%p_uni(1,id), sigma) - else if (mu > self%p_uni(2,id)) then - par = 2.d0*mu-rand_trunc_gauss(handle, mu, 2.d0*mu-self%p_uni(2,id), sigma) - else - par = mu + sigma * rand_gauss(handle) - end if - end do - end if - - if (band == self%ref_band) then - write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' - else - write(*,*) ' Line ratio i = ', id, ' = ', par - end if - end if - - ! Distribute new relative line ratio, and update - call mpi_bcast(par, 1, MPI_DOUBLE_PRECISION, 0, self%x%info%comm, ierr) - - if (band == self%ref_band) then - self%x%map = self%x%map * par ! Rescale amplitude map, but leave mixing matrix - self%x%alm = self%x%alm * par - do i = 1, self%npar ! Rescale line ratios at other frequencies - if (self%ind2band(i) == self%ref_band) cycle - self%theta(i)%p%map = self%theta(i)%p%map / par - if (self%lmax_ind >= 0) then - self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) / par - end if - end do - else - self%theta(id)%p%map = par - if (self%lmax_ind >= 0) then - self%theta(id)%p%alm(:,1) = par * sqrt(4.d0*pi) - end if - end if - call self%updateMixmat() - - end subroutine sampleLineRatios - - - ! update the mixing matrix, assumes only temperature and constant across the whole map - - subroutine updateMixmatLineRatios(self, theta, beta, band, df, par) - implicit none - class(comm_line_comp), intent(inout) :: self - class(comm_map), dimension(:), intent(in), optional :: theta - real(dp), dimension(:,:,:), intent(in), optional :: beta ! Not used here - integer(i4b), intent(in), optional :: band - class(map_ptr), dimension(:), intent(inout), optional :: df ! Derivative of mixmat with respect to parameter par; for Jeffreys prior - integer(i4b), intent(in), optional :: par ! Parameter ID for derivative - - - integer(i4b) :: i, j, l, p, nmaps, ierr !,checkv, p_min, p_max, n, k, - real(dp) :: t1, t2 !lat, lon, - logical(lgt) :: mixmatnull ! NEW ,only_pol, , bad, precomp, - ! character(len=2) :: ctext - real(dp), allocatable, dimension(:) :: buffer, buff2, theta_p_v ! s, nu, - class(comm_mapinfo), pointer :: info => null() !, info_tp => null() - ! class(map_ptr), allocatable, dimension(:) :: theta_prev - - ! call wall_time(t1) - if (trim(self%type) == 'md') return - - call update_status(status, "mixupdate1 " // trim(self%label)) - - ! Copy over alms from input structure, and compute pixel-space parameter maps - if (present(theta)) then - do i = 1, self%npar - ! write(*,*) 'Check 1' - self%theta(i)%p%alm = theta(i)%alm - end do - end if - - - ! Compute mixing matrix - do i = 1, numband - - ! Only update requested band if present - if (present(band)) then - if (i /= band) cycle - end if - - ! Compute spectral parameters at the correct resolution for this channel - ! only temperature can have a monopole, doesn't make sense for polarization - check with HKE and others about - ! procedure going forwards - if (self%npar > 0) then - nmaps = min(data(i)%info%nmaps, self%theta(1)%p%info%nmaps) - allocate(theta_p_v(self%npar)) - do j = 1,self%npar - ! if self%theta(j)%p%info%lmax=0 constant on the sky - theta_p_v(j) = self%theta(j)%p%alm(0,1)/sqrt(4.0d0*pi) - end do - end if - ! write(*,*) 'id', self%x%info%myid - - call mpi_bcast(theta_p_v,size(theta_p_v),MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr) - - do l = 0, data(i)%ndet - if (self%F_null(i,l)) then - if (present(df)) df(i)%p%map = 0.d0 - cycle - end if - - if (data(i)%comp_sens == "broadband") then - ! If broadband, calculate mixing matrix - mixmatnull = .false. - else - ! If component sensitivity, only calculate mixmat on that component. - mixmatnull = .true. - If (data(i)%comp_sens == self%label) then - mixmatnull = .false. - end if - end if - - ! Temperature - if (self%npar > 0) then - if (mixmatnull) then - self%F(i,l)%p%map(:,1) = 0.0 - else - self%F(i,l)%p%map(:,1) = self%F_int(1,i,l)%p%eval(theta_p_v(:)) * data(i)%gain * self%cg_scale(1) - ! if (self%x%info%myid==0 .or. self%x%info%myid==1) then - ! write(*,*) 'Check inside core', self%x%info%myid - ! end if - end if - else - if (mixmatnull) then - self%F(i,l)%p%map(:,1) = 0.0 - else - self%F(i,l)%p%map(:,1) = self%F_int(1,i,l)%p%eval([0.d0]) * data(i)%gain * self%cg_scale(1) - end if - end if - - - - allocate(buffer(self%nmaps), buff2(self%nmaps)) - do j = 1, min(self%nmaps, data(i)%info%nmaps) - self%F_mean(i,l,j) = sum(self%F(i,l)%p%map(:,j)) - end do - buff2 = self%F_mean(i,l,:) - !call mpi_barrier(mpi_comm_world, ierr) - call mpi_allreduce(buff2, buffer, self%nmaps, & - & MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - self%F_mean(i,l,:) = buffer / self%F(i,l)%p%info%npix - deallocate(buffer,buff2) - - end do - if (allocated(theta_p_v)) deallocate(theta_p_v) - end do - - call update_status(status, "mixupdate2 " // trim(self%label)) - - ! Request preconditioner update - recompute_diffuse_precond = .true. - - ! call wall_time(t2) - ! if (self%x%info%myid == 0) write(*,*) ' Update line ratio mixing matrix time = ', t2-t1 - - end subroutine updateMixmatLineRatios - - - - - end module comm_line_comp_mod - - - ->>>>>> devel From b7633f386628ef86e2df00b6195cf294b7295231 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 24 Jun 2025 13:09:56 +0200 Subject: [PATCH 160/171] Minor fixes --- .../components/ame/ame_DIRBE.defaults | 2 +- .../components/cmb/cmb_DIRBE.defaults | 1 + .../components/co/cii_DIRBE_v3.defaults | 1 + .../components/co/co100_DIRBE.defaults | 1 + .../components/co/co217_DIRBE.defaults | 1 + .../components/co/co353_DIRBE.defaults | 1 + .../defaults/components/co/co_DIRBE.defaults | 1 + .../components/co/co_tot_DIRBE.defaults | 1 + .../dust/dust_DIRBE_localsampler.defaults | 8 +++---- .../dust/dust_coldcores_DIRBE_n4096.defaults | 1 + .../dust/dust_coldtab_DIRBE.defaults | 1 + .../dust/dust_coldtab_DIRBE_n4096.defaults | 1 + .../components/dust/dust_hotPAH.defaults | 1 + .../dust/dust_hotPAH_n4096.defaults | 1 + .../components/dust/dust_ir_DIRBE.defaults | 1 + .../dust/dust_ir_DIRBE_n4096.defaults | 1 + .../dust/dust_nearby_DIRBE.defaults | 1 + .../components/dust/dust_stars_n512.defaults | 1 + .../freefree/freefree_DIRBE.defaults | 1 + .../freefree/freefree_DIRBE2.defaults | 1 + .../components/pah/pah_DIRBE.defaults | 1 + .../stars/faint_WISE_DIRBE.defaults | 3 ++- .../components/synch/synch_DIRBE.defaults | 1 + commander3/src/comm_data_mod.f90 | 2 +- commander3/src/comm_diffuse_comp_mod.f90 | 2 +- commander3/src/comm_diffuse_comp_smod.f90 | 23 ++++++++++--------- commander3/src/comm_param_mod.f90 | 4 ++++ commander3/src/comm_ptsrc_comp_mod.f90 | 1 - commander3/src/comm_tod_dirbe_mod.f90 | 13 +++++++---- commander3/src/comm_zodi_mod.f90 | 2 +- commander3/src/comm_zodi_samp_mod.f90 | 2 +- 31 files changed, 55 insertions(+), 27 deletions(-) diff --git a/commander3/parameter_files/defaults/components/ame/ame_DIRBE.defaults b/commander3/parameter_files/defaults/components/ame/ame_DIRBE.defaults index e7db0e969..a3524205a 100644 --- a/commander3/parameter_files/defaults/components/ame/ame_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/ame/ame_DIRBE.defaults @@ -13,7 +13,7 @@ COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0016_600arcmin_rescaled_TQU #COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_120arcmin_rescaled_TQU.fits,64,120.d0,2.0,2.5,3.0,3.5,4.0,10 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1000 - +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 60 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults b/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults index 67ea4d94b..649162df9 100644 --- a/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/cmb/cmb_DIRBE.defaults @@ -10,6 +10,7 @@ COMP_NSIDE&& = 2048 COMP_MONOPOLE_PRIOR&& = monopole-dipole:mask_band_monopoles_bp10_chisq_comp_radio_commonDX12_n2048_TQU.fits COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 4000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 4000 diff --git a/commander3/parameter_files/defaults/components/co/cii_DIRBE_v3.defaults b/commander3/parameter_files/defaults/components/co/cii_DIRBE_v3.defaults index 768694765..bd54e7e90 100644 --- a/commander3/parameter_files/defaults/components/co/cii_DIRBE_v3.defaults +++ b/commander3/parameter_files/defaults/components/co/cii_DIRBE_v3.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 200 COMP_NSIDE&& = 512 COMP_L_APOD&& = 500 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 500 COMP_OUTPUT_FWHM&& = 42 # arcmin diff --git a/commander3/parameter_files/defaults/components/co/co100_DIRBE.defaults b/commander3/parameter_files/defaults/components/co/co100_DIRBE.defaults index 2de3433c4..f66eb3457 100644 --- a/commander3/parameter_files/defaults/components/co/co100_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/co/co100_DIRBE.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 COMP_NSIDE&& = 2048 COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 6000 COMP_OUTPUT_FWHM&& = 9.5 # arcmin diff --git a/commander3/parameter_files/defaults/components/co/co217_DIRBE.defaults b/commander3/parameter_files/defaults/components/co/co217_DIRBE.defaults index 2bd84e88e..f7965fac1 100644 --- a/commander3/parameter_files/defaults/components/co/co217_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/co/co217_DIRBE.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 COMP_NSIDE&& = 2048 COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 6000 COMP_OUTPUT_FWHM&& = 5.0 # arcmin diff --git a/commander3/parameter_files/defaults/components/co/co353_DIRBE.defaults b/commander3/parameter_files/defaults/components/co/co353_DIRBE.defaults index 1a3950733..a72bacb8a 100644 --- a/commander3/parameter_files/defaults/components/co/co353_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/co/co353_DIRBE.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 COMP_NSIDE&& = 2048 COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 6000 COMP_OUTPUT_FWHM&& = 5.0 # arcmin diff --git a/commander3/parameter_files/defaults/components/co/co_DIRBE.defaults b/commander3/parameter_files/defaults/components/co/co_DIRBE.defaults index 671116e62..8d1c6a5dc 100644 --- a/commander3/parameter_files/defaults/components/co/co_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/co/co_DIRBE.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 COMP_NSIDE&& = 2048 COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 6000 COMP_OUTPUT_FWHM&& = 5 # arcmin diff --git a/commander3/parameter_files/defaults/components/co/co_tot_DIRBE.defaults b/commander3/parameter_files/defaults/components/co/co_tot_DIRBE.defaults index f812a41d3..50c2be535 100644 --- a/commander3/parameter_files/defaults/components/co/co_tot_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/co/co_tot_DIRBE.defaults @@ -9,6 +9,7 @@ COMP_CG_SAMPLE_GROUP&& = 1 COMP_CG_SAMP_GROUP_MAXITER&& = 35 COMP_NSIDE&& = 2048 COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 6000 COMP_OUTPUT_FWHM&& = 9.5 # arcmin diff --git a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults index 64fe7c3d9..7500e07be 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_DIRBE_localsampler.defaults @@ -1,6 +1,6 @@ # New Local sampling parameters, 'dust' -COMP_BETA_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat -COMP_BETA_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_INT_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_BETA_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat COMP_BETA_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_BETA_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_BETA_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg,prior}. @@ -36,8 +36,8 @@ COMP_BETA_COMBINED_MONOPOLE_MASK&& = fullsky mask_band_monopoles_bp10_chisq_comp COMP_BETA_CORRELATION_CONVERGENCE_SAMPLING&& = .false. COMP_BETA_CORRELATION_CONVERGENCE_LIMIT&& = 0.1d0 -COMP_T_INT_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat -COMP_T_POL_LMAX&& = -1 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_INT_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat +COMP_T_POL_LMAX&& = 0 # alm sampling (>=0), local sampling (-1). NOTE!! Also sets alm/pix-by-pix updateMixmat COMP_T_INT_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_T_POL_LNLTYPE&& = chisq # log-likelihood type {chisq,ridge,marginal}. All evaluated at smoothing scale, local sampling COMP_T_INT_PIXREG&& = fullsky # pixel region type, local sampling, {fullsky,single_pix,pixreg}. 'Pixreg' only one supported at the moment diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults index c8f0fbfb6..375c67184 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldcores_DIRBE_n4096.defaults @@ -12,6 +12,7 @@ COMP_NSIDE&& = 4096 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 5 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults index 0f441b384..d2f8203cc 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE.defaults @@ -12,6 +12,7 @@ COMP_NSIDE&& = 2048 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 10 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults index f3e2efcba..6cb5776b1 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_coldtab_DIRBE_n4096.defaults @@ -12,6 +12,7 @@ COMP_NSIDE&& = 4096 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 5 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults index 1a36c3963..d9f6c7d9b 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 2048 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 10 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults index 4be3e806f..ba4e1495d 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_hotPAH_n4096.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 4096 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 6000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 5 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults index 3564fef36..b78395001 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 512 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 200 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 42 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults index ef5196daa..65556619c 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_ir_DIRBE_n4096.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 4096 COMP_MONOPOLE_PRIOR&& = crosscorr:HI4PI_NHI_n0064_60arcmin_rescaled_TQU.fits,64,60.d0,1.5,2.0,2.5,3.0,3.5,4.0 #,,, COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 800 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 45 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE.defaults b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE.defaults index d3a7e53c5..8596066e4 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_nearby_DIRBE.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 2048 COMP_MONOPOLE_PRIOR&& = none COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1000 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 14 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults index 673a53bd0..280c3b05b 100644 --- a/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults +++ b/commander3/parameter_files/defaults/components/dust/dust_stars_n512.defaults @@ -34,6 +34,7 @@ COMP_CL_DEFAULT_BETA_B&& = 30.d0 COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 500 COMP_L_APOD&& = 200 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_AMP_INPUT_MAP&& = zero_n512.fits COMP_AMP_PRIOR_MAP&& = none diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE.defaults index 43bb68358..453b49cfe 100644 --- a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE.defaults @@ -12,6 +12,7 @@ COMP_MONOPOLE_PRIOR&& = monopole-dipole:mask_ff_monoprior_bp10_n1024_TQU COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1500 COMP_LMAX_IND&& = 0 -1 # Use input map as is +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 30 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults index 2c38e1a31..b6e70f19f 100644 --- a/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults +++ b/commander3/parameter_files/defaults/components/freefree/freefree_DIRBE2.defaults @@ -12,6 +12,7 @@ COMP_MONOPOLE_PRIOR&& = monopole-dipole:mask_ff_monoprior_bp10_n1024_TQU COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1500 COMP_LMAX_IND&& = 0 -1 # Use input map as is +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 15 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/parameter_files/defaults/components/pah/pah_DIRBE.defaults b/commander3/parameter_files/defaults/components/pah/pah_DIRBE.defaults index 9f35b0f5e..33bc84fc5 100644 --- a/commander3/parameter_files/defaults/components/pah/pah_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/pah/pah_DIRBE.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 256 COMP_AMP_LMIN&& = 0 COMP_AMP_LMAX&& = 750 COMP_L_APOD&& = 750 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_UNIT&& = MJy/sr COMP_NU_MIN&& = 0.d0 COMP_NU_MAX&& = 1d30 diff --git a/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults b/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults index ef47b385d..df09e519a 100644 --- a/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/stars/faint_WISE_DIRBE.defaults @@ -19,6 +19,7 @@ COMP_NU_REF_T&& = 239833.966 COMP_NU_REF_P&& = 239833.966 COMP_MASK&& = fullsky COMP_INDMASK&& = fullsky +COMP_APPLY_DUST_EXTINCTION&& = .true. COMP_CL_TYPE&& = none # {none, single_l, binned,power_law, exp} COMP_CL_POLTYPE&& = 2 # {1 = {T+E+B}, 2 = {T,E+B}, 3 = {T,E,B}} @@ -37,7 +38,7 @@ COMP_AMP_LMAX&& = 1500 COMP_AMP_INPUT_MAP&& = diffuse_star_template_DIRBE01_smoothe_n512_x2000.fits COMP_AMP_PRIOR_MAP&& = none -COMP_IND_LMAX&& = -1 +COMP_IND_LMAX&& = 0 COMP_BETA_NU_MIN&& = 30 # Lowest frequency for index estimation in GHz COMP_BETA_NU_MAX&& = 1000 2540 # Highest frequency for index estimation in GHz diff --git a/commander3/parameter_files/defaults/components/synch/synch_DIRBE.defaults b/commander3/parameter_files/defaults/components/synch/synch_DIRBE.defaults index 544e4d91f..a805c96a9 100644 --- a/commander3/parameter_files/defaults/components/synch/synch_DIRBE.defaults +++ b/commander3/parameter_files/defaults/components/synch/synch_DIRBE.defaults @@ -11,6 +11,7 @@ COMP_NSIDE&& = 1024 COMP_MONOPOLE_PRIOR&& = bandmono:0.4-Haslam # COMP_DEFLATION_MASK&& = fullsky COMP_L_APOD&& = 1500 +COMP_APPLY_DUST_EXTINCTION&& = .false. COMP_OUTPUT_FWHM&& = 60 # arcmin COMP_UNIT&& = uK_RJ COMP_NU_MIN&& = 0.d0 diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index 4597011e1..ccaa2a0fc 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -323,7 +323,7 @@ subroutine initialize_data_mod(cpar, handle) end if ! Initialize dust extinction map - if (active_dust_ext_model(data(i)%bp(0)%p%nu_c)) then + if (active_dust_ext_model(data(n)%bp(0)%p%nu_c)) then info_smooth => comm_mapinfo(data(n)%info%comm, data(n)%info%nside, & & -1, 1, .false.) data(n)%A_ext => comm_map(data(n)%info) diff --git a/commander3/src/comm_diffuse_comp_mod.f90 b/commander3/src/comm_diffuse_comp_mod.f90 index 5fc352aec..74a09ac83 100644 --- a/commander3/src/comm_diffuse_comp_mod.f90 +++ b/commander3/src/comm_diffuse_comp_mod.f90 @@ -36,7 +36,7 @@ module comm_diffuse_comp_mod ! only interfaces in this file, accompanying smod.f character(len=512) :: cltype integer(i4b) :: nside, nx, x0, ndet logical(lgt) :: pol, output_mixmat, output_EB, apply_jeffreys, almsamp_pixreg, priorsamp_local - logical(lgt) :: output_localsamp_maps + logical(lgt) :: output_localsamp_maps, apply_dust_ext integer(i4b) :: lmin_amp, lmax_amp, lmax_ind, lmax_prior, lpiv, l_apod, lmax_pre_lowl integer(i4b) :: lmax_def, nside_def, ndef, nalm_tot, sample_first_niter diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 5e47d0d3d..3d61a5e12 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -63,14 +63,15 @@ module subroutine initDiffuse(self, cpar, id, id_abs) call update_status(status, "init_diffuse_start") ! Initialize variables specific to diffuse source type - self%pol = cpar%cs_polarization(id_abs) - self%nside = cpar%cs_nside(id_abs) - self%lmin_amp = cpar%cs_lmin_amp(id_abs) - self%lmax_amp = cpar%cs_lmax_amp(id_abs) - self%lmax_prior = cpar%cs_lmax_amp_prior(id_abs) - self%l_apod = cpar%cs_l_apod(id_abs) - self%nu_min = cpar%cs_nu_min(id_abs) - self%nu_max = cpar%cs_nu_max(id_abs) + self%pol = cpar%cs_polarization(id_abs) + self%nside = cpar%cs_nside(id_abs) + self%lmin_amp = cpar%cs_lmin_amp(id_abs) + self%lmax_amp = cpar%cs_lmax_amp(id_abs) + self%lmax_prior = cpar%cs_lmax_amp_prior(id_abs) + self%l_apod = cpar%cs_l_apod(id_abs) + self%nu_min = cpar%cs_nu_min(id_abs) + self%nu_max = cpar%cs_nu_max(id_abs) + self%apply_dust_ext = cpar%cs_apply_dust_ext(id_abs) self%cltype = cpar%cs_cltype(id_abs) self%cg_scale(1:3) = cpar%cs_cg_scale(1:3,id_abs) @@ -1937,7 +1938,7 @@ module subroutine updateDiffuseMixmat(self, theta, beta, band, df, par) end if ! Initialize dust extinction - if (associated(data(i)%A_ext)) then + if (self%apply_dust_ext .and. associated(data(i)%A_ext)) then A_ext = data(i)%A_ext%map(j,1) else A_ext = 1.d0 @@ -2106,7 +2107,7 @@ module function evalDiffuseBand(self, band, amp_in, pix, alm_out, det) result(re if (apply_mixmat) then ! Scale to correct frequency through multiplication with mixing matrix - if (all(self%lmax_ind_mix(1:nmaps,:) == 0) .and. self%latmask < 0.d0) then + if (all(self%lmax_ind_mix(1:nmaps,:) == 0) .and. self%latmask < 0.d0 .and. .not. (self%apply_dust_ext .and. associated(data(band)%A_ext))) then do i = 1, m%info%nmaps m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do @@ -2178,7 +2179,7 @@ module function projectDiffuseBand(self, band, map, alm_in, det) result(res) end if call data(band)%B(d)%p%conv(trans=.true., map=m) - if (all(self%lmax_ind_mix(1:nmaps,:) == 0) .and. self%latmask < 0.d0) then + if (all(self%lmax_ind_mix(1:nmaps,:) == 0) .and. self%latmask < 0.d0 .and. .not. (self%apply_dust_ext .and. associated(data(band)%A_ext))) then do i = 1, nmaps m%alm(:,i) = m%alm(:,i) * self%F_mean(band,d,i) end do diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index b98a5fe56..36ad49abd 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -248,6 +248,7 @@ module comm_param_mod character(len=2048), allocatable, dimension(:) :: cs_mask character(len=2048), allocatable, dimension(:) :: cs_mono_prior real(dp), allocatable, dimension(:) :: cs_latmask + logical(lgt), allocatable, dimension(:) :: cs_apply_dust_ext character(len=2048), allocatable, dimension(:) :: cs_indmask character(len=2048), allocatable, dimension(:) :: cs_defmask real(dp), allocatable, dimension(:,:) :: cs_cl_prior @@ -837,6 +838,7 @@ subroutine read_component_params_hash(htbl, cpar) n = cpar%cs_ncomp_tot allocate(cpar%cs_include(n), cpar%cs_label(n), cpar%cs_type(n), cpar%cs_class(n)) allocate(cpar%cs_spec_lnLtype(3,MAXPAR,n)) + allocate(cpar%cs_apply_dust_ext(n)) allocate(cpar%cs_pixreg_init_theta(MAXPAR,n)) allocate(cpar%cs_almsamp_init(MAXPAR,n),cpar%cs_theta_prior(2,3,MAXPAR,n)) allocate(cpar%cs_spec_pixreg(3,MAXPAR,n),cpar%cs_spec_mask(MAXPAR,n)) @@ -873,6 +875,7 @@ subroutine read_component_params_hash(htbl, cpar) cpar%cs_spec_mono_combined=.false. !by default cpar%cs_spec_corr_convergence=.false. !by default + cpar%cs_apply_dust_ext=.false. do i = 1, n call int2string(i, itext) @@ -900,6 +903,7 @@ subroutine read_component_params_hash(htbl, cpar) ! Break up the diffuse parameter reading into something a bit more legible else if (trim(cpar%cs_class(i)) == 'diffuse') then call read_diffuse_gen_params_hash(htbl, cpar, itext, i, len_itext, bool_flag, pol_labels) + call get_parameter_hashtable(htbl, 'COMP_APPLY_DUST_EXTINCTION'//itext, len_itext=len_itext, par_lgt=cpar%cs_apply_dust_ext(i)) select case (trim(cpar%cs_type(i))) case ('cmb') call read_cmb_params_hash(htbl,cpar) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index bd2b9e0c5..a5b115c2c 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -284,7 +284,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) if (c%F_null(i)) cycle ia = c%b2a(i) call get_dust_attenuation_pos(c%src(j)%vec, data(i)%bp(0)%p%nu_c, c%src(j)%T(ia)%A_ext) - if(cpar%myid == 0) write(*,*) j, i, c%src(j)%T(ia)%A_ext end do end do diff --git a/commander3/src/comm_tod_dirbe_mod.f90 b/commander3/src/comm_tod_dirbe_mod.f90 index 62171aa52..8d36c471e 100644 --- a/commander3/src/comm_tod_dirbe_mod.f90 +++ b/commander3/src/comm_tod_dirbe_mod.f90 @@ -294,26 +294,29 @@ subroutine process_DIRBE_tod(self, chaindir, chain, iter, handle, map_in, delta, !!$ & trim(self%freq) == '03' .or. & !!$ & trim(self%freq) == '09' .or. trim(self%freq) == '10') then !if (trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then - if (trim(self%freq(1:2)) == '10') then + if (trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then sample_ncorr = .true. - sample_ncorr = .false. + !sample_ncorr = .false. else sample_ncorr = .false. end if + if (trim(self%freq(1:2)) == '05' .or. trim(self%freq(1:2)) == '06') then + sample_gain = iter > 1 + else + sample_gain = .false. + end if + if (trim(self%freq(1:2)) == '05' .or. trim(self%freq(1:2)) == '06' .or. & & trim(self%freq(1:2)) == '07' .or. trim(self%freq(1:2)) == '08' .or. & & trim(self%freq(1:2)) == '09' .or. trim(self%freq(1:2)) == '10') then - sample_gain = iter > 1 ! Pixhist Extreme RMS ranges Single Ranges Pointing flag_threshold = [1.0, -20., -5.0, -3.0, -2.0, -1.5, 1.0, -0.30, 1.0] else - sample_gain = iter > 1 ! Pixhist Extreme RMS ranges Single Ranges Pointing flag_threshold = [1.0, -50., -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0] !flag_threshold = [-1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0] end if - sample_gain = .false. ! Initialize local variables ndelta = size(delta,3) diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 6d634f054..76eb07efd 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -322,7 +322,7 @@ subroutine init_general_priors_and_scales(self, prior, scale) real(dp), dimension(1:,1:), intent(inout) :: prior real(dp), dimension(1:,1:), intent(inout) :: scale - prior(:,1) = [250.d0, 300.d0, 286.d0, 5.d0] ! T_0 + prior(:,1) = [250.d0, 330.d0, 286.d0, 5.d0] ! T_0 scale(1,:) = [286.d0, 3.d0] prior(:,2) = [0.4d0, 0.5d0, 0.467d0, 0.004d0] ! delta scale(2,:) = [0.4d0, 0.01d0] diff --git a/commander3/src/comm_zodi_samp_mod.f90 b/commander3/src/comm_zodi_samp_mod.f90 index 006b7ea8f..9f8f5449b 100644 --- a/commander3/src/comm_zodi_samp_mod.f90 +++ b/commander3/src/comm_zodi_samp_mod.f90 @@ -557,7 +557,7 @@ subroutine minimize_zodi_with_powell(cpar, iter, handle, samp_group) if (cpar%myid == cpar%root) then ! Perform search - call powell(theta, lnL_zodi, ierr, tolerance=1d-5) + call powell(theta, lnL_zodi, ierr, tolerance=1d-4) if (ierr /= 0) write(*,*) 'powell failed, ierr =', ierr chisq_new = lnL_zodi(theta) flag = 0 From 4d84cc2805631c29e0ab43cb5a97f5738fcb7237 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 24 Jun 2025 16:03:38 +0200 Subject: [PATCH 161/171] Updated default parameter files to be compatible, as well as updating the file validation for monopole priors --- cmake/sources.cmake | 2 +- .../defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults | 2 ++ .../defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults | 4 +++- .../defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults | 4 +++- .../defaults/bands/FIRAS/FIRAS_H0857_map.defaults | 1 - .../defaults/bands/FIRAS/FIRAS_H1251_map.defaults | 2 ++ .../defaults/bands/HFI/HFI_100_TOD.defaults | 2 ++ .../defaults/bands/HFI/HFI_353_map_pol_only.defaults | 1 + .../defaults/bands/HFI/HFI_545-1_TOD.defaults | 2 ++ .../defaults/bands/HFI/HFI_545_TOD.defaults | 2 ++ .../defaults/bands/HFI/HFI_857_map.defaults | 1 + .../defaults/bands/LFI/LFI_030_TOD.defaults | 11 +++++++++++ .../defaults/bands/LFI/LFI_044_TOD.defaults | 11 +++++++++++ .../defaults/bands/LFI/LFI_070_TOD.defaults | 11 +++++++++++ .../defaults/bands/LiteBIRD/LB_040_L1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_050_L2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_060_L1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_068_L2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_068_L3_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_078_L1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_078_L4_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_089_L2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_089_L3_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_100_L4_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_100_M1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_119_L3_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_119_M2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_140_L4_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_140_M1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_166_M2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_195_H1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_195_M1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_235_H2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_280_H1_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_337_H2_TOD.defaults | 2 ++ .../defaults/bands/LiteBIRD/LB_402_H3_TOD.defaults | 2 ++ .../defaults/bands/QUIET/QUIET_Q_GC_TOD.defaults | 2 ++ .../defaults/bands/WMAP/WMAP_K_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_Ka_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_Q1_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_Q2_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_V1_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_V2_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_W1_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_W2_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_W3_TOD.defaults | 11 +++++++++++ .../defaults/bands/WMAP/WMAP_W4_TOD.defaults | 11 +++++++++++ .../defaults/bands/haslam/haslam_0.4_map.defaults | 2 ++ commander3/src/comm_param_mod.f90 | 2 +- install_ita.sh | 4 ++-- 67 files changed, 259 insertions(+), 19 deletions(-) diff --git a/cmake/sources.cmake b/cmake/sources.cmake index 13adc538d..9c1042bc9 100644 --- a/cmake/sources.cmake +++ b/cmake/sources.cmake @@ -104,7 +104,7 @@ set(hdf5_md5 "9e22217d22eb568e09f0cc15fb641d7c") #------------------------------------------------------------------------------ #set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz") #set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.49.tar.gz") -set(cfitsio_url "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.0.0.tar.gz") +set(cfitsio_url "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.0.0.tar.gz") #------------------------------------------------------------------------------ # HEALPix #------------------------------------------------------------------------------ diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults index d6b9e6294..3c215c09f 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults index dee36b5f8..548f0e34a 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_01_CIO_512.defaults @@ -77,3 +77,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults index 6678189d2..c27af2903 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults index 3632f9e99..2aed54778 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_02_CIO_512.defaults @@ -77,3 +77,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults index 7aa7069cb..e10827ca0 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_256.defaults @@ -75,4 +75,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults index b607bb842..ee515f1e8 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_03_CIO_512.defaults @@ -78,3 +78,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults index c4b684c10..94d5d266d 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults index d45ea71d1..6ec1fd22f 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_04_CIO_512.defaults @@ -76,4 +76,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults index ed33e4391..863fafe64 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults index 8e4630d61..c9a61ba2b 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_05_CIO_512.defaults @@ -77,3 +77,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults index 3e4ec03ab..7bebb12da 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults index 59d4746de..69e4e4e8f 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_06_CIO_512.defaults @@ -77,3 +77,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults index ae725cd9b..3e54d2f7d 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults index 7d2ab4710..6ddc3c333 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_07_CIO_512.defaults @@ -76,4 +76,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults index 170814862..3e9b65551 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults index a186b343e..1f0c17081 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_08_CIO_512.defaults @@ -76,4 +76,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults index ad3079295..39f8b1cd1 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_256.defaults @@ -76,4 +76,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults index 5b7891659..4ba148c14 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_09_CIO_512.defaults @@ -77,3 +77,5 @@ BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults index 4d3148ea8..fe978921b 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_256.defaults @@ -74,4 +74,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults index 3d5960fca..61714c84d 100644 --- a/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults +++ b/commander3/parameter_files/defaults/bands/DIRBE/DIRBE_10_CIO_512.defaults @@ -76,4 +76,6 @@ BAND_TOD_MOON_CENTRIC_MASK&&& = none BAND_TOD_MOON_CENTRIC_INITMAP&&& = none BAND_TOD_EARTH_CENTRIC_MODEL&&& = none BAND_TOD_EARTH_CENTRIC_MASK&&& = none -BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none \ No newline at end of file +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H0857_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H0857_map.defaults index af9e5baf7..93088250d 100644 --- a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H0857_map.defaults +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H0857_map.defaults @@ -42,4 +42,3 @@ BAND_REG_NOISEFILE&&& = none BAND_NOISE_RMS&&&_SMOOTH01 = none BAND_NOISE_RMS&&&_SMOOTH02 = none BAND_NOISE_RMS&&&_SMOOTH03 = none - diff --git a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1251_map.defaults b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1251_map.defaults index b274a971d..2cd50e2ba 100644 --- a/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1251_map.defaults +++ b/commander3/parameter_files/defaults/bands/FIRAS/FIRAS_H1251_map.defaults @@ -43,3 +43,5 @@ BAND_NOISE_RMS&&&_SMOOTH01 = none BAND_NOISE_RMS&&&_SMOOTH02 = none BAND_NOISE_RMS&&&_SMOOTH03 = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults index f7f2cd1c8..736121f05 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_100_TOD.defaults @@ -79,3 +79,5 @@ BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n1024_TQU.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_353_map_pol_only.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_353_map_pol_only.defaults index cd6bf33ab..dbb84915b 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_353_map_pol_only.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_353_map_pol_only.defaults @@ -1,5 +1,6 @@ # 353 GHz (full frequency) parameters; only polarization, not temperature BAND_LABEL&&& = 353 +BAND_INSTRUMENT_LABEL&&& = 353 BAND_OBS_PERIOD&&& = 1 BAND_POLARIZATION&&& = .true. BAND_NSIDE&&& = 1024 diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults index b0e4526c6..e673600a1 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545-1_TOD.defaults @@ -79,3 +79,5 @@ BAND_TOD_ZODI_MASK&&& = mask_common_dx12_n2048_TQU.fits BAND_TOD_ZODI_EMISSIVITY&&& = 1.d0,1.d0,1.d0,1.d0,1.d0,1.d0 BAND_TOD_ZODI_ALBEDO&&& = 0.d0,0.d0,0.d0,0.d0,0.d0,0.d0 BAND_TOD_ZODI_REFERENCE_BAND&&&= .false. + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults index 8c66e8231..e179db093 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_545_TOD.defaults @@ -71,3 +71,5 @@ N_GIBBS_PER_TOD&&& = 1 BAND_TOD_RIMO&&& = HFI_instrument_v2.h5 BAND_TOD_FILELIST&&& = filelist_545_Artem_full_pointing_DPC.txt #filelist_545_Artem_full.txt + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/HFI/HFI_857_map.defaults b/commander3/parameter_files/defaults/bands/HFI/HFI_857_map.defaults index c8c8fb060..004aca959 100644 --- a/commander3/parameter_files/defaults/bands/HFI/HFI_857_map.defaults +++ b/commander3/parameter_files/defaults/bands/HFI/HFI_857_map.defaults @@ -2,6 +2,7 @@ # Come up with a name, an nside, a beam, a noise rms, the mask, the beams, but # most things can be left at their defaults. BAND_LABEL&&& = 857 # A descriptive label +BAND_INSTRUMENT_LABEL&&& = 857 # A descriptive label BAND_OBS_PERIOD&&& = 1 # A placeholder BAND_POLARIZATION&&& = .false. # Is it polarized or not? BAND_NSIDE&&& = 1024 # Which healpix Nisde? diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults index b74d11cdb..a1c00c3d4 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults @@ -71,3 +71,14 @@ BAND_TOD_RIMO&&& = LFI_instrument_v4.h5 BAND_TOD_FILELIST&&& = filelist_30_v17.txt N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults index 4257eea4e..cc8369e37 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_044_TOD.defaults @@ -54,3 +54,14 @@ BAND_TOD_DETECTOR_LIST&&& = 24M,24S,25M,25S,26M,26S BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults index 0e4ccbd82..39f81d611 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_070_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_DETECTOR_LIST&&& = 18M,18S,19M,19S,20M,20S,21M,21S,22M,22S,23M,23S BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_040_L1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_040_L1_TOD.defaults index a744edcd6..f8d3888c5 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_040_L1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_040_L1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_050_L2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_050_L2_TOD.defaults index e54cd0cfd..90518537f 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_050_L2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_050_L2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_060_L1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_060_L1_TOD.defaults index 925748bf5..3d7a5e100 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_060_L1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_060_L1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L2_TOD.defaults index a4ec14259..cf692ec9e 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L3_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L3_TOD.defaults index dba04aa18..4d3251312 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_068_L3_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L1_TOD.defaults index 10631121c..834c5ac28 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L4_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L4_TOD.defaults index 21e1e9aa1..dfec61a49 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L4_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_078_L4_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L2_TOD.defaults index 3c45464b1..125060799 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L3_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L3_TOD.defaults index 166abf8cd..bc1e89782 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_089_L3_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_L4_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_L4_TOD.defaults index c55a33875..d07731b8a 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_L4_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_L4_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_M1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_M1_TOD.defaults index 382b26476..145674f70 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_M1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_100_M1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_L3_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_L3_TOD.defaults index 7dc670ada..a4df1fb31 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_L3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_L3_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_M2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_M2_TOD.defaults index 816d64b25..447e6f790 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_M2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_119_M2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_L4_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_L4_TOD.defaults index a6130eefa..f1ba623f8 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_L4_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_L4_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_M1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_M1_TOD.defaults index e8c83b6f5..261694eec 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_M1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_140_M1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_166_M2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_166_M2_TOD.defaults index e2490062f..ff7b24804 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_166_M2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_166_M2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_H1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_H1_TOD.defaults index 71c6ada40..94b318bdc 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_H1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_H1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_M1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_M1_TOD.defaults index aeebe56ce..81349c93d 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_M1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_195_M1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_235_H2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_235_H2_TOD.defaults index 84e61337f..46390b7ee 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_235_H2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_235_H2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_280_H1_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_280_H1_TOD.defaults index f1be55023..46f5fed7c 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_280_H1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_280_H1_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_337_H2_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_337_H2_TOD.defaults index 8979d5bb4..5f52bcf74 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_337_H2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_337_H2_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_402_H3_TOD.defaults b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_402_H3_TOD.defaults index 9f235222f..cb4424fce 100644 --- a/commander3/parameter_files/defaults/bands/LiteBIRD/LB_402_H3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LiteBIRD/LB_402_H3_TOD.defaults @@ -52,3 +52,5 @@ BAND_TOD_INIT_FROM_HDF&&& = default BAND_TOD_LEVEL&&& = L1 BAND_TOD_ZODI_SUBTRACTION&&& = .false. N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/QUIET/QUIET_Q_GC_TOD.defaults b/commander3/parameter_files/defaults/bands/QUIET/QUIET_Q_GC_TOD.defaults index 74eccc0e2..6dc672d6e 100644 --- a/commander3/parameter_files/defaults/bands/QUIET/QUIET_Q_GC_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/QUIET/QUIET_Q_GC_TOD.defaults @@ -54,3 +54,5 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults index a8e4dc28d..c567a10ab 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_K_TOD.defaults @@ -54,3 +54,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = K113,K114,K123,K124 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults index 2f81b1b29..5265cf146 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Ka_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = Ka113,Ka114,Ka123,Ka124 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults index 6d4cf2b95..f1376c219 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q1_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = Q113,Q114,Q123,Q124 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults index f67f22af0..484e356f0 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_Q2_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = Q213,Q214,Q223,Q224 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults index 3e8e657d9..d2c4bf71a 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V1_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = V113,V114,V123,V124 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults index b072c9dcb..0c5ecb41d 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_V2_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = V213,V214,V223,V224 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults index abc27eb19..1aec7ee27 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W1_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = W113,W114,W123,W124 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults index 1b22fa975..11248e13e 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W2_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = W213,W214,W223,W224 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults index 03d28c529..15bc529ee 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W3_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = W313,W314,W323,W324 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults index a3125e6ef..206e2ff55 100644 --- a/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/WMAP/WMAP_W4_TOD.defaults @@ -55,3 +55,14 @@ BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = W413,W414,W423,W424 BAND_TOD_INIT_FROM_HDF&&& = default N_GIBBS_PER_TOD&&& = 1 + +BAND_TOD_MAPMAKE_TYPE&&& = binned +BAND_TOD_SOLAR_CENTRIC_MODEL&&& = none +BAND_TOD_SOLAR_CENTRIC_MASK&&& = none +BAND_TOD_SOLAR_CENTRIC_INITMAP&&& = none +BAND_TOD_MOON_CENTRIC_MODEL&&& = none +BAND_TOD_MOON_CENTRIC_MASK&&& = none +BAND_TOD_MOON_CENTRIC_INITMAP&&& = none +BAND_TOD_EARTH_CENTRIC_MODEL&&& = none +BAND_TOD_EARTH_CENTRIC_MASK&&& = none +BAND_TOD_EARTH_CENTRIC_INITMAP&&& = none diff --git a/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults b/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults index d0ce5935b..1d74cefa3 100644 --- a/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults +++ b/commander3/parameter_files/defaults/bands/haslam/haslam_0.4_map.defaults @@ -39,3 +39,5 @@ BAND_DEFAULT_BP_DELTA&&& = 0. BAND_DEFAULT_NOISEAMP&&& = 1. BAND_COMPONENT_SENSITIVITY&&& = broadband BAND_TOD_TYPE&&& = none + +BAND_TOD_MAPMAKE_TYPE&&& = binned diff --git a/commander3/src/comm_param_mod.f90 b/commander3/src/comm_param_mod.f90 index c7b85bd6d..29aee3dde 100644 --- a/commander3/src/comm_param_mod.f90 +++ b/commander3/src/comm_param_mod.f90 @@ -3636,7 +3636,7 @@ subroutine validate_params(cpar) call validate_file(trim(cpar%cs_input_amp(i)), 'COMP_AMP_INPUT_MAP'//itext) end if - if (trim(cpar%cs_mono_prior(i)) /= 'none') then + if (trim(cpar%cs_mono_prior(i)) /= 'none' .and. cpar%cs_mono_prior(i)(1:8) .ne. 'bandmono') then filename = get_token(cpar%cs_mono_prior(i), ":", 2) filename1 = get_token(filename, ",", 1) call validate_file(trim(cpar%datadir) //"/"// trim(filename1),"COMP_MONOPOLE_PRIOR"//itext) diff --git a/install_ita.sh b/install_ita.sh index a52ba6f37..bbdafb468 100755 --- a/install_ita.sh +++ b/install_ita.sh @@ -179,8 +179,8 @@ then mpicc="mpicc" mpicxx="mpicxx" printf "Using GNU:\nFC=$fc\nCC=$cc\nCXX=$cxx\nMPIF90=$mpifc\nMPICC=$mpicc\nMPICXX=$mpicxx" - module load gcc/13.1 - module load openmpi/gcc13/5.0.2 + module load gcc/13.3.1 + module load openmpi/gcc13/5.0.5 printf "\n" $mpifc --version elif [[ "$toolchain" =~ "flang" ]] From a6d2b7fe2643a4c0b970e0f2ccd6274ff6acd6d0 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 24 Jun 2025 16:08:58 +0200 Subject: [PATCH 162/171] Got rid of annoying c++ compilation warning --- commander3/src/comm_system_backend.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_system_backend.cpp b/commander3/src/comm_system_backend.cpp index e448f2aee..8c3fb31ad 100644 --- a/commander3/src/comm_system_backend.cpp +++ b/commander3/src/comm_system_backend.cpp @@ -41,6 +41,7 @@ #include #include #include +#include using namespace std; typedef int (*forthandler)(int*); @@ -68,7 +69,7 @@ extern "C" stringstream path; path << "/proc/" << getpid() << "/statm"; FILE * f = fopen(path.str().c_str(),"r"); int64_t npage; - fscanf(f, "%lld", &npage); + fscanf(f, "%" SCNd64, &npage); fclose(f); return npage*getpagesize(); } From 47836a0d12865f47e3e28be5cdb627e762f6ce6a Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 24 Jun 2025 17:25:56 +0200 Subject: [PATCH 163/171] Edits for fixing readin --- commander3/src/comm_data_mod.f90 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commander3/src/comm_data_mod.f90 b/commander3/src/comm_data_mod.f90 index b044d8ed7..632071c07 100644 --- a/commander3/src/comm_data_mod.f90 +++ b/commander3/src/comm_data_mod.f90 @@ -331,14 +331,16 @@ subroutine initialize_data_mod(cpar, handle) end if ! Set up bp pointers in the TOD object if (cpar%enable_TOD_analysis) then - allocate(data(n)%tod%bp(0:data(n)%ndet)) - do j = 0, data(n)%ndet - data(n)%tod%bp(j)%p => data(n)%bp(j)%p - end do + if (data(n)%ndet .ne. 0) then + allocate(data(n)%tod%bp(0:data(n)%ndet)) + do j = 0, data(n)%ndet + data(n)%tod%bp(j)%p => data(n)%bp(j)%p + end do + end if end if ! Initialize dust extinction map - if (active_dust_ext_model(data(i)%bp(0)%p%nu_c)) then + if (active_dust_ext_model(data(n)%bp(0)%p%nu_c)) then info_smooth => comm_mapinfo(data(n)%info%comm, data(n)%info%nside, & & -1, 1, .false.) data(n)%A_ext => comm_map(data(n)%info) From b468d49f132fcb75d29d899fb3c706a305160063 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 24 Jun 2025 17:33:11 +0200 Subject: [PATCH 164/171] Removed unlabeled write statement --- commander3/src/comm_ptsrc_comp_mod.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index ca81d62c6..3e628661f 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -284,7 +284,6 @@ function constructor_ptsrc(cpar, id, id_abs) result(c) if (c%F_null(i)) cycle ia = c%b2a(i) call get_dust_attenuation_pos(c%src(j)%vec, data(i)%bp(0)%p%nu_c, c%src(j)%T(ia)%A_ext) - if(cpar%myid == 0) write(*,*) j, i, c%src(j)%T(ia)%A_ext end do end do From 96d6c84ce07c9161691d5cbbb890e79130515702 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 25 Jun 2025 09:47:20 +0200 Subject: [PATCH 165/171] Fixed merge --- commander3/src/comm_line_comp_mod.f90 | 350 +------------------------- 1 file changed, 3 insertions(+), 347 deletions(-) diff --git a/commander3/src/comm_line_comp_mod.f90 b/commander3/src/comm_line_comp_mod.f90 index 0c267796c..37d4668dd 100644 --- a/commander3/src/comm_line_comp_mod.f90 +++ b/commander3/src/comm_line_comp_mod.f90 @@ -19,7 +19,6 @@ ! !================================================================================ module comm_line_comp_mod -<<<<<< precond use comm_comp_interface_mod implicit none @@ -37,6 +36,7 @@ module comm_line_comp_mod contains procedure :: S => evalSED_line procedure :: sampleSpecInd => sampleLineRatios + procedure :: updateMixmat => updateMixmatLineRatios end type comm_line_comp interface comm_line_comp @@ -357,349 +357,7 @@ subroutine sampleLineRatios(self, cpar, handle, id, iter) end subroutine sampleLineRatios -end module comm_line_comp_mod -====== - use comm_comp_interface_mod - implicit none - - private - public comm_line_comp - - !************************************************** - ! Line emission component - !************************************************** - type, extends (comm_diffuse_comp) :: comm_line_comp - integer(i4b) :: ref_band - real(dp) :: line2RJ_ref - integer(i4b), allocatable, dimension(:) :: ind2band - real(dp), allocatable, dimension(:) :: line2RJ - contains - procedure :: S => evalSED_line - procedure :: sampleSpecInd => sampleLineRatios - procedure :: updateMixmat => updateMixmatLineRatios - end type comm_line_comp - - interface comm_line_comp - procedure constructor_line - end interface comm_line_comp - - contains - - !************************************************** - ! Routine definitions - !************************************************** - function constructor_line(cpar, id, id_abs) result(c) - implicit none - type(comm_params), intent(in) :: cpar - integer(i4b), intent(in) :: id, id_abs - class(comm_line_comp), pointer :: c - - integer(i4b) :: i, j, k, l, m, nline, b, n, ierr - real(dp) :: f - logical(lgt) :: ref_exist - character(len=512), allocatable, dimension(:) :: label - real(dp), allocatable, dimension(:) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:) :: poltype - type(comm_mapinfo), pointer :: info - - ! General parameters - allocate(c) - c%npar = 0 !temporary value so that lmax_ind is correcty set (to 0) in initDiffuse - call c%initDiffuse(cpar, id, id_abs) - - ! Read line template file - call read_line_template(trim(cpar%cs_SED_template(1,id_abs)), & - & nline, label, mu, sigma, line2RJ, poltype) - - ! Check how many lines are included in current run - n = 0 - ref_exist = .false. - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) n = n+1 - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) ref_exist = .true. - end do - if (.not. ref_exist) call report_error("Line component reference band does not exist, need "//trim(cpar%cs_band_ref(id_abs))) - - allocate(c%ind2band(n)) - c%npar = n - - allocate(c%lmax_ind_pol(3,c%npar)) - c%lmax_ind_pol = 0 !always fullsky (lmax=0) for line component - if (allocated(c%lmax_ind_mix)) deallocate(c%lmax_ind_mix) - allocate(c%lmax_ind_mix(3,c%npar)) - c%lmax_ind_mix = 0 !always fullsky (lmax=0) for line component - allocate(c%pol_pixreg_type(3,c%npar)) - c%pol_pixreg_type = 0 - - allocate(c%theta_def(n), c%p_gauss(2,n), c%p_uni(2,n)) - allocate(c%poltype(n), c%indlabel(n), c%line2RJ(n)) - n = 0 - do i = 1, numband - do j = 1, nline - if (trim(label(j)) == trim(data(i)%label)) then - n = n+1 - c%ind2band(n) = i - c%theta_def(n) = mu(j) - c%p_gauss(1,n) = mu(j) - c%p_gauss(2,n) = sigma(j) - c%p_uni(1,n) = -100.d30 !mu(j)-5*sigma(j) - c%p_uni(2,n) = 100.d30 !mu(j)+5*sigma(j) - c%poltype(n) = poltype(j) - c%indlabel(n) = label(j) - c%line2RJ(n) = line2RJ(j) - exit - end if - end do - if (trim(data(i)%label) == trim(cpar%cs_band_ref(id_abs))) then - c%ref_band = i - c%line2RJ_ref = c%line2RJ(n) - end if - end do - - ! Update reference band unit conversion - do i = 1, c%x%info%nmaps - c%RJ2unit_(i) = 1.d0 / c%line2RJ_ref - c%x%map(:,i) = c%x%map(:,i) / c%RJ2unit_(i) - c%x%alm(:,i) = c%x%alm(:,i) / c%RJ2unit_(i) - end do - - ! Initialize spectral index maps - info => comm_mapinfo(cpar%comm_chain, c%nside, c%lmax_ind, & - & c%nmaps, c%pol) - - allocate(c%theta(n)) - do i = 1, n - c%theta(i)%p => comm_map(info) - c%theta(i)%p%map = c%theta_def(i) - if (c%lmax_ind >= 0) call c%theta(i)%p%YtW_scalar - end do - - - ! Precompute mixmat integrator for each band - allocate(c%F_int(3,numband,0:c%ndet)) - j = 1 - do l = 1, 3 - do i = 1, numband - if (l > 1) then - do m = 0,c%ndet - c%F_int(l,i,m)%p => c%F_int(l-1,i,m)%p - end do - cycle - end if - if (any(c%ind2band == i)) then - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .true., & - & c%line2RJ(j) / c%line2RJ_ref * data(i)%RJ2data(k), j) - end do - j = j+1 - else - do k = 0, data(i)%ndet - ! write(*,*) 'line disabled' - c%F_int(l,i,k)%p => comm_F_line(c, data(i)%bp(k)%p, .false., 0.d0, j) - end do - end if - end do - end do - - ! Initialize mixing matrix - if (trim(cpar%init_chain_prefix) == 'none' & - & .or. trim(c%init_from_HDF) == 'none') & - & call c%updateMixmat - - deallocate(label, mu, sigma, line2RJ, poltype) - - end function constructor_line - - ! Definition: - ! SED = delta_{band, - function evalSED_line(self, nu, band, pol, theta) - class(comm_line_comp), intent(in) :: self - real(dp), intent(in), optional :: nu - integer(i4b), intent(in), optional :: band - integer(i4b), intent(in), optional :: pol - real(dp), dimension(1:), intent(in), optional :: theta - real(dp) :: evalSED_line - - integer(i4b) :: i, ind - - if (band == self%ref_band) then - evalSED_line = 1.d0 - else - do i = 1, self%npar - if (band == self%ind2band(i)) exit - end do - if (i > self%npar) then - evalSED_line = 0.d0 - else - evalSED_line = theta(i) * self%line2RJ(i) / self%line2RJ_ref - end if - end if - - end function evalSED_line - - subroutine read_line_template(filename, nline, label, mu, sigma, line2RJ, poltype) - implicit none - character(len=*), intent(in) :: filename - integer(i4b), intent(out) :: nline - character(len=512), allocatable, dimension(:), intent(out) :: label - real(dp), allocatable, dimension(:), intent(out) :: mu, sigma, line2RJ - integer(i4b), allocatable, dimension(:), intent(out) :: poltype - - integer(i4b) :: i, unit - character(len=1024) :: line - - unit = getlun() - - ! Find number of lines - nline = 0 - open(unit, file=trim(filename), recl=1024) - do while (.true.) - read(unit,'(a)', end=1) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - end do - 1 close(unit) - - allocate(label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline)) - open(unit, file=trim(filename), recl=1024) - nline = 0 - do while (.true.) - read(unit,'(a)', end=2) line - line = trim(adjustl(line)) - if (line(1:1) == '#') cycle - nline = nline+1 - read(line,*) label(nline), mu(nline), sigma(nline), line2RJ(nline), poltype(nline) - end do - 2 close(unit) - - end subroutine read_line_template - - ! Sample line ratios - subroutine sampleLineRatios(self, cpar, handle, id, iter) - implicit none - class(comm_line_comp), intent(inout) :: self - type(comm_params), intent(in) :: cpar - type(planck_rng), intent(inout) :: handle - integer(i4b), intent(in) :: id - integer(i4b), intent(in) :: iter !Gibbs iteration - - integer(i4b) :: i, j, l, n, m, band, ierr - real(dp) :: A, b, mu, sigma, par, sigma_p, scale, w - class(comm_map), pointer :: invN_amp, amp - character(len=2) :: id_text - - band = self%ind2band(id) - !if (band == self%ref_band) return - - - ! Compute likelihood term - w = self%theta(id)%p%map(1,1) - amp => comm_map(data(band)%info) - invN_amp => comm_map(data(band)%info) - amp%map = self%getBand(band)/w - invN_amp%map = amp%map - call data(band)%N%invN(invN_amp) ! Inverse noise variance weighted amplitude map - - !!$ call int2string(id, id_text) - !!$ call mask%writeFITS('co_mask'//id_text//'.fits') - !!$ call amp%writeFITS('co_amp'//id_text//'.fits') - !!$ call data(band)%res%writeFITS('co_res'//id_text//'.fits') - !!$ call data(band)%N%invN_diag%writeFITS('co_invN'//id_text//'.fits') - - ! Reduce across processors - if (associated(self%indmask(band)%p)) then - A = sum(invN_amp%map * self%indmask(band)%p%map * amp%map) - b = sum(invN_amp%map * self%indmask(band)%p%map * data(band)%res%map) - else - A = sum(invN_amp%map * amp%map) - b = sum(invN_amp%map * data(band)%res%map) - end if - call mpi_allreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - call mpi_allreduce(MPI_IN_PLACE, b, 1, MPI_DOUBLE_PRECISION, MPI_SUM, self%x%info%comm, ierr) - - call amp%dealloc(); deallocate(amp) - call invN_amp%dealloc(); deallocate(invN_amp) - - ! Compute new line ratio; just root processor - if (self%x%info%myid == 0) then - - if (A > 0.d0) then - mu = b / A - sigma = sqrt(1.d0 / A) - else if (self%p_gauss(2,id) > 0.d0) then - mu = 0.d0 - sigma = 1.d30 - else - mu = self%p_uni(1,id) + (self%p_uni(2,id)-self%p_uni(1,id))*rand_uni(handle) - sigma = 0.d0 - end if - - ! Add prior - if (self%p_gauss(2,id) > 0.d0) then - sigma_p = self%p_gauss(2,id) !/ sqrt(real(npix_reg,dp)) - mu = (mu*sigma_p**2 + self%p_gauss(1,id) * sigma**2) / (sigma_p**2 + sigma**2) - sigma = sqrt(sigma**2 * sigma_p**2 / (sigma**2 + sigma_p**2)) - end if - - ! Draw sample - par = -1.d300 - if (trim(self%operation) == 'optimize') then - if (mu < self%p_uni(1,id)) then - par = self%p_uni(1,id) - else if (mu > self%p_uni(2,id)) then - par = self%p_uni(2,id) - else - par = mu - end if - else - do while (par < self%p_uni(1,id) .or. par > self%p_uni(2,id)) - if (mu < self%p_uni(1,id)) then - par = rand_trunc_gauss(handle, mu, self%p_uni(1,id), sigma) - else if (mu > self%p_uni(2,id)) then - par = 2.d0*mu-rand_trunc_gauss(handle, mu, 2.d0*mu-self%p_uni(2,id), sigma) - else - par = mu + sigma * rand_gauss(handle) - end if - end do - end if - - if (band == self%ref_band) then - write(*,*) ' Line ratio i = ', id, ' = ', par, ' (at refband)' - else - write(*,*) ' Line ratio i = ', id, ' = ', par - end if - end if - - ! Distribute new relative line ratio, and update - call mpi_bcast(par, 1, MPI_DOUBLE_PRECISION, 0, self%x%info%comm, ierr) - - if (band == self%ref_band) then - self%x%map = self%x%map * par ! Rescale amplitude map, but leave mixing matrix - self%x%alm = self%x%alm * par - do i = 1, self%npar ! Rescale line ratios at other frequencies - if (self%ind2band(i) == self%ref_band) cycle - self%theta(i)%p%map = self%theta(i)%p%map / par - if (self%lmax_ind >= 0) then - self%theta(i)%p%alm(:,1) = self%theta(i)%p%alm(:,1) / par - end if - end do - else - self%theta(id)%p%map = par - if (self%lmax_ind >= 0) then - self%theta(id)%p%alm(:,1) = par * sqrt(4.d0*pi) - end if - end if - call self%updateMixmat() - - end subroutine sampleLineRatios - - ! update the mixing matrix, assumes only temperature and constant across the whole map - subroutine updateMixmatLineRatios(self, theta, beta, band, df, par) implicit none class(comm_line_comp), intent(inout) :: self @@ -820,8 +478,6 @@ end subroutine updateMixmatLineRatios - end module comm_line_comp_mod - - +end module comm_line_comp_mod ->>>>>> devel + From dce9989a52c05084ea8bc9c2d291282c75eb9be7 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 25 Jun 2025 22:19:02 +0200 Subject: [PATCH 166/171] Fixed initialization issues --- .../parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults | 2 +- commander3/src/comm_cmb_comp_mod.f90 | 2 ++ commander3/src/comm_diffuse_comp_smod.f90 | 4 ++-- commander3/src/comm_ptsrc_comp_mod.f90 | 5 +---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults index a1c00c3d4..1739a9cb2 100644 --- a/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults +++ b/commander3/parameter_files/defaults/bands/LFI/LFI_030_TOD.defaults @@ -39,7 +39,7 @@ BAND_TOD_BP_INIT_PROP&&& = bp_init_030_v1.dat BAND_TOD_HALFRING&&& = 0 BAND_TOD_START_SCANID&&& = 3 BAND_TOD_END_SCANID&&& = 44072 -BAND_TOD_TOT_NUMSCAN&&& = 44070 +BAND_TOD_TOT_NUMSCAN&&& = 45860 BAND_TOD_FLAG&&& = 6111232 BAND_TOD_ABSCAL_COMP&&& = full BAND_TOD_DETECTOR_LIST&&& = 27M,27S,28M,28S diff --git a/commander3/src/comm_cmb_comp_mod.f90 b/commander3/src/comm_cmb_comp_mod.f90 index 5bfeef186..7dc933eab 100644 --- a/commander3/src/comm_cmb_comp_mod.f90 +++ b/commander3/src/comm_cmb_comp_mod.f90 @@ -58,6 +58,8 @@ function constructor_cmb(cpar, id, id_abs) result(c) allocate(c) c%npar = 0 call c%initDiffuse(cpar, id, id_abs) + call c%initLmaxSpecind(cpar, id, id_abs) + ! Precompute mixmat integrator for each band allocate(c%F_int(3,numband,0:c%ndet)) diff --git a/commander3/src/comm_diffuse_comp_smod.f90 b/commander3/src/comm_diffuse_comp_smod.f90 index 47c8977fa..92e90ba0a 100644 --- a/commander3/src/comm_diffuse_comp_smod.f90 +++ b/commander3/src/comm_diffuse_comp_smod.f90 @@ -355,8 +355,8 @@ module subroutine initLmaxSpecind(self, cpar, id, id_abs) if (self%npar==0) then allocate(self%lmax_ind_mix(3,1)) - self%lmax_ind = cpar%cs_lmax_ind_pol(p,i,id_abs) - self%lmax_ind_mix = cpar%cs_lmax_ind_pol(p,i,id_abs) + self%lmax_ind = 0 + self%lmax_ind_mix = 0 return !do not go further, lmax_ind is set in initDiffuse end if diff --git a/commander3/src/comm_ptsrc_comp_mod.f90 b/commander3/src/comm_ptsrc_comp_mod.f90 index 3e628661f..b0b3a6a44 100644 --- a/commander3/src/comm_ptsrc_comp_mod.f90 +++ b/commander3/src/comm_ptsrc_comp_mod.f90 @@ -2934,9 +2934,6 @@ subroutine updatePtsrcFInt(self, band) if(self%precomputed_amps) return - nmaps = data(band)%info%nmaps - if(nmaps > 3) nmaps = 3 - if (present(band)) then nmaps = data(band)%info%nmaps if(nmaps > 3) nmaps = 3 @@ -2951,7 +2948,7 @@ subroutine updatePtsrcFInt(self, band) do k = 1, numband if (self%F_null(k)) cycle ka = self%b2a(k) - nmaps = data(band)%info%nmaps + nmaps = data(k)%info%nmaps if(nmaps > 3) nmaps = 3 do i = 1, nmaps do j = 0, data(k)%ndet From eae3a29a453d833eb7eb24048158aff4d718a6bd Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 26 Jun 2025 21:57:24 +0200 Subject: [PATCH 167/171] Removed debugging test erroneously left out --- commander3/src/comm_tod_lfi_smod.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commander3/src/comm_tod_lfi_smod.f90 b/commander3/src/comm_tod_lfi_smod.f90 index ebe347bfa..b15e9b284 100644 --- a/commander3/src/comm_tod_lfi_smod.f90 +++ b/commander3/src/comm_tod_lfi_smod.f90 @@ -818,8 +818,8 @@ module subroutine process_lfi_tod(self, chaindir, chain, iter, handle, map_in, d else call sample_n_corr(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr, sd%pix(:,:,1), dospike=.true.) end if - sd%n_corr = 0. - sd%s_bp = 0. + !sd%n_corr = 0. + !sd%s_bp = 0. ! Compute noise spectrum parameters call sample_noise_psd(self, sd%tod, handle, i, sd%mask, sd%s_tot, sd%n_corr) From b2cbb41aa277434621c96259d149460af7aea2eb Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 29 Jun 2025 20:50:23 +0200 Subject: [PATCH 168/171] Explicitly initializing d_calib to zero to avoid nan's later --- commander3/src/comm_tod_driver_mod.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index f535a02f1..aa7774518 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -999,6 +999,7 @@ subroutine compute_calibrated_data(tod, scan, sd, d_calib, jump_template) ! write(*, *) "s_bp:", sd%s_sky(:,1) call timer%start(TOD_MAPBIN, tod%band) nout = size(d_calib,1) + d_calib = 0d0 do j = 1, sd%ndet if (.not. tod%scans(scan)%d(j)%accept) cycle inv_gain = 1.0 / tod%scans(scan)%d(j)%gain From 3e994724cf81db5d29137a4cffd10ab4f9e467ff Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 29 Jun 2025 22:22:45 +0200 Subject: [PATCH 169/171] Added status check for readin, changed call for zipped tod to match WMAP's standard. --- commander3/src/comm_hdf_mod.f90 | 1 + commander3/src/comm_tod_driver_mod.f90 | 2 +- commander3/src/comm_tod_gain_smod.f90 | 2 +- commander3/src/comm_tod_mod.f90 | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_hdf_mod.f90 b/commander3/src/comm_hdf_mod.f90 index 61c2d4ce6..786cf42ee 100644 --- a/commander3/src/comm_hdf_mod.f90 +++ b/commander3/src/comm_hdf_mod.f90 @@ -2579,6 +2579,7 @@ subroutine read_hdf_opaque(file, setname, val) call open_hdf_set(file, setname) call h5dget_type_f(file%sethandle, dtype, file%status) call h5tget_size_f(dtype, len, file%status) + call assert(file%status>=0, "comm_hdf_mod: Cannot read data from hdf set " // setname // ' from file ' // trim(file%filename)) numint = len allocate(val(numint)) f_ptr = c_loc(val) diff --git a/commander3/src/comm_tod_driver_mod.f90 b/commander3/src/comm_tod_driver_mod.f90 index aa7774518..08297a4c8 100644 --- a/commander3/src/comm_tod_driver_mod.f90 +++ b/commander3/src/comm_tod_driver_mod.f90 @@ -713,7 +713,7 @@ subroutine sample_calibration(tod, mode, handle, map_sky, map_gain, procmask, pr do i = 1, tod%nscan if (.not. any(tod%scans(i)%d%accept)) then - write(*,*) ' No accepted samples in scan = ', tod%scanid(i) + ! write(*,*) ' No accepted samples in scan = ', tod%scanid(i) cycle end if call wall_time(t1) diff --git a/commander3/src/comm_tod_gain_smod.f90 b/commander3/src/comm_tod_gain_smod.f90 index 0fa2cf512..705deec56 100644 --- a/commander3/src/comm_tod_gain_smod.f90 +++ b/commander3/src/comm_tod_gain_smod.f90 @@ -477,7 +477,7 @@ module subroutine sample_abscal_from_orbital(tod, handle, A_abs, b_abs) tod%gain0(0) = tod%gain0(0) + 1.d0/sqrt(sum(A)) * rand_gauss(handle) end if if (tod%verbosity > 1) then - write(*,*) ' | abscal = ', tod%gain0(0) + write(*,*) '| abscal = ', tod%gain0(0) !write(*,*) 'sum(b), sum(A) = ', sum(b), sum(A) end if end if diff --git a/commander3/src/comm_tod_mod.f90 b/commander3/src/comm_tod_mod.f90 index 94d64d340..853ede730 100644 --- a/commander3/src/comm_tod_mod.f90 +++ b/commander3/src/comm_tod_mod.f90 @@ -1343,7 +1343,7 @@ subroutine read_hdf_scan_data(self, tod, filename, scan, ndet, detlabels, nhorn, field = detlabels(i) if(ndiode == 1) then if (tod%compressed_tod) then - call read_hdf_opaque(file, slabel // "/" // trim(field) // "/tod", self%d(i)%ztod) + call read_hdf_opaque(file, slabel // "/" // trim(field) // "/ztod", self%d(i)%ztod) else allocate(self%d(i)%tod(m)) call read_hdf(file, slabel // "/" // trim(field) // "/tod", buffer_sp) From a7c33da05f938ced16a82a0ab70ea1e8cc336a2d Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Wed, 20 Aug 2025 10:34:47 +0200 Subject: [PATCH 170/171] Fixed memory leak in comm_map_mod --- commander3/src/comm_map_mod.f90 | 1 + commander3/src/comm_zodi_mod.f90 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/commander3/src/comm_map_mod.f90 b/commander3/src/comm_map_mod.f90 index 035c79540..50567ae9d 100644 --- a/commander3/src/comm_map_mod.f90 +++ b/commander3/src/comm_map_mod.f90 @@ -435,6 +435,7 @@ subroutine deallocate_comm_map(self) if (allocated(self%map)) deallocate(self%map) if (allocated(self%alm)) deallocate(self%alm) + if (allocated(self%alm_buff)) deallocate(self%alm_buff) nullify(self%info) if (associated(self%nextLink)) then diff --git a/commander3/src/comm_zodi_mod.f90 b/commander3/src/comm_zodi_mod.f90 index 76eb07efd..6065f150f 100644 --- a/commander3/src/comm_zodi_mod.f90 +++ b/commander3/src/comm_zodi_mod.f90 @@ -324,7 +324,7 @@ subroutine init_general_priors_and_scales(self, prior, scale) prior(:,1) = [250.d0, 330.d0, 286.d0, 5.d0] ! T_0 scale(1,:) = [286.d0, 3.d0] - prior(:,2) = [0.4d0, 0.5d0, 0.467d0, 0.004d0] ! delta + prior(:,2) = [0.3d0, 0.5d0, 0.467d0, 0.004d0] ! delta scale(2,:) = [0.4d0, 0.01d0] prior(:,3) = [-1d0, 1d0, 0.70d0, 0.1d0] ! g_1 scale(3,:) = [1d0, 0.01d0] From 13ddb47f2d6120eedbf234434ae7b560ca40ad29 Mon Sep 17 00:00:00 2001 From: Hans Kristian Eriksen Date: Tue, 2 Dec 2025 11:16:29 +0100 Subject: [PATCH 171/171] Disabled MH step readjustment, and added Duncan's memory leak fix --- commander3/src/comm_mh_specind_mod.f90 | 2 +- commander3/src/comm_n_rms_mod.f90 | 2 +- commander3/src/comm_n_rms_qucov_mod.f90 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commander3/src/comm_mh_specind_mod.f90 b/commander3/src/comm_mh_specind_mod.f90 index 2ae01d782..b015564cd 100644 --- a/commander3/src/comm_mh_specind_mod.f90 +++ b/commander3/src/comm_mh_specind_mod.f90 @@ -358,7 +358,7 @@ subroutine sample_mbbtab_mh(outdir, cpar, handle, handle_noise, l) if (cpar%myid == 0) then write(*,fmt='(a,i3,a,a)') ' | MH MBBtab sampling group ', l, ', active CG sampling groups = ', trim(cpar%mcmc_update_cg_groups(l)) - if (mh_accept_stat(l,1) > 30 .and. real(mh_accept_stat(l,2),sp)/mh_accept_stat(l,1) < 0.1d0) then + if (.false. .and. mh_accept_stat(l,1) > 30 .and. real(mh_accept_stat(l,2),sp)/mh_accept_stat(l,1) < 0.1d0) then write(*,*) 'MH MBBtab ADJUSTING STEP LENGTH for group', l mh_scale(l) = mh_scale(l) / 2. mh_accept_stat(l,:) = 0 diff --git a/commander3/src/comm_n_rms_mod.f90 b/commander3/src/comm_n_rms_mod.f90 index 3627e1c0c..8adf1fbb2 100644 --- a/commander3/src/comm_n_rms_mod.f90 +++ b/commander3/src/comm_n_rms_mod.f90 @@ -162,7 +162,7 @@ subroutine update_N_rms(self, info, handle, mask, regnoise, procmask, noisefile, if (present(noisefile)) then self%rms0 => comm_map(info, noisefile) else if (present(map)) then - self%rms0 => comm_map(info) + if (.not. associated(self%rms0)) self%rms0 => comm_map(info) self%rms0%map = map%map else call report_error('Error in update_N_rms - no noisefile or map declared') diff --git a/commander3/src/comm_n_rms_qucov_mod.f90 b/commander3/src/comm_n_rms_qucov_mod.f90 index 5b472217e..7a882a6d4 100644 --- a/commander3/src/comm_n_rms_qucov_mod.f90 +++ b/commander3/src/comm_n_rms_qucov_mod.f90 @@ -181,7 +181,7 @@ subroutine update_N_rms_QUcov(self, info, handle, mask, regnoise, procmask, nois if (present(noisefile)) then self%N_map => comm_map(info, noisefile) else if (present(map)) then - self%N_map => comm_map(info) + if (.not. associated(self%N_map)) self%N_map => comm_map(info) if (map%info%nmaps == 3) then self%N_map%map(:,1:3) = map%map self%N_map%map(:,4) = 0