axis

In Python NumPy what is a dimension and axis?

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am coding with Pythons NumPy module. If coordinates of a point in 3D space are described as [1, 2, 1] , wouldn't that be three dimensions, three axis, a rank of three? Or if that is one dimension then shouldn't it be points (plural), not point? Here is the documentation: In Numpy dimensions are called axes. The number of axes is rank. For example, the coordinates of a point in 3D space [1, 2, 1] is an array of rank 1, because it has one axis. That axis has a length of 3. Source: http://wiki.scipy.org/Tentative_NumPy_Tutorial 回答1: In numpy

Get mean of 2D slice of a 3D array in numpy

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a numpy array with a shape of: ( 11L , 5L , 5L ) I want to calculate the mean over the 25 elements of each 'slice' of the array [0, :, :], [1, :, :] etc, returning 11 values. It seems silly, but I can't work out how to do this. I've thought the mean(axis=x) function would do this, but I've tried all possible combinations of axis and none of them give me the result I want. I can obviously do this using a for loop and slicing, but surely there is a better way? 回答1: Use a tuple for axis : >>> a = np . arange ( 11 * 5 * 5 ).

Matplotlib: coloring axis/tick labels

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How would one color y-axis label and tick labels in red? So for example the "y-label" and values 0 through 40, to be colored in red. import matplotlib.pyplot as plt import numpy as np x = np.arange(10) fig = plt.figure() ax = plt.subplot(111) ax.set_ylabel("y-label") for i in xrange(5): ax.plot(x, i * x, label='$y = %ix$' % i) ax.legend() plt.show() 回答1: label = plt.ylabel("y-label") label.set_color("red") similarly, you can obtain and modify the tick labels: [i.set_color("red") for i in plt.gca().get_xticklabels()] 回答2: The xlabel can be

axis2 Log Response with Request

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am very new to Web Service. I have one web service exposed, So client is consuming it but due to importance of service we want to Log SOAP Request and SOAP Response flowing IN and OUT. I am using Axis2-1.6.2 This is what I tried so far, I wrote one custom Handler and Module class import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.axis2.engine.Handler; import org.apache.axis2.handlers.AbstractHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public

How can I make my 2D Gaussian fit to my image

匿名 (未验证) 提交于 2019-12-03 01:09:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to fit a 2D Gaussian to an image to find the location of the brightest point in it. My code looks like this: import numpy as np import astropy.io.fits as fits import os from astropy.stats import mad_std from scipy.optimize import curve_fit import matplotlib.pyplot as plt from matplotlib.patches import Circle from lmfit.models import GaussianModel from astropy.modeling import models, fitting def gaussian(xycoor,x0, y0, sigma, amp): '''This Function is the Gaussian Function''' x, y = xycoor # x and y taken from fit function. Stars

How to catch a MessagingException on Apache Axis

匿名 (未验证) 提交于 2019-12-03 01:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: On my Axis 1.4 webservice this exception is thrown when an incoming message is corrupted. WARN ;2010-07-15 14:45:38,232;org.apache.axis.attachments.AttachmentsImpl;;Exception: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: javax.mail.MessagingException: Error in input stream; nested exception is: java.io.IOException: End of stream encountered before final boundary marker. faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:javax.mail.MessagingException:

Getting vertical gridlines to appear in line plot in matplotlib

匿名 (未验证) 提交于 2019-12-03 01:07:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to get both horizontal and vertical grid lines on my plot but only the horizontal grid lines are appearing by default. I am using a pandas.DataFrame from an sql query in python to generate a line plot with dates on the x-axis. I'm not sure why they do not appear on the dates and I have tried to search for an answer to this but couldn't find one. All I have used to plot the graph is the simple code below. data . plot () grid ( 'on' ) data is the DataFrame which contains the dates and the data from the sql query. I have also

Select a multiple-key cross section from a DataFrame

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a DataFrame "df" with (time,ticker) Multiindex and bid/ask/etc data columns: tod last bid ask volume time ticker 2013-02-01 SPY 1600 149.70 150.14 150.17 1300 SLV 1600 30.44 30.38 30.43 3892 GLD 1600 161.20 161.19 161.21 3860 I would like to select a second-level (level=1) cross section using multiple keys. Right now, I can do it using one key, i.e. df.xs('SPY', level=1) which gives me a timeseries of SPY. What is the best way to select a multi-key cross section, i.e. a combined cross-section of both SPY and GLD, something like: df.xs

Concatenate input with constant vector in keras

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to concatenate my input with a constant tensor in the keras-2 function API. In my real problem, the constants depend on some parameters in setup, but I think the example below shows the error I get. from keras.layers import* from keras.models import * from keras import backend as K import numpy as np a = Input(shape=(10, 5)) a1 = Input(tensor=K.variable(np.ones((10, 5)))) x = [a, a1] # x = [a, a] works fine b = concatenate(x, 1) x += [b] # This changes b._keras_history[0].input b = concatenate(x, 1) model = Model(a, b) The error

Numpy/Python: Array iteration without for-loop

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So it's another n-dimensional array question: I want to be able to compare each value in an n-dimensional arrays with its neighbours. For example if a is the array which is 2-dimensional i want to be able to check: a[y][x]==a[y+1][x] for all elements. So basically check all neighbours in all dimensions. Right now I'm doing it via: for x in range(1,a.shape[0]-1): do.something(a[x]) The shape of the array is used, so that I don't run into an index out of range at the edges. So if I want to do something like this in n-D for all elements in the