@@ -15,11 +15,12 @@ void ParticleReaderClasses(py::module &m) {
1515 " The available particle readers are:\n "
1616 " 1. PSPout The monolithic EXP phase-space snapshot format\n "
1717 " 2. PSPspl Like PSPout, but split into multiple file chunks\n "
18- " 3. GadgetNative The original Gadget native format\n "
19- " 4 GadgetHDF5 The newer HDF5 Gadget format\n "
20- " 5. TipsyNative The original Tipsy format\n "
21- " 6. TipsyXDR The original XDR Tipsy format\n "
22- " 7. Bonsai This is the Bonsai varient of Tipsy files\n\n "
18+ " 3. PSPhdf5 The HDF5 version of the EXP phase-space format\n "
19+ " 4. GadgetNative The original Gadget native format\n "
20+ " 5 GadgetHDF5 The newer HDF5 Gadget format\n "
21+ " 6. TipsyNative The original Tipsy format\n "
22+ " 7. TipsyXDR The original XDR Tipsy format\n "
23+ " 8. Bonsai This is the Bonsai varient of Tipsy files\n\n "
2324 " We have a helper function, getReaders, to get a list to help you\n "
2425 " remember. Try: pyEXP.read.ParticleReader.getReaders()\n\n "
2526 " Each reader can manage snapshots split into many files by parallel,\n "
@@ -216,6 +217,38 @@ void ParticleReaderClasses(py::module &m) {
216217 }
217218 };
218219
220+ class PyPSPhdf5 : public PSPhdf5
221+ {
222+ public:
223+
224+ // Inherit the constructors
225+ using PSPhdf5::PSPhdf5;
226+
227+ void SelectType (const std::string& type) override {
228+ PYBIND11_OVERRIDE (void , PSPhdf5, SelectType, type);
229+ }
230+
231+ std::vector<std::string> GetTypes () override {
232+ PYBIND11_OVERRIDE (std::vector<std::string>, PSPhdf5, GetTypes,);
233+ }
234+
235+ unsigned long CurrentNumber () override {
236+ PYBIND11_OVERRIDE (unsigned long , PSPhdf5, CurrentNumber,);
237+ }
238+
239+ double CurrentTime () override {
240+ PYBIND11_OVERRIDE (double , PSPhdf5, CurrentTime,);
241+ }
242+
243+ const Particle* firstParticle () override {
244+ PYBIND11_OVERRIDE (const Particle*, PSPhdf5, firstParticle,);
245+ }
246+
247+ const Particle* nextParticle () override {
248+ PYBIND11_OVERRIDE (const Particle*, PSPhdf5, nextParticle,);
249+ }
250+ };
251+
219252 class PyTipsy : public Tipsy
220253 {
221254 public:
@@ -401,8 +434,8 @@ void ParticleReaderClasses(py::module &m) {
401434 pr.def_static (" getReaders" , []()
402435 {
403436 const std::vector<std::string> formats = {
404- " PSPout" , " PSPspl" , " GadgetNative " , " GadgetHDF5 " , " TipsyNative " ,
405- " TipsyXDR" , " Bonsai" };
437+ " PSPout" , " PSPspl" , " PSPhdf5 " , " GadgetNative " , " GadgetHDF5 " ,
438+ " TipsyNative " , " TipsyXDR" , " Bonsai" };
406439
407440 return formats;
408441 },
@@ -431,7 +464,7 @@ void ParticleReaderClasses(py::module &m) {
431464 Returns
432465 -------
433466 ParticleReader
434- )" );
467+ )" , py::arg ( " files " ), py::arg ( " verbose " )= false );
435468
436469 py::class_<GadgetNative, std::shared_ptr<GadgetNative>, PyGadgetNative, ParticleReader>(m, " GadgetNative" )
437470 .def (py::init<const std::vector<std::string>&, bool >(),
@@ -448,7 +481,7 @@ void ParticleReaderClasses(py::module &m) {
448481 Returns
449482 -------
450483 ParticleReader
451- )" );
484+ )" , py::arg ( " files " ), py::arg ( " verbose " )= false );
452485
453486 py::class_<PSP , std::shared_ptr<PSP >, PyPSP, ParticleReader>(m, " PSP" )
454487 .def (py::init<bool >(), " Base class for PSP reader" )
@@ -464,19 +497,67 @@ void ParticleReaderClasses(py::module &m) {
464497
465498 py::class_<PSPout, std::shared_ptr<PSPout>, PyPSPout, PSP >(m, " PSPout" )
466499 .def (py::init<const std::vector<std::string>&, bool >(),
467- " Reader for monolitic PSP format (single file written by root process)" )
500+ R"(
501+ Read PSP ascii monolithic format snapshot files
502+
503+ Parameters
504+ ----------
505+ files : list(str)
506+ List of files with phase-space segments comprising a single snapshot
507+ verbose : bool, default=False
508+ Verbose, diagnostic output
509+
510+ Returns
511+ -------
512+ ParticleReader
513+ )" , py::arg (" files" ), py::arg (" verbose" )=false )
468514 .def (" CurrentNumber" , &PSPout::CurrentNumber)
469515 .def (" GetTypes" , &PSPout::GetTypes)
470516 .def (" CurrentTime" , &PSPout::CurrentTime);
471517
472518
473519 py::class_<PSPspl, std::shared_ptr<PSPspl>, PyPSPspl, PSP >(m, " PSPspl" )
474520 .def (py::init<const std::vector<std::string>&, bool >(),
475- " Reader for split PSP files (multiple files written by each process)" )
521+ R"(
522+ Reader for split PSP files (multiple files written by each process)
523+
524+ Parameters
525+ ----------
526+ files : list(str)
527+ List of files with phase-space segments comprising a single snapshot
528+ verbose : bool, default=False
529+ Verbose, diagnostic output
530+
531+ Returns
532+ -------
533+ ParticleReader
534+ )" , py::arg (" files" ), py::arg (" verbose" )=false )
476535 .def (" CurrentNumber" , &PSPspl::CurrentNumber)
477536 .def (" GetTypes" , &PSPspl::GetTypes)
478537 .def (" CurrentTime" , &PSPspl::CurrentTime);
479538
539+ py::class_<PSPhdf5, std::shared_ptr<PSPhdf5>, PyPSPhdf5, PSP >(m, " PSPhdf5" )
540+ .def (py::init<const std::vector<std::string>&, bool >(),
541+ R"(
542+ Reader for HDF5 PSP files (both single and multiple files)
543+
544+ Parameters
545+ ----------
546+ files : list(str)
547+ List of files with phase-space segments comprising a single snapshot
548+ verbose : bool, default=False
549+ Verbose, diagnostic output
550+
551+ Returns
552+ -------
553+ ParticleReader
554+ )" , py::arg (" files" ), py::arg (" verbose" )=false )
555+ .def (" SelectType" , &PSPhdf5::SelectType)
556+ .def (" NumFiles" , &PSPhdf5::NumFiles)
557+ .def (" CurrentNumber" , &PSPhdf5::CurrentNumber)
558+ .def (" GetTypes" , &PSPhdf5::GetTypes)
559+ .def (" CurrentTime" , &PSPhdf5::CurrentTime);
560+
480561 py::class_<Tipsy, std::shared_ptr<Tipsy>, PyTipsy, ParticleReader> tipsy (m, " Tipsy" );
481562
482563 py::enum_<Tipsy::TipsyType>(tipsy, " TipsyType" )
@@ -485,12 +566,28 @@ void ParticleReaderClasses(py::module &m) {
485566 .value (" bonsai" , Tipsy::TipsyType::bonsai)
486567 .export_values ();
487568
488- tipsy.def (py::init<const std::string&, Tipsy::TipsyType, bool >())
569+ tipsy.def (py::init<const std::string&, Tipsy::TipsyType, bool >(),
570+ R"(
571+ Read Tipsy format snapshots
572+
573+ Parameters
574+ ----------
575+ file : str
576+ The Tipsy snapshot file
577+ type : TipsyType
578+ The Tipsy file type (native, xdr, bonsai)
579+ verbose : bool, default=False
580+ Verbose, diagnostic output
581+
582+ Returns
583+ -------
584+ ParticleReader
585+
586+ )" , py::arg (" file" ), py::arg (" type" ), py::arg (" verbose" )=false )
489587 .def (py::init<const std::vector<std::string>&, Tipsy::TipsyType, bool >())
490588 .def (" SelectType" , &Tipsy::SelectType)
491589 .def (" CurrentNumber" , &Tipsy::CurrentNumber)
492590 .def (" GetTypes" , &Tipsy::GetTypes)
493591 .def (" CurrentTime" , &Tipsy::CurrentTime);
494592
495593}
496-
0 commit comments