@@ -3,7 +3,6 @@ module simple_commanders_rec
33use simple_commanders_api
44use simple_matcher_2Dprep
55use simple_matcher_3Drec, only: calc_3Drec, calc_projdir3Drec
6- use simple_refine3D_fnames, only: refine3D_fsc_fname, refine3D_state_halfvol_fname, refine3D_state_vol_fname
76use simple_sigma2_files, only: load_sigma2_groups
87implicit none
98#include " simple_local_flags.inc"
@@ -13,11 +12,6 @@ module simple_commanders_rec
1312 procedure :: execute = > exec_rec3D
1413end type commander_rec3D
1514
16- type, extends(commander_base) :: commander_bootstrap_rec3D
17- contains
18- procedure :: execute = > exec_bootstrap_rec3D
19- end type commander_bootstrap_rec3D
20-
2115type, extends(commander_base) :: commander_rec3D_worker
2216 contains
2317 procedure :: execute = > exec_rec3D_distr_worker
@@ -59,164 +53,6 @@ subroutine exec_rec3D( self, cline )
5953 if ( allocated (strategy) ) deallocate (strategy)
6054 end subroutine exec_rec3D
6155
62- subroutine exec_bootstrap_rec3D ( self , cline )
63- use simple_commanders_euclid, only: commander_calc_pspec
64- class(commander_bootstrap_rec3D), intent (inout ) :: self
65- class(cmdline), intent (inout ) :: cline
66- type (commander_rec3D) :: xrec3D
67- type (commander_calc_pspec) :: xcalc_pspec
68- type (cmdline) :: cline_reg, cline_pspec
69- type (parameters) :: params
70- integer :: state, which_iter
71- if ( .not. cline% defined(' mkdir' ) ) call cline% set(' mkdir' , ' yes' )
72- call cline% set(' oritype' , ' ptcl3D' )
73- if ( .not. cline% defined(' nstates' ) ) call cline% set(' nstates' , 1 )
74- call warn_for_forced_bootstrap_overrides(cline)
75- call cline% set(' sigma_est' , ' global' )
76- if ( .not. cline% defined(' which_iter' ) ) call cline% set(' which_iter' , 1 )
77- if ( .not. cline% defined(' postprocess' ) ) call cline% set(' postprocess' , ' yes' )
78- if ( .not. cline% defined(' combine_eo' ) ) call cline% set(' combine_eo' , ' no' )
79- if ( .not. cline% defined(' envfsc' ) ) call cline% set(' envfsc' , ' no' )
80- call cline% delete (' objfun' )
81- call cline% delete (' ml_reg' )
82- call params% new (cline)
83- which_iter = max (1 , params% which_iter)
84- call cline% set(' which_iter' , which_iter)
85- call cline% set(' mkdir' , ' no' ) ! child reconstruct3D calls must not create nested run directories
86- ! One sigma2 basis for every bootstrap (2026-09-06): the particle
87- ! power spectra, exactly what a fresh refinement seeds from, written
88- ! as the grouped STAR of which_iter (legacy store) or the registered
89- ! canonical state. The former half-map power estimator sat on a
90- ! different basis than the residual sigmas a refinement then computes
91- ! and conditioned the euclid system markedly worse (bgal residual
92- ! 0.23 vs 0.08, refine3D_auto startup record). With the seed in hand
93- ! the reconstruction is a single euclid ML-regularized pass; callers
94- ! that ship a final map upgrade the seed with a residual pass
95- ! (simple_sigma2_bootstrap).
96- cline_pspec = cline
97- call cline_pspec% set(' prg' , ' calc_pspec' )
98- call cline_pspec% set(' mkdir' , ' no' )
99- call cline_pspec% set(' objfun' , ' euclid' )
100- call cline_pspec% set(' sigma_est' , ' global' )
101- call cline_pspec% set(' which_iter' , which_iter)
102- call cline_pspec% delete (' postprocess' )
103- call cline_pspec% delete (' combine_eo' )
104- call cline_pspec% delete (' rec_backend' )
105- call cline_pspec% delete (' maxits_pcg' )
106- call cline_pspec% delete (' rtol' )
107- call cline_pspec% delete (' trail_seed' )
108- call cline_pspec% delete (' outfile' )
109- write (logfhandle,' (A,I0)' ) ' >>> BOOTSTRAP_REC3D SIGMA2 FROM PARTICLE POWER SPECTRA, ITERATION ' , which_iter
110- call xcalc_pspec% execute(cline_pspec)
111- call cline_pspec% kill
112- cline_reg = cline
113- call prepare_bootstrap_rec_cline(cline_reg, l_regularized= .true. )
114- write (logfhandle,' (A)' ) ' >>> BOOTSTRAP_REC3D: EUCLID ML-REGULARIZED RECONSTRUCTION'
115- call xrec3D% execute(cline_reg)
116- call register_bootstrap_rec_outputs()
117- do state = 1 , params% nstates
118- call cline% set(' vol' // int2str(state), refine3D_state_vol_fname(state))
119- enddo
120- call cline_reg% kill
121- call simple_end(' **** SIMPLE_BOOTSTRAP_REC3D NORMAL STOP ****' , print_simple= .false. )
122-
123- contains
124-
125- subroutine prepare_bootstrap_rec_cline ( cline_rec , l_regularized )
126- class(cmdline), intent (inout ) :: cline_rec
127- logical , intent (in ) :: l_regularized
128- integer :: state
129- call cline_rec% set(' prg' , ' reconstruct3D' )
130- call cline_rec% set(' mkdir' , ' no' )
131- call cline_rec% set(' oritype' , params% oritype)
132- call cline_rec% set(' nstates' , params% nstates)
133- call cline_rec% set(' sigma_est' , ' global' )
134- call cline_rec% set(' which_iter' , which_iter)
135- call cline_rec% set(' trail_rec' , ' no' )
136- call cline_rec% set(' combine_eo' , ' no' )
137- call cline_rec% delete (' refine' )
138- call cline_rec% delete (' update_frac' )
139- call cline_rec% delete (' fillin' )
140- call cline_rec% delete (' objfun_den' )
141- call cline_rec% delete (' objfun_den_w' )
142- call cline_rec% delete (' ufrac_trec' )
143- call cline_rec% delete (' endit' )
144- call cline_rec% delete (' vol_even' )
145- call cline_rec% delete (' vol_odd' )
146- call cline_rec% delete (' refs' )
147- call cline_rec% delete (' refs_even' )
148- call cline_rec% delete (' refs_odd' )
149- do state = 1 , params% nstates
150- call cline_rec% delete (' vol' // int2str(state))
151- enddo
152- if ( l_regularized )then
153- call cline_rec% set(' objfun' , ' euclid' )
154- call cline_rec% set(' ml_reg' , ' yes' )
155- else
156- call cline_rec% set(' objfun' , ' cc' )
157- call cline_rec% set(' ml_reg' , ' no' )
158- call cline_rec% set(' postprocess' , ' no' )
159- call cline_rec% set(' filt_mode' , ' none' )
160- call cline_rec% set(' automsk' , ' no' )
161- endif
162- end subroutine prepare_bootstrap_rec_cline
163-
164-
165- subroutine register_bootstrap_rec_outputs ()
166- type (sp_project) :: spproj
167- type (string) :: volname, fscname
168- integer :: state, pop
169- character (len= 16 ) :: imgkind
170- call spproj% read_segment(' out' , params% projfile)
171- call spproj% read_segment(params% oritype, params% projfile)
172- select case (trim (params% oritype))
173- case (' cls3D' )
174- imgkind = ' vol_cavg'
175- case DEFAULT
176- imgkind = ' vol'
177- end select
178- do state = 1 , params% nstates
179- select case (trim (params% oritype))
180- case (' cls3D' )
181- pop = spproj% os_cls3D% get_pop(state, ' state' )
182- case DEFAULT
183- pop = spproj% os_ptcl3D% get_pop(state, ' state' )
184- end select
185- if ( pop == 0 )cycle
186- volname = refine3D_state_vol_fname(state)
187- if ( .not. file_exists(volname) )then
188- call volname% kill
189- cycle
190- endif
191- fscname = refine3D_fsc_fname(state)
192- ! params%box_crop/smpd_crop are the effective reconstruction
193- ! sampling resolved by params%new or explicitly pinned by
194- ! callers that must avoid staged downsampling leakage.
195- call spproj% add_vol2os_out(volname, params% smpd_crop, state, trim (imgkind), pop= pop)
196- if ( file_exists(fscname) ) call spproj% add_fsc2os_out(fscname, state, params% box_crop)
197- call volname% kill
198- call fscname% kill
199- enddo
200- call spproj% write_segment_inside(' out' , params% projfile)
201- call spproj% kill
202- end subroutine register_bootstrap_rec_outputs
203-
204-
205- subroutine warn_for_forced_bootstrap_overrides ( cline_in )
206- class(cmdline), intent (inout ) :: cline_in
207- type (string) :: val
208- if ( cline_in% defined(' sigma_est' ) )then
209- val = cline_in% get_carg(' sigma_est' )
210- if ( val% to_char().ne. ' global' )then
211- THROW_WARN(' bootstrap_rec3D enforces sigma_est=global; ignoring input sigma_est=' // val% to_char())
212- endif
213- call val% kill
214- endif
215- if ( cline_in% defined(' objfun' ) ) THROW_WARN(' bootstrap_rec3D controls objfun internally; ignoring input objfun' )
216- if ( cline_in% defined(' ml_reg' ) ) THROW_WARN(' bootstrap_rec3D controls ml_reg internally; ignoring input ml_reg' )
217- end subroutine warn_for_forced_bootstrap_overrides
218- end subroutine exec_bootstrap_rec3D
219-
22056 subroutine exec_rec3D_distr_worker ( self , cline )
22157 use simple_rec3D_pcg_strategy, only: execute_rec3D_pcg_worker
22258 class(commander_rec3D_worker), intent (inout ) :: self
0 commit comments