我需要将每个月的数据乘以相应月份的天数。数据是月平均降水量乘以累积降水量的天数。我想要一种pythonic方式(也许是xarray或pandas)。我的代码如下:
#!/usr/bin/env python3.6
import xarray as xr
ncfile = 'https://www.esrl.noaa.gov/psd/thredds/dodsC/' \
'Datasets/cmap/std/precip.mon.mean.nc'
with xr.open_dataset(ncfile, autoclose=True) as dset:
lat = dset['lat']
lon = dset['lon']
precip = dset['precip']
print(precip)
例如:
数据的前三个月是:1979-01-01,1979-02-01,1979-03-01,所以:
print(precip[0:3, 10, 10].values)
[ 0.81 0.76999998 0.70999998]
0.81 * 31
0.76999998 * 28
0.70999998 * 31
答案 0 :(得分:1)
您可以使用days_in_month
(或别名precip_month = precip * precip.time.dt.daysinmonth
)属性:
$this->client = new SoapClient($this->wsdl, array(
'trace' => true,
'exceptions' => true,
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true
),
'soap_version' => SOAP_1_2,
));
$this->client->__setLocation($service);
$params = array(
'Scope' => array(
'IncludedSources' => array('Token' => ''),
'Extension' => array(
'CameraUuid' => $CameraUuid,
'StartTime' => $StartTime,
'StopTime' => $StopTime,
),
),
'KeepAliveTime' => $KeepAlive
);
return $this->client->FindRecordings($params);