Exemple #1
0
 def table_div(self):
     """Returns the html div for a table, or an empty string if no table is to be produced"""
     if self.missing_input_files():
         raise MissingInputDataException(
             "Dear developer: Run check_input_files() first, before plotting!"
         )
     return self.cache.lookup_table_div(self, self._table_div_producer)
Exemple #2
0
 def plot_div(self):
     """Return the plot as an html <div/> for use in the dashboard. Override this method in subclasses"""
     if self.missing_input_files():
         raise MissingInputDataException(
             "Dear developer: Run check_input_files() first, before plotting!"
         )
     return self.cache.lookup_plot_div(self, self._plot_div_producer)
Exemple #3
0
 def table_div(self):
     """Returns the html div for a table, or an empty string if no table is to be produced"""
     if self.missing_input_files():
         raise MissingInputDataException(
             "Following input files are missing: {input_files}".format(
                 input_files=self.missing_input_files()))
     return self.cache.lookup_table_div(self, self._table_div_producer)
Exemple #4
0
 def plot_div(self):
     """Return the plot as an html <div/> for use in the dashboard. Override this method in subclasses"""
     if self.missing_input_files():
         raise MissingInputDataException(
             "Following input files are missing: {input_files}".format(
                 input_files=self.missing_input_files()))
     return self.cache.lookup_plot_div(self, self._plot_div_producer)
Exemple #5
0
def main(config):
    assert os.path.exists(config.scenario), 'Scenario not found: %s' % config.scenario
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    print('Running demand calculation for scenario %s' % config.scenario)
    print('Running demand calculation with dynamic infiltration=%s' %
          config.demand.use_dynamic_infiltration_calculation)
    print('Running demand calculation with multiprocessing=%s' % config.multiprocessing)
    if config.debug:
        print('Running demand in debug mode: Instant visualization of tsd activated.')
        print('Running demand calculation with write detailed output')

    if not radiation_files_exist(locator, config):
        raise MissingInputDataException("Missing radiation data in scenario. Consider running radiation script first.")

    demand_calculation(locator=locator, config=config)
Exemple #6
0
    def plot(self, auto_open=False):
        """Plots the graphs to the filename (see output_path)"""
        if self.missing_input_files():
            raise MissingInputDataException("Dear developer: Run check_input_files() first, before plotting!")
        # PLOT
        template_path = os.path.join(os.path.dirname(__file__), 'plot.html')
        template = jinja2.Template(open(template_path, 'r').read())
        plot_html = template.render(plot_div=self.plot_div(), table_div=self.table_div(), title=self.title)
        with open(self.output_path, 'w') as f:
            f.write(plot_html)

        print("Plotted '%s' to %s" % (self.name, self.output_path))
        if auto_open:
            import webbrowser
            webbrowser.open(self.output_path)
    def plot(self, auto_open=False):
        """Plots the graphs to the filename (see output_path)"""
        if self.missing_input_files():
            raise MissingInputDataException(
                "Following input files are missing: {input_files}".format(
                    input_files=self.missing_input_files()))
        # PLOT
        template_path = os.path.join(os.path.dirname(__file__), 'plot.html')
        with open(template_path, "r") as fp:
            template = jinja2.Template(fp.read())
        plot_html = template.render(plot_div=self.plot_div(),
                                    table_div=self.table_div(),
                                    title=self.title)
        with open(self.output_path, 'w') as f:
            f.write(plot_html)

        print("Plotted '%s' to %s" % (self.name, self.output_path))
        if auto_open:
            import webbrowser
            webbrowser.open(self.output_path)