def _generate_json(self, directory=None, prefix=None):

        if directory is None:
            directory = os.getcwd()

        if prefix is None:
            prefix = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')

        self._scene_json_file = prefix + "_scene_desc.json"
        self._simulation_json_file = prefix + "_simulation_data.json"

        if self.system is None:
            constants = self.constants
            num_time_steps = self.states_trajectories.shape[0]
        else:
            constants = self.system.constants
            num_time_steps = len(self.system.times)
        # TODO : This assumes that all constants have unique strings and
        # that they are valid strings for the JSON file which can possibly
        # fail.
        constant_map_for_json = {str(k): v for k, v in constants.items()}

        self._generate_simulation_dict()
        self._generate_scene_dict()

        self._scene_info["simulationData"] = self._simulation_json_file

        times = None
        if self.times is not None:
            times = self.times
        elif self.system and self.system.times is not None:
            times = self.system.times

        if times is None:
            self._scene_info["timeDelta"] = 1.0 / self.frames_per_second
            self._scene_info["startTime"] = 0.0
        else:
            # Assume that times is evenly spaced and monotonic.
            # TODO: Interpolate if times are not evenly spaced.
            total_time = times[-1] - times[0]
            self._scene_info["timeDelta"] = total_time / (num_time_steps - 1)
            self._scene_info["startTime"] = times[0]

        self._scene_info["fps"] = self.frames_per_second
        self._scene_info["speedup"] = (self.frames_per_second *
                                       self._scene_info["timeDelta"])
        self._scene_info["timeSteps"] = num_time_steps
        self._scene_info["constant_map"] = constant_map_for_json

        scene_file_path = os.path.join(directory, self._scene_json_file)
        with open(scene_file_path, 'w') as scene_data_outfile:
            scene_data_outfile.write(json.dumps(self._scene_info,
                                                indent=4,
                                                separators=(',', ': ')))

        sim_file_path = os.path.join(directory, self._simulation_json_file)
        with open(sim_file_path, 'w') as simulation_data_outfile:
            simulation_data_outfile.write(json.dumps(
                self._simulation_info, indent=4,
                separators=(',', ': ')))
Creates two JSON files and copies all the necessary static files
dataset/ETHPy150Open pydy/pydy/pydy/viz/scene.py/Scene._generate_json