calculating galactic space velocities gal_uvw in - coordinates

Where to find a clear explanation of gal_uvw transformation? I am searching for some figures to derive the matrix of transformation.
https://github.com/segasai/astrolibpy/blob/master/astrolib/gal_uvw.py
I looked at
https://articles.adsabs.harvard.edu/pdf/1987AJ.....93..864J
but the matrix is a inverse and reverse.

Related

Doing PCA and Whitening with matlab

My task is to do PCA and whitening transform with given 2dimentional 5000data.
What I understand with PCA is analyzing the main axis of the data with covariance Matrix's Eigen Vector and rotate the main axis to the x axis!
So here's what I did.
[BtEvector,BtEvalue]=eig(MYCov);% Eigen value and vector using built-in function
I first calculated eigen values and vectors. The result was
BtEvalue=[4.027487815706757,0;0,8.903923357227459]
and
BtEvector=[0.033937679569230,-0.999423951036524;-0.999423951036524,-0.033937679569230]
So I figured out that the main axis will have eigen value of 8.903923357227459 and eigen vector of [-0.999423951036524,-0.033937679569230] which is the second corresponding term.
After then, because it's two dimentional data, I let cos(theta) as -0.9994.. and sin(theta)=-0.033937. Because I thought the main axis of the data(eigen vector [-0.999423951036524,-0.033937679569230]) has to be x axis I made rotational axis R= [cos(-Theta)-sin(-theta);sin(-theta) cos(-theta)]. Let original data sets A=>2*5000, I did A*R to get rotated data.
Also, For whitening case, using Cholesky whitening, I made whitening transformation matrix as inv(Covariance Matrix).
Is there something wrong with my algorithm? Could someone testify if there's error or misunderstanding please? Thank you a lot in advance.
Since your data is two-dimensional, the covariance matrix that you calculated is not accurate. If you only calculate the covariance with respect to one axis (say x), you're assuming that the covariance along the y axis is identity. This is obviously not true. Although you've attempted to address this, there's a sound procedure that you can use (I've explained below).
Unfortunately, this is a common mistake. Have a look at this paper, where it is explained exactly how the covariance should be calculated.
In summary, you can calculate the covariance along each axis (Sx and Sy). Then approximate the 2D covariance of the vectorized matrix as kron(Sx,Sy). This will be a better approximation of the 2D covariance.

Utility of loglog plots in curve fitting inverse square relationship

I have a a bunch of data that I'd like to use to find an unknown parameter in a physical equation.
I'm trying to find a parameter k to characterise the output of a hall effect sensor as a function on input voltage and distance between the sensor and the magnet. However, I've found this function to be inversely proportional to the square of the distance.
I asked my professor about how to use MATLAB to find the unknown parameter, and he told me I could try to fit it by taking the logarithm of both sides of the equation and plotting that, seen as that would make the relationship linear and thus easier to plot.
I'd have to do this in MATLAB and I'm assuming the values I measured would have to be converted by hand before being able to perform any sort of curve fitting on them.
I was wondering if doing that was worth it, and if there is a faster way of doing this.
Thanks :)
In order to easily identify the relationship, for a set input voltage, I had to take the logarithm of the measured distance and the logarithm of the respective output voltages and plot those. Fitting a line through those points then enabled me to see that the coefficient was close enough to -2, confirming the inverse square relationship.
I then did the same for different input voltages and added everything together on the same plot.

Matlab multidimensional correlation with circular data

I am kind of new to analyzing circular data and I have a quite complex problem.
I'm trying to correlate 2 multidimensional vectors (N observations x 2 dimensions) where one dimension is circular (i.e. angles in radians).
I have found the corr2 function for 2D correlations which seems to work fine (http://www.mathworks.com/help/images/ref/corr2.html), I am however uncertain if I can use it on circular data (there isn't much information on it in the Matlab Documentation).
I found documentation on the Origin software which states that the correlations can be circular (http://www.originlab.com/doc/Origin-Help/2D-Correlation) but I have no idea if it this generalizes to Malab.
I tried two approaches:
1- I input the linear and circular data as is:
r = corr2([Theta_X Amplitude_X], [Theta_Y Amplitude_Y]);
which yields very good results but I am unsure if they are valid.
2- I "linearized" the data by converting the polar coordinates into Cartesian (pol2cart):
r = corr2([x_X y_X], [x_Y y_Y]);
which yields noisier results.
My question is thus: can I use the corr2 function on circular data? If not, can anyone point me in the right direction?

Matlab calculations of major/minor axis lengths (regiosprops)

I have been doing a fair bit of searching around for an answer to my issue here.. hopefully someone can tell me where im going wrong.
im trying to replicate matlabs regionprops function to calculate major/minor axis lengths, and think i understand most of what it's doing but im a little lost.
my understanding was that the axis lengths are equal to the eigenvalues of the covariance matrix (of the regions pixel coordinates) but the numbers i am getting are far from what matlab is returning.
so far i am:
1)extracting coordinates as an n-by-2 matrix.
2)subtracting the x/y means from the matrix.
3)calculating covariance matrix (matrix'.matrix)/num_pixels
4)calculating eigenvalues from the covariance matrix
but the values i get are way away from what matlab is returning. am i doing completely the wrong thing here or am i just making a mistake in the working?

Finding all complex eigenvalues near the unit circle of a large matrix (n around 10k-100k) with MATLAB

I am studying wave propagation in periodic material and need to computes slowness surfaces which are obtained by computing polynomial eigenvalues of some matrix.
Given that I am only interested in propagative waves, only eigenvalues near the unit circle should be researched.
Is there an efficient way to computes those given we do not know the number of values we are searching ?
Thanks for the help !