# Path: frbpoppy/misc.py
# def pprint(*s, output=True):
#     """Hack to make for more informative print statements."""
#     f = inspect.stack()[1][1].split('/')[-1]
#     m = '{:13.13} |'.format(f)
# 
#     if output:
#         print(m, *s)
#     else:
#         lines = []
#         for e in s:
#             lines.append('\n'.join([f'{m} {f}' for f in e.split('\n')]))
#         return '\n'.join(lines)
# 
# Path: frbpoppy/paths.py
# class Paths():
#     def __init__(self):
#     def __str__(self):
#     def check(self, path):
#     def store(self, name, default, *args):
#     def data(self, *args):
#     def populations(self, *args):
#     def surveys(self, *args):
#     def models(self, *args):
#     def frbcat(self, *args):


import os
import numpy as np
import sqlite3
import sys
import frbpoppy.galacticops as go
from scipy.integrate import quad
from tqdm import tqdm
from joblib import Parallel, delayed
from frbpoppy.misc import pprint
from frbpoppy.paths import paths

class NE2001Table:
    """Create/use a NE2001 lookup table for dispersion measure."""

    def __init__(self, test=False):
        """Initializing."""
        self.test = test
        self.set_file_name()

        # Setup database
        self.db = False
        self.step = 0.1
        self.rounding = 2

        # For parallel processes
        self.temp_path = None

        if self.test:
            self.step = 0.1
            if os.path.exists(self.file_name):
                os.remove(self.file_name)

        if os.path.exists(self.file_name) and self.test is False:
            self.db = True
        else:
            # Calculations take quite some time
            # Provide a way for people to quit
            try:
                self.create_table()
            except KeyboardInterrupt:

# Path: frbpoppy/misc.py
# def pprint(*s, output=True):
#     """Hack to make for more informative print statements."""
#     f = inspect.stack()[1][1].split('/')[-1]
#     m = '{:13.13} |'.format(f)
# 
#     if output:
#         print(m, *s)
#     else:
#         lines = []
#         for e in s:
#             lines.append('\n'.join([f'{m} {f}' for f in e.split('\n')]))
#         return '\n'.join(lines)
# 
# Path: frbpoppy/paths.py
# class Paths():
#     def __init__(self):
#     def __str__(self):
#     def check(self, path):
#     def store(self, name, default, *args):
#     def data(self, *args):
#     def populations(self, *args):
#     def surveys(self, *args):
#     def models(self, *args):
#     def frbcat(self, *args):


# Path: frbpoppy/precalc.py
import os
import numpy as np
import sqlite3
import sys
import frbpoppy.galacticops as go
from scipy.integrate import quad
from tqdm import tqdm
from joblib import Parallel, delayed
from frbpoppy.misc import pprint
from frbpoppy.paths import paths


class NE2001Table:
    """Create/use a NE2001 lookup table for dispersion measure."""

    def __init__(self, test=False):
        """Initializing."""
        self.test = test
        self.set_file_name()

        # Setup database
        self.db = False
        self.step = 0.1
        self.rounding = 2

        # For parallel processes
        self.temp_path = None

        if self.test:
            self.step = 0.1
            if os.path.exists(self.file_name):
                os.remove(self.file_name)

        if os.path.exists(self.file_name) and self.test is False:
            self.db = True
        else:
            # Calculations take quite some time
            # Provide a way for people to quit
            try:
                self.create_table()
            except KeyboardInterrupt:

                pprint('Losing all progress in calculations')