@@ -265,7 +265,7 @@ namespace BasisClasses
265265 if (conf[" EVEN_M" ]) EVEN_M = conf[" EVEN_M" ].as <bool >();
266266 if (conf[" M0_ONLY" ]) M0_only = conf[" M0_ONLY" ].as <bool >();
267267 if (conf[" pcavar" ]) pcavar = conf[" pcavar" ].as <bool >();
268- if (conf[" sampT " ]) sampT = conf[" sampT " ].as <int >();
268+ if (conf[" subsamp " ]) sampT = conf[" subsamp " ].as <int >();
269269 }
270270 catch (YAML ::Exception & error) {
271271 if (myid==0 ) std::cout << " Error parsing parameter stanza for <"
@@ -568,7 +568,8 @@ namespace BasisClasses
568568 coefctr = {0.0 , 0.0 , 0.0 };
569569 }
570570
571- void Spherical::accumulate (double x, double y, double z, double mass)
571+ void Spherical::accumulate (double x, double y, double z, double mass,
572+ unsigned long indx)
572573 {
573574 double fac, fac1, fac2, fac4;
574575 double norm = -4.0 *M_PI ;
@@ -1444,6 +1445,8 @@ namespace BasisClasses
14441445 if (unmatched.size ())
14451446 throw YamlConfigError (" Basis::Basis::Cylindrical" , " parameter" , unmatched, __FILE__, __LINE__);
14461447
1448+ int sampT = 0 ;
1449+
14471450 // Assign values from YAML
14481451 //
14491452 try {
@@ -1495,6 +1498,7 @@ namespace BasisClasses
14951498 if (conf[" vflag" ]) vflag = conf[" vflag" ].as <int >();
14961499 if (conf[" pyname" ]) pyname = conf[" pyname" ].as <std::string>();
14971500 if (conf[" pcavar" ] ) pcavar = conf[" pcavar" ].as <bool >();
1501+ if (conf[" subsamp" ] ) sampT = conf[" subsamp" ].as <int >();
14981502
14991503 // Deprecation warning
15001504 if (conf[" density" ]) {
@@ -1544,6 +1548,7 @@ namespace BasisClasses
15441548 EmpCylSL::CMAPZ = cmapZ;
15451549 EmpCylSL::logarithmic = logarithmic;
15461550 EmpCylSL::VFLAG = vflag;
1551+ EmpCylSL::PCAVAR = pcavar;
15471552
15481553 // Check for non-null cache file name. This must be specified
15491554 // to prevent recomputation and unexpected behavior.
@@ -1566,7 +1571,11 @@ namespace BasisClasses
15661571 //
15671572 if (mlim>=0 ) sl->set_mlim (mlim);
15681573 if (EVEN_M ) sl->setEven (EVEN_M );
1569-
1574+ if (sampT>0 ) {
1575+ sl->setSampT (sampT);
1576+ sl->init_pca ();
1577+ }
1578+
15701579 // Cache override for old Eigen cache
15711580 //
15721581 if (oldcache) sl->AllowOldCache ();
@@ -1790,11 +1799,12 @@ namespace BasisClasses
17901799 }
17911800 }
17921801
1793- void Cylindrical::accumulate (double x, double y, double z, double mass)
1802+ void Cylindrical::accumulate (double x, double y, double z, double mass,
1803+ unsigned long indx)
17941804 {
17951805 double R = sqrt (x*x + y*y);
17961806 double phi = atan2 (y, x);
1797- sl->accumulate (R, z, phi, mass, 0 , 0 );
1807+ sl->accumulate (R, z, phi, mass, indx, 0 , 0 , pcavar );
17981808 }
17991809
18001810 void Cylindrical::reset_coefs (void )
@@ -1857,7 +1867,7 @@ namespace BasisClasses
18571867
18581868 void Cylindrical::make_coefs (void )
18591869 {
1860- sl->make_coefficients ();
1870+ sl->make_coefficients (pcavar );
18611871 }
18621872
18631873
@@ -2170,7 +2180,8 @@ namespace BasisClasses
21702180 coefctr = {0.0 , 0.0 , 0.0 };
21712181 }
21722182
2173- void FlatDisk::accumulate (double x, double y, double z, double mass)
2183+ void FlatDisk::accumulate (double x, double y, double z, double mass,
2184+ unsigned long indx)
21742185 {
21752186 // Normalization factors
21762187 //
@@ -2974,7 +2985,8 @@ namespace BasisClasses
29742985 coefctr = {0.0 , 0.0 , 0.0 };
29752986 }
29762987
2977- void CBDisk::accumulate (double x, double y, double z, double mass)
2988+ void CBDisk::accumulate (double x, double y, double z, double mass,
2989+ unsigned long int idx)
29782990 {
29792991 // Normalization factors
29802992 //
@@ -3432,7 +3444,8 @@ namespace BasisClasses
34323444 coefctr = {0.0 , 0.0 , 0.0 };
34333445 }
34343446
3435- void Slab::accumulate (double x, double y, double z, double mass)
3447+ void Slab::accumulate (double x, double y, double z, double mass,
3448+ unsigned long int idx)
34363449 {
34373450 // Truncate to slab with sides in [0,1]
34383451 if (x<0.0 )
@@ -3949,7 +3962,8 @@ namespace BasisClasses
39493962 coefctr = {0.0 , 0.0 , 0.0 };
39503963 }
39513964
3952- void Cube::accumulate (double x, double y, double z, double mass)
3965+ void Cube::accumulate (double x, double y, double z, double mass,
3966+ unsigned long int indx)
39533967 {
39543968 // Truncate to cube with sides in [0,1]
39553969 if (x<0.0 )
@@ -4179,7 +4193,7 @@ namespace BasisClasses
41794193 }
41804194
41814195 if (use) {
4182- accumulate (pp (0 ), pp (1 ), pp (2 ), p->mass );
4196+ accumulate (pp (0 ), pp (1 ), pp (2 ), p->mass , p-> indx );
41834197 }
41844198 }
41854199 make_coefs ();
@@ -4298,7 +4312,7 @@ namespace BasisClasses
42984312 coefindx++;
42994313
43004314 if (use) {
4301- accumulate (pp (0 ), pp (1 ), pp (2 ), m (n));
4315+ accumulate (pp (0 ), pp (1 ), pp (2 ), m (n), n );
43024316 }
43034317 }
43044318 }
@@ -4336,7 +4350,7 @@ namespace BasisClasses
43364350 coefindx++;
43374351
43384352 if (use) {
4339- accumulate (pp (0 ), pp (1 ), pp (2 ), m (n));
4353+ accumulate (pp (0 ), pp (1 ), pp (2 ), m (n), n );
43404354 }
43414355 }
43424356 }
@@ -4826,6 +4840,7 @@ namespace BasisClasses
48264840
48274841 // Add a time attribute
48284842 //
4843+ time = roundTime (time);
48294844 stanza.createAttribute <double >(" Time" , HighFive::DataSpace::From (time)).write (time);
48304845
48314846 // Add the sample statistics
@@ -4903,14 +4918,22 @@ namespace BasisClasses
49034918 return ;
49044919 }
49054920
4921+ // Round time
4922+ //
4923+ time = roundTime (time);
4924+
49064925 // The H5 filename
4926+ //
49074927 std::string fname = " coefcovar." + compname + " ." + runtag + " .h5" ;
49084928
49094929 // Check if file exists?
49104930 //
49114931 try {
4912- // Open the HDF5 file in read-only mode
4913- HighFive::File file (fname, HighFive::File::ReadOnly);
4932+ // Open the HDF5 file in read-write mode, creating if it doesn't
4933+ // exist
4934+ HighFive::File file (fname,
4935+ HighFive::File::ReadWrite |
4936+ HighFive::File::Create);
49144937
49154938 // Check for version string
49164939 std::string path = " CovarianceFileVersion" ;
@@ -4921,23 +4944,6 @@ namespace BasisClasses
49214944 return ;
49224945 }
49234946
4924- } catch (const HighFive::Exception& err) {
4925- // Handle HighFive specific errors (e.g., file not found)
4926- std::cerr << " HighFive Error: " << err.what () << std::endl;
4927- } catch (const std::exception& err) {
4928- // Handle other general exceptions
4929- std::cerr << " Error: " << err.what () << std::endl;
4930- }
4931-
4932- // Write coefficients
4933- //
4934- try {
4935- // Create a new hdf5 file
4936- //
4937- HighFive::File file (fname,
4938- HighFive::File::ReadWrite |
4939- HighFive::File::Create);
4940-
49414947 // Write the Version string
49424948 //
49434949 file.createAttribute <std::string>(" CovarianceFileVersion" , HighFive::DataSpace::From (CovarianceFileVersion)).write (CovarianceFileVersion);
@@ -4967,8 +4973,14 @@ namespace BasisClasses
49674973 //
49684974 dataset.write (count);
49694975
4970- } catch (HighFive::Exception& err) {
4971- std::cerr << err.what () << std::endl;
4976+ } catch (const HighFive::Exception& err) {
4977+ // Handle HighFive specific errors (e.g., file not found)
4978+ throw std::runtime_error
4979+ (std::string (" BiorthBasis::writeCoefCovariance HighFive Error: " ) + err.what ());
4980+ } catch (const std::exception& err) {
4981+ // Handle other general exceptions
4982+ throw std::runtime_error
4983+ (std::string (" BiorthBasis::writeCoefCovariance Error: " ) + err.what ());
49724984 }
49734985 }
49744986
@@ -4996,7 +5008,8 @@ namespace BasisClasses
49965008 dataset.write (count);
49975009
49985010 } catch (HighFive::Exception& err) {
4999- std::cerr << err.what () << std::endl;
5011+ throw std::runtime_error
5012+ (std::string (" BiorthBasis::extendCoefCovariance: HighFive error: " ) + err.what ());
50005013 }
50015014 }
50025015
0 commit comments