慕田峪7331174
2022-08-16 18:42:21
我正在研究有關地球磁場的地面觀測數據。我在Jupyter Notebook的Python中工作。每個天文臺都有一個數據系列,繪制如下圖:plt.scatter法典:# Function that plots the time series and the data series from a .mat data file # (in the dB-direction based on the out-variable), that is associated with the observatory code (based on the sta-variable)# It also takes an optional argument 'showdatapoints' so its possible to show data points mainly for debuggingdef plotdata_stations(filename, sta, out, start, stop, *args):# Makes the function use one of the three columns (and thus directions of field) in the data series based on inputif out == 'radial': dat = 0elif out == 'theta': dat = 1elif out == 'phi': dat = 2# If the user inputs something else than one of these three, it returns an error and a hint to resolve the errorelse: print('\nError: Component ' + "'" + out + "'" + ' not recognized...') print('\nHint: Try using ' + "'" + 'radial' + "', " + "'" + 'theta' + "' or " + "'" + 'phi' + "'.")# Try to load file in case the file does not existtry: nam = DataLoad(filename, 'obs_all')# If the file does not exist, it returns an error and a hint to resolve the errorexcept: print('\nError: File ' + "'" + filename + "'" + ' not recognized...') print('\nHint: Try putting your file in the same folder as this script.')# If the observatory code is not in the data file, it returns an error and a hint to resolve the errorif sta not in nam and sta != 'all': print('\nError: Observatory Code ' + "'" + sta + "'" + ' not recognized...') print('\nHint: Try using an Observatory Code from the Observatory Locations map.')
1 回答

瀟湘沐
TA貢獻1816條經驗 獲得超6個贊
我用數學的方式做了,就像這樣:
# Scaling data down to point of obs
###########################################
scax = 3
scay = 4
ntim=np.subtract(ntim,2000)
ntim=np.multiply(ntim,scax)
ndat=np.divide(ndat,scay)
###########################################
# Plots data from obs at the location of obs
# Plot at locations by adding coordinates of obs and subtracting the mean of each axis of data set
plt.scatter(ntim-np.mean(ntim)+phi, ndat-np.mean(ndat)+the, color='blue', marker='.')
plt.scatter(phi, the, color='red', marker='.')
但是,如果有人知道一種更“科學”的方法,我會歡迎您的回復。
添加回答
舉報
0/150
提交
取消