我正在用python编写一个脚本,在这个脚本中,我可以将ls输出传递到脚本中,并使用scipy.io打开python中我想使用的所有文件,然后将它们分配到一个.mat文件中(同样使用scipy.io)。我已经成功地导入了数据并将其分配到一个字典中导出,但是当我在MATLAB中加载我的输出文件时,所有的数据看起来都不一样。在
我要导入的数据都有一个纬度/经度坐标,因此我将以这些数据为例。数据来自netCDF(.nc)文件:#!/usr/bin/python
import sys
import scipy.io as sio
import numpy as np
# script take absolute path inputs (or absolute paths are desirable)
# to access an abolute path on a linux systen use the command:
# ls -d $PWD/* OR if files not in PWD then ls -d /absolute_file_path/*
# and then pipe the standard output of that to input of this script
# initialize dictionary (param) and cycle number (i.e. datafile number)
cycle = []
param = {}
# read each file from stdin
for filename in sys.stdin:
fh = sio.netcdf.netcdf_file(filename,'r')
# load in