# obspy.signal.spectral_estimation.PPSD.calculate_histogram

`PPSD.``calculate_histogram`(starttime=None, endtime=None, time_of_weekday=None, year=None, month=None, isoweek=None, callback=None)

  Calculate and set current 2D histogram stack, optionally with start- and endtime and time of day restrictions.

  Note

  All restrictions to the stack are evaluated as a logical AND, i.e. only individual psd pieces are included in the stack that match all of the specified restrictions (e.g. isoweek=40, month=2 can never match any data).

  Note

  All time restrictions are specified in UTC, so actual time in local time zone might not be the same across start/end date of daylight saving time periods.

  Note

  Time restrictions only check the starttime of the individual psd pieces.

  Parameters: | starttime (`UTCDateTime`) If set, data before the specified time is excluded from the returned stack. endtime (`UTCDateTime`) If set, data after the specified time is excluded from the returned stack. time_of_weekday (list of (int, float, float) 3-tuples) If set, restricts the data that is included in the stack by time of day and weekday. Monday is 1, Sunday is 7, -1 for any day of week. For example, using time_of_weekday=[(-1, 0, 2), (-1, 22, 24)] only individual spectra that have a starttime in between 10pm and 2am are used in the stack for all days of week, using time_of_weekday=[(5, 22, 24), (6, 0, 2), (6, 22, 24), (7, 0, 2)] only spectra with a starttime in between Friday 10pm to Saturdays 2am and Saturday 10pm to Sunday 2am are used. Note that time of day is specified in UTC (time of day might have to be adapted to daylight saving time). Also note that this setting filters only by starttime of the used psd time slice, so the length of individual slices (set at initialization: `PPSD(..., ppsd_length=XXX, ...)` in seconds) has to be taken into consideration (e.g. with a ppsd_length of one hour and a time_of_weekday restriction to 10pm-2am actually includes data from 10pm-3am). year (list of int) If set, restricts the data that is included in the stack by year. For example, using year=[2015] only individual spectra from year 2015 are used in the stack, using year=[2013, 2015] only spectra from exactly year 2013 or exactly year 2015 are used. month (list of int) If set, restricts the data that is included in the stack by month of year. For example, using month=[2] only individual spectra from February are used in the stack, using month=[4, 7] only spectra from exactly April or exactly July are used. isoweek (list of int) If set, restricts the data that is included in the stack by ISO week number of year. For example, using isoweek=[2] only individual spectra from 2nd ISO week of any year are used in the stack, using isoweek=[4, 7] only spectra from exactly 4th ISO week or exactly 7th ISO week are used. callback (func) Custom user defined callback function that can be used for more complex scenarios to specify whether an individual psd piece should be included in the stack or not. The function will be passed an array with the starttimes of all psd pieces (as a POSIX timestamp that can be used as a single argument to initialize a `UTCDateTime` object) and should return a boolean array specifying which psd pieces should be included in the stack (True) and which should be excluded (False). Note that even when callback returns True the psd piece will be excluded if it does not match all other criteria (e.g. starttime).
  Return type: | None

### Thank you!

We would like to thank our contributors, whose efforts make this software what it is. These people have helped by writing code and documentation, and by testing. They have created and maintained this product, its associated libraries and applications, our build tools and our web sites.

#### Contributors

- Ackerley, Nick
- Allgeyer, Sebastien
- Ammon, Charles J.
- Antunes, Emanuel
- Arnarsson, Ólafur St.
- Bank, Markus
- Barsch, Robert
- Behr, Yannik
- Bernardi, Fabrizio
- Bernauer, Felix
- Bes de Berc, Maxime
- Beyreuther, Moritz
- Boltz, Shawn
- Bonaimé, Sébastien
- Carothers, Lloyd
- Chamberlain, Calum
- Chambers, Derrick
- Chen, Zhao
- Clark, Adam
- Danecek, Peter
- Egdorf, Sven
- Engels, Fabian
- Ermert, Laura
- Eulenfeld, Tom

- Fabbri, Tommaso
- Falco, Nicholas
- Fee, Jeremy
- Grellier, Clément
- Grunberg, Marc
- Hammer, Conny
- Heimann, Sebastian
- Heiniger, Lukas
- Hope, Gaute
- Igel, Heiner
- Inza, Adolfo
- Isken, Marius
- Ketchum, David
- Koymans, Mathijs
- Kremers, Simon
- Kress, Victor
- Krieger, Lars
- Krischer, Lion
- Kula, Damian
- Käufl, Paul
- Köhler, Andreas
- Lecocq, Thomas
- Leeman, John
- Legovini, Paride

- Lesage, Philippe
- Li, Yulin
- Lomax, Anthony
- Lopes, Rui L.
- MacCarthy, Jonathan
- Maggi, Alessia
- Martin, Henri
- Medlin, Andrew
- Megies, Tobias
- Meschede, Matthias
- Michelini, Alberto
- Miller, Nathaniel C.
- Morgenstern, Bernhard
- Nof, Ran Novitsky
- Panning, Mark P.
- Parker, Tom
- Pestourie, Romain
- Rapagnani, Giovanni
- Reyes, Celso
- Ringler, Adam
- Rothenhäusler, Nicolas
- Russo, Emiliano
- Sales de Andrade, Elliott

- Satriano, Claudio
- Saul, Joachim
- Scheingraber, Chris
- Schneider, Simon
- Sippl, Christian
- Snoke, Arthur
- Stange, Stefan
- Stähler, Simon C.
- Sullivan, Benjamin
- Tian, Dongdong
- Trabant, Chad
- Trani, Luca
- Uieda, Leonardo
- Walker, Andrew
- Walther, Marcus
- Wassermann, Joachim
- Williams, Mark C.
- Winkelman, Andrew
- Zaccarelli, Riccardo
- Zad, Seyed Kasra Hosseini
- Zhu, Lijun
- van Driel, Martin
- van Wijk, Kasper

#### Funds

ObsPy was partially funded by the

- German Science Foundation (DFG) via grant DFG IG 16/9-1
- German Ministry for Education and Research (BMBF), GEOTECHNOLOGIEN grant 03G0646H.
- NERA project (Network of European Research Infrastructures for Earthquake Risk Assessment and Mitigation) under the European Community's Seventh Framework Programme (FP7/2007-2013) grant agreement n° 262330
- Leibniz Institute for Applied Geophysics (LIAG)
- VERCE EU-FP7 project (no. 283543)