netcdf.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:sympl 作者: mcgibbon 项目源码 文件源码
def write(self):
            """
            Write all cached states to the NetCDF file, and clear the cache.
            This will append to any existing NetCDF file.

            Raises
            ------
            InvalidStateError
                If cached states do not all have the same quantities
                as every other cached and written state.
            """
            with nc4.Dataset(self._filename, self._write_mode) as dataset:
                self._ensure_cached_state_keys_compatible_with_dataset(dataset)
                time_list, state_list = self._get_ordered_times_and_states()
                self._ensure_time_exists(dataset, time_list[0])
                it_start = dataset.dimensions['time'].size
                it_end = it_start + len(time_list)
                append_times_to_dataset(time_list, dataset, self._time_units)
                all_states = combine_states(state_list)
                for name, value in all_states.items():
                    ensure_variable_exists(dataset, name, value)
                    dataset.variables[name][
                        it_start:it_end, :] = value.values[:, :]
            self._cached_state_dict = {}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号