This document is a Master's thesis that applies the technique of differential reduction to the pole (DRTP) to aeromagnetic anomaly data from Iran. DRTP transforms magnetic anomalies measured at various latitudes and orientations to how they would appear if measured at the magnetic pole. The thesis applies this technique using MATLAB programs to iteratively calculate the DRTP correction. It then uses the corrected DRTP map of Iran's magnetic anomalies to better delineate geological structures like fold belts and delineate boundaries between volcanic and metamorphic zones.
ENHANCED DATA DRIVEN MODE-FREE ADAPTIVE YAW CONTROL OF UAV HELICOPTERijics
An enhanced data driven model-free adaptive yaw control tracking control scheme is proposed for the yaw
channel of an unmanned-aerial-vehicle (UAV) helicopter which is non-affine in the control input in this paper. Through dynamic linearization and observer techniques, the proposed control algorithm is only based on the pseudo-partial derivative (PPD) parameter estimation derived online from the I/O data of the yaw channel of an UAV helicopter, and Lyapunov-based stability analysis is utilized to prove all signals of
close-loop control system are bounded. Compared with the traditional model free adaptive control
(MFAC), the proposed enhanced MFAC algorithm can make the close-loop control system with stronger robustness and better anti-jamming ability. Finally, simulation results of the UAV yaw channel are offered to demonstrate the effectiveness of the proposed novel control technique.
Backstepping linearization controller of the Delta Wing Rock PhenomenaIJERA Editor
This paper deals with the control of the wing rock phenomena of a delta wing aircraft. A control technique is
proposed to stabilize the system. The controller is a BACKSTEPPING controller. It is appeared that the
proposed solution of control guarantee the asymptotic convergence to zero of all the states of the system. To
show the performance of the proposed controller, simulation results are presented and discussed. It is found that
the control scheme work well for the wing rock phenomena of a delta wing aircraft.
Comparison of time domain techniques for the evaluation of the response and t...Franco Bontempi
Plenary Lecture at Fourth M.I.T. Conference on Computational Fluid and Solid Mechanics – Focus: Fluid-Structure Interactions, Boston, June 13-15, 2007.
During the last decades, several studies on suspension bridges under wind actions have been developed in civil engineering and many techniques have been used to approach this structural problem both in time and frequency domain. In this paper, four types of time domain techniques to evaluate the response and the stability of a long span suspension bridge are implemented: nonaeroelastic, steady, quasi steady, modified quasi steady. These techniques are compared considering both nonturbulent and turbulent flow wind modelling. The results show consistent differences both in the amplitude of the response and in the value of critical wind velocity.
ENHANCED DATA DRIVEN MODE-FREE ADAPTIVE YAW CONTROL OF UAV HELICOPTERijics
An enhanced data driven model-free adaptive yaw control tracking control scheme is proposed for the yaw
channel of an unmanned-aerial-vehicle (UAV) helicopter which is non-affine in the control input in this paper. Through dynamic linearization and observer techniques, the proposed control algorithm is only based on the pseudo-partial derivative (PPD) parameter estimation derived online from the I/O data of the yaw channel of an UAV helicopter, and Lyapunov-based stability analysis is utilized to prove all signals of
close-loop control system are bounded. Compared with the traditional model free adaptive control
(MFAC), the proposed enhanced MFAC algorithm can make the close-loop control system with stronger robustness and better anti-jamming ability. Finally, simulation results of the UAV yaw channel are offered to demonstrate the effectiveness of the proposed novel control technique.
Backstepping linearization controller of the Delta Wing Rock PhenomenaIJERA Editor
This paper deals with the control of the wing rock phenomena of a delta wing aircraft. A control technique is
proposed to stabilize the system. The controller is a BACKSTEPPING controller. It is appeared that the
proposed solution of control guarantee the asymptotic convergence to zero of all the states of the system. To
show the performance of the proposed controller, simulation results are presented and discussed. It is found that
the control scheme work well for the wing rock phenomena of a delta wing aircraft.
Comparison of time domain techniques for the evaluation of the response and t...Franco Bontempi
Plenary Lecture at Fourth M.I.T. Conference on Computational Fluid and Solid Mechanics – Focus: Fluid-Structure Interactions, Boston, June 13-15, 2007.
During the last decades, several studies on suspension bridges under wind actions have been developed in civil engineering and many techniques have been used to approach this structural problem both in time and frequency domain. In this paper, four types of time domain techniques to evaluate the response and the stability of a long span suspension bridge are implemented: nonaeroelastic, steady, quasi steady, modified quasi steady. These techniques are compared considering both nonturbulent and turbulent flow wind modelling. The results show consistent differences both in the amplitude of the response and in the value of critical wind velocity.
This paper is my work on Einstein's Relativity theory for speed greater than light.The paper mainly focus on to generalize the Lorentz factor , equation of negative energy and negative mass thus proving the existence of wormholes and the derivation of new space metric.
It was presented at the Dept. Of Atmospheric Sciences for the award of M.Tech degree. It is all about the research in high resolution ARW model for tropical cyclones simulations.
Feedback Linearization Controller Of The Delta WingRock PhenomenaIJERA Editor
This project deals with the control of the wing rock phenomena of a delta wing aircraft. a control schemeis
proposed to stabilize the system. The controlleris a feedback linearization controller. It is shown that the
proposed control scheme guarantee the asymptotic convergence to zero of all the states of the system. To
illustrate the performance of the proposed controller, simulation results are presented and discussed. It is found
that the proposed control scheme work well for the wing rock phenomena of a delta wing aircraft.
The project involves complex development of the territory with total area of 316.1 hectares and includes the construction of multi-apartment residential blocks as well as shopping, leisure and other commercial objects with public infrastructures.
From 0 to 90 in 18 minutes: The First 90 Days - TEDx Sept 2015 - Reading ListArnon Kraft
Reading list for those interested that relates to what I talked about at the TEDx event yesterday: Reputation, Purpose & Commitments and Corporate (or team) Culture.
This paper is my work on Einstein's Relativity theory for speed greater than light.The paper mainly focus on to generalize the Lorentz factor , equation of negative energy and negative mass thus proving the existence of wormholes and the derivation of new space metric.
It was presented at the Dept. Of Atmospheric Sciences for the award of M.Tech degree. It is all about the research in high resolution ARW model for tropical cyclones simulations.
Feedback Linearization Controller Of The Delta WingRock PhenomenaIJERA Editor
This project deals with the control of the wing rock phenomena of a delta wing aircraft. a control schemeis
proposed to stabilize the system. The controlleris a feedback linearization controller. It is shown that the
proposed control scheme guarantee the asymptotic convergence to zero of all the states of the system. To
illustrate the performance of the proposed controller, simulation results are presented and discussed. It is found
that the proposed control scheme work well for the wing rock phenomena of a delta wing aircraft.
The project involves complex development of the territory with total area of 316.1 hectares and includes the construction of multi-apartment residential blocks as well as shopping, leisure and other commercial objects with public infrastructures.
From 0 to 90 in 18 minutes: The First 90 Days - TEDx Sept 2015 - Reading ListArnon Kraft
Reading list for those interested that relates to what I talked about at the TEDx event yesterday: Reputation, Purpose & Commitments and Corporate (or team) Culture.
A catalogue of mosaic products , produced by Martin Brown Mosaics .
Ideal for both interior and exterior spaces .
Commercial and domestic environments .
Lacoste event of photography and fashion carried out in 2011, at the brazilian cities of São Paulo, Rio de Janeiro an Brasília.
Photos by Bob Wolfenson and Ludovic Careme, styling by Paulo Martinez and copy by Ignácio de Loyola Brandão and a cast of beatiful celebrities.
DISTANCE TWO LABELING FOR MULTI-STOREY GRAPHSgraphhoc
An L (2, 1)-labeling of a graph G (also called distance two labeling) is a function f from the vertex set V (G) to the non negative integers {0,1,…, k }such that |f(x)-f(y)| ≥2 if d(x, y) =1 and | f(x)- f(y)| ≥1 if d(x, y) =2. The L (2, 1)-labeling number λ (G) or span of G is the smallest k such that there is a f with
max {f (v) : vє V(G)}= k. In this paper we introduce a new type of graph called multi-storey graph. The distance two labeling of multi-storey of path, cycle, Star graph, Grid, Planar graph with maximal edges and its span value is determined. Further maximum upper bound span value for Multi-storey of simple
graph are discussed.
Development of Matlab Programme to study nonlinear vibration of a cantilever ...ijiert bestjournal
The finite element model for the nonlinear transverse vibration of t he beam was implemented in the program NLB This program was used to calculate the steady state response of the beam. The numerical results from the program were compared to the experimental res ults obtained by Malatkar (2003). The NLB program was also used to calculate the transient response of the be am,which was compared with the response obtained with ANSYS. The paper is a extension of the research papers which has been publishe d earlier in this issue of journal and December 2014 issue.
Please show the whole code... Im very confused. Matlab code for ea.pdfarshiartpalace
Please show the whole code... I\'m very confused. Matlab code for earth orbit Using a software
package such as MATLAB, create a plot of an Earth orbit with a = 31, 800 km and e = 0.6 for 0
lessthanorequalto theta lessthanorequalto 2 pi. The origin of the plot should be Earth. Perigee
should be in the direction of the positive x axis (therta = 0). On this plot, you should label (by
hand) the semimajor axis, semiminor axis, radius of perigee, radius of apogee, and the
semiparameter (semilatus rectum) of the ellipse.
Solution
---------------------------------------------------------------------------------------------------------------------
-------------------------------------------------
Elliptic orbit:
%periapsis
rp = 500e3 + getradius(\'earth\');
%eccentricity
ec = .7;
%semimajor axis
a = getsemimajoraxis(rp,ec);
%apoapsis
ra = 2*a-rp;
%true anomaly
theta = [0:.1:360];
orbit = ellipse(theta,a,ec,\'earth\');
figure(1), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
hold on
plot(x,y,\'color\',[0 1 1])
hold off
figure(2), plot(theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
%current time
c = clock;
%reset hour and second
c(4) = 12; %hour
c(5) = 0; %minute
c(6) = orbit.tau; %seconds
%ellapsed time
datetime(c)
%returns 14-Feb-2015 21:34:54, so it\'s about 9.5 hours later still on
%Monday
2
ans =
22-Feb-2015 21:34:54
-----------Elliptic orbit
%periapsis
rp = 500e3 + getradius(\'earth\');
%eccentricity
ec = .7;
%semimajor axis
a = getsemimajoraxis(rp,ec);
%apoapsis
ra = 2*a-rp;
%true anomaly
theta = [0:.1:360];
orbit = ellipse(theta,a,ec,\'earth\');
figure(1), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
hold on
plot(x,y,\'color\',[0 1 1])
hold off
figure(2), plot(theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
%current time
c = clock;
%reset hour and second
c(4) = 12; %hour
c(5) = 0; %minute
c(6) = orbit.tau; %seconds
%ellapsed time
datetime(c)
%returns 14-Feb-2015 21:34:54, so it\'s about 9.5 hours later still on
%Monday
2
ans =
22-Feb-2015 21:34:54
3
The circular orbits at perigee and apogee are
7.6167 and 3.1997 km/s, respectively.
-----Parabolic orbit:
Sphere of influence is actually a chapter 5 concept, but is the distance at which the gravitational
forces
between two objects is equal. Thus,
While an approximation, if we just estimate this as the point between the sun and the earth
where
these forces balance, then if the orbital radius of Earth is , then
, and thus solution for r_E in gives
r_soi = getsphereofinfluence(\'earth\',\'sun\');
display([\'Radius from center of earth to sphere of influence is approximately \' num2str(r_soi)]);
%perifocal distance
rp = 500e3 + getradius(\'earth\');
%eccentricty
ec = 1; %always so for a a parabola
theta = -180:1:180;
orbit = parabola(theta,rp,\'earth\');
figure(3), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
1. Differential Reduction to the Pole of Iran aeromagnetic anomalies
Master's Thesis
Vahid Ghobadian
Supervisors:
Dr.Abdoreza Ghods
Dr.Mahnaz Rezaeian
September 2012
1
2. Abstract
In this work, The aeromagnetic map of Iran wich reprocessed by Saleh (2008), performed by Arkani Hamed (1988)method called differential reduction to the pole(DRTP). The variations in direction are treated as perturbations about mean directions and the problem is solved iteratively.The DRTP operator used the Taylor series expansion approach in the frequency domain provided a uniformly leveled aeromagnetic map of Iran. DRTP reduces magnetic anomalies to the pole more effectively than the space-domain algorithm. It takes the anomaly, as measured at any latitude, and transforms it into which would have been measured if the body had been laid at the magnetic pole i.e. the area where the field inclination is vertical and the anomalies from symmetrical bodies are symmetrical. The technique is applied to the magnetic anomalies of three semiintinite dipoles, which arc inductively magnetized and locatcd at high, mid, and low latitudes in a region where the inclination of the ambient field changes from 25 to 42 degrees. We also apply the technique to the aeromagnetic anomalies of Iran. The revised DRTP map of Iran, where the inclination varies from 37° to 42°, is the most important output of this work. This aeromagnetic anomaly map of Iran clearly delineate distinctive anomaly pattern for Zagros and Alborz fold and thrust belts, Sanandaj-Sirjan metamorphic and Uromiyeh-Dokhtar volcanic zones, Lut block, Makran accretionary prism and Daruneh fault. Using the new DRTP map, a good correlation between geological structures and magnetic anomaly has been verified. For example after the algorithm reduced magnetic anomalies to the north, magnetic anomaly map boundaries delineate Sabalan and Damavand volcanic zones and Jazmurian district.
2
3. Appendix 1 - Matlab programs used for Standard RTP calculations
% ***********************************************************
% Tested using Matlab 7.6 Release 2008b under Windows XP
% ***********************************************************
% AUTHOR
% Vahid Ghobadian
%M.Sc. Student of Geophysics
%Earth Science Department
% Institute of Advanced Studies in Basic Sciences (IASBS)
% Zanjan, Iran
% vghobadian@iasbs.ac.ir
% ***********************************************************
% Function : RTP
% Calculates reduction to pole
% ***********************************************************
function out = RTP(TR,Inc,Dec,dx,dy)
I=Inc;
D=Dec;
TR = TR';
[nx,ny] = size(TR);
nmax=max([nx ny]); npts=2^nextpow2(nmax);
cdiff=floor((npts-ny)/2); rdiff=floor((npts-nx)/2);
data=taper2d(TR,npts,nx,ny,rdiff,cdiff);
TR1 = data;
nyqx=(1/(2*dx));
nyqy=(1/(2*dy));
kx=linspace(-nyqx,nyqx,npts);
ky=linspace(-nyqy,nyqy,npts);
L=cos(I)*cos(D);
l=cos(I)*cos(D);
R=cos(I)*sin(D);
r=cos(I)*sin(D);
Q=sin(I);
q=sin(I);
[KX KY]=meshgrid(kx,ky);
Kx=KX.*KX;
Ky=KY.*KY;
3
4. for m= 1:npts
for n= 1:npts
RTP(m,n) = (Kx(m,n)+Ky(m,n))/(((i*L*KX(m,n))+(i*R*KY(m,n))+(Q*((Kx(m,n)+Ky(m,n)). ^0.5))).*((i*l*KX(m,n))+(i*r*KY(m,n))+(q*((Kx(m,n)+Ky(m,n)).^0.5))));
end
end
RTP=fftshift(RTP);
filtR_dat1=(ifft2(fft2(TR1).*RTP));
out=real(filtR_dat1(1+rdiff:nx+rdiff,1+cdiff:ny+cdiff));
out = out';
function gt=taper2d(g,npts,nr,nc,rdiff,cdiff)
% Merge edges to the value opposite using a cubic spline
gt=zeros(npts); gt(rdiff+1:rdiff+nr,cdiff+1:cdiff+nc)=g;
gp=g(:,1:3); [gpx1,junk]=gradient(gp); % sides
gp=g(:,nc-2:nc); [gpx2,junk]=gradient(gp);
x1=0; x2=(2*cdiff)+1;
x=[1 1 0 0;x1 x2 1 1; x1^2 x2^2 2*x1 2*x2; x1^3 x2^3 3*x1^2 3*x2^2];
for I=1:nr;
y=[g(I,nc) g(I,1) gpx2(I,3) gpx1(I,1)];
c=y/x;
for J=1:cdiff;
gt(I+rdiff,J)=c(1)+(J+cdiff)*c(2)+c(3)*(J+cdiff)^2+c(4)*(J+cdiff)^3;
gt(I+rdiff,J+nc+cdiff)=c(1)+J*c(2)+c(3)*J^2+c(4)*J^3;
end;
end;
gp=g(1:3,:); [junk,gpx1]=gradient(gp); % top and bottom
gp=g(nr-2:nr,:); [junk,gpx2]=gradient(gp);
x1=0; x2=(2*rdiff)+1;
x=[1 1 0 0;x1 x2 1 1; x1^2 x2^2 2*x1 2*x2; x1^3 x2^3 3*x1^2 3*x2^2];
for J=1:nc;
y=[g(nr,J) g(1,J) gpx2(3,J) gpx1(1,J)];
c=y/x;
for I=1:rdiff;
gt(I,J+cdiff)=c(1)+(I+rdiff)*c(2)+c(3)*(I+rdiff)^2+c(4)*(I+rdiff)^3;
gt(I+rdiff+nr,J+cdiff)=c(1)+I*c(2)+c(3)*I^2+c(4)*I^3;
end;
end;
for I=rdiff+nr+1:npts; % Corners
for J=cdiff+nc+1:npts;
if (I-nr-rdiff)>(J-nc-cdiff); gt(I,J)=gt(I,nc+cdiff); else gt(I,J)=gt(nr+rdiff,J); end;
end;
end;
for I=1:rdiff;
4
5. for J=1:cdiff;
if I>J; gt(I,J)=gt(rdiff+1,J); else gt(I,J)=gt(I,cdiff+1); end;
end;
end;
for I=1:rdiff; % bottom right
for J=cdiff+nc+1:npts;
if I>(npts-J); gt(I,J)=gt(rdiff+1,J); else gt(I,J)=gt(I,cdiff+nc); end;
end;
end;
for I=rdiff+nr+1:npts; % top left
for J=1:cdiff;
if (npts-I)>J; gt(I,J)=gt(rdiff+nr,J); else gt(I,J)=gt(I,cdiff+1); end;
end;
end;
Appendix 2 - The program generates a magnetic field model (uniform magnetic sphere center in x0, y0-depth z0 and radius r0)
function [XI,YI,L,N,Bx,By,Bz,T] = s3d2(incl,x0,y0)
clc
d2rad=pi/180;
incl=incl*d2rad;
decl=0;
z0=50;rs=20;nx=201;ny=nx;azm=0*d2rad;
%f=msphere3(incl,decl,M,dz,rs,nx,dx,ix,iy);
F=50000; % Strength of Earth''s field (nT)
chi=0.1; % Susceptibility of sphere (SI)
vol = (4*pi*rs.^3)./3;
cm=1e-7;
mu_0 = 4*pi*cm;
M=vol*chi*F/(mu_0) ; % Magnetization of sphere
m0=M ; % Magnetic moment of sphere
lx=600 ;ly=600;%length of grid (m)
dx=lx./(nx-1);dy=ly./(nx-1);
x=linspace(-lx/2,lx/2,nx);
y=linspace(-ly/2,ly/2,ny);
Mx=cos(incl).*cos(decl-azm);
My=cos(incl).*sin(decl-azm);
Mz=sin(incl);
rx=(x-x0);
5
6. ry=(y-y0);
rz=0-(z0)*ones(1,nx);
for i=1:nx
for j=1:ny
r2(i,j)=rx(i)^2+ry(j)^2+rz(i)^2;
r(i,j)=sqrt(r2(i,j));
dot(i,j)=rx(i)*Mx+ry(j)*My+rz(i)*Mz;
% z0=z0.*ones(101,101);
r5(i,j)=r(i,j)^5;
Bx(i,j)=m0*cm*(3*dot(i,j)*rx(i)-(r2(i,j)*Mx))/r5(i,j);
By(i,j)=m0*cm*(3*dot(i,j)*ry(j)-(r2(i,j)*My))/r5(i,j);
Bz(i,j)=m0*cm*(3*dot(i,j)*rz(i)-(r2(i,j)*Mz))/r5(i,j);
IB(i,j)=atan(Bz(i,j)/sqrt((Bx(i,j)^2)+(By(i,j))^2));
DB(i,j)=acos(Bx(i,j)/sqrt((Bx(i,j)^2)+(By(i,j))^2));
DB(i,j)=decl;
IB(i,j)=incl;
B(i,j)=(Bx(i,j)*cos(DB(i,j))*cos(IB(i,j))+By(i,j)*sin(DB(i, j))*cos(IB(i,j)))+Bz(i,j)*sin(IB(i,j));
end
end
N=401;
xi=linspace(min(x),max(x),N);
yi=linspace(min(y),max(y),N);
L=max(xi)-min(yi);
[XI,YI] = meshgrid(xi,yi);
T = griddata(x,y,B,XI,YI,'linear');
Bx = griddata(x,y,Bx,XI,YI,'linear');
By = griddata(x,y,By,XI,YI,'linear');
Bz = griddata(x,y,Bz,XI,YI,'linear');
6
7. Appendix 3 -Matlab program used to calculate differential reduction to pole (DRTP)correction
%********(Differential Reduction to pole DRTP)
% Reduction to Pole with variable geomagnetic parameters
% *** Uses a perturbation method in the frequency domain
% drtp Reduce a magnetic field anomaly map to the pole
% using Fourier transform and specifying variation of inclination and
% declination of the magnetic field and magnetization
% Please notice that north is along X axis
% Z is positive beyond horizontal
% PC-MATLAB
% AUTHOR
% Vahid Ghobadian-IASBS-Department of Earth Sciences - March 5 2012
clear all
clc
load c.mat
format short g ;
deltaT=data(:,1);%input =data(x,y,T)
x=(data(:,3));
y=(data(:,2));
x1=min(x):1.25:max(x);
y1=min(y):1.25:max(y);
[XI,YI]=meshgrid(x1,y1);
dx=XI(1,2)-XI(1,1);dy=YI(2,1)-YI(1,1); %Define sample interval in x,y direction
clear XI;clear YI;
deltaT=gridfit(x,y,deltaT,x1,y1); %creation grid data
decl=data(:,4);
incl=data(:,5);
7
8. d2rad=pi/180; %converting degrees to radians
[nx,ny]=size(deltaT); %Define demension of input 2-D data in x-y direction
cm=1e-7; %constant value calculation in SI
img=sqrt(-1); %imaginary number
clear data;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Constructing the external feild
incv =gridfit(x,y,incl,x1,y1)*d2rad; % inclination matrix
%incv=incv';
declv =gridfit(x,y,decl,x1,y1)*d2rad; % inclination matrix
%declv=declv';
%clear XI;clear YI;
inc=incv(ceil(nx/2),ceil(ny/2)); % inclination at centre of grid
dec=declv(ceil(nx/2),ceil(ny/2));
fx=(cos(incv).*cos(declv)); % vector of external feild in x
fy=cos(incv) .* sin(declv); % vector of external feild in y
fz=(sin(incv)); % vector of external feild in z
clear incv;
clear declv;
% Defining components of external field at the center of our study region,
f0_x=fx(floor(nx/2),floor(ny/2)); %fx in center of Iran
f0_y=fy(floor(nx/2),floor(ny/2)); %fy in center of Iran
f0_z=fz(floor(nx/2),floor(ny/2)); %fz in center of Iran
% Calculating delta_f
deltafx=(fx-f0_x); %perturbation about uniform vector f0_x
deltafy=(fy-f0_y); %perturbation about uniform vector f0_x
deltafz=(fz-f0_z); %perturbation about uniform vector f0_x
Mx=fx;
My=fy;
Mz=0;
clear fx;
clear fy;
clear fz;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%
% Defining wave number
kx=kvalue(nx,dx);
ky=(kvalue(ny,dy));
kx=(kx'*ones(1,ny));
ky=(ky'*ones(1,nx));ky=(ky');
k=(sqrt(kx.*kx+ky.*ky));kx=img.*kx;ky=img.*ky;kz=abs(k);
kdotf0=f0_x.*kx+f0_y.*ky+f0_z.*kz;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%
%furier transform of the Total field anomaly
fdT=(fft2(deltaT));
8
9. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
% calculating gradient of V, Gv
fv= zeros(nx,ny);
fv_old=fv;
epsilon=1e-2;
iter=0;
error =1000;
while error > epsilon
Gv1= real(ifft2(kx .* (fv)));
Gv2= real(ifft2(ky .* (fv)));
Gv3= real(ifft2(kz .* (fv)));
nl=(deltafx.*Gv1+deltafy.*Gv2+deltafz.*Gv3);
clear Gv1;clear Gv2;clear Gv3;
% Calculating potential field V
for i=1:nx
for j=1:ny
if (kdotf0(i,j) ~= 0)
fv(i,j)=-(fdT(i,j)+fft2(nl(i,j)))/kdotf0(i,j);
else
kdotf0(i,j)=1;
end;
end;
end;
error = sqrt(sum(sum( (real(fv - fv_old)).^2)));
fv_old =fv;
error
iter=iter+1;
iter
if iter > 10 , break;
end
end
disp('fv converged!');
clear nl;
kdotM0=kdotf0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%
M0x=f0_x;
M0y=f0_y;
M0z=f0_z;
9
10. % Calculating magnetization of the equvalant layer
fM=zeros(nx,ny);
M=zeros(nx,ny);
fM_old= fM;
epsilon2=1e-3;
iter2=0;
error2 =1000;
while error2 > epsilon2
M=real(ifft2(fM));
deltamx=Mx-M0x;
deltamy=My-M0y;
deltamz=0;
fMdm_x=(fft2(M.*deltamx));
fMdm_y=(fft2(M.*deltamy));
fMdm_z=(fft2(M.*deltamz));
clear deltamx;
clear deltamy;
clear deltamz;
kdotfMdm=kx.*fMdm_x+ky.*fMdm_y+kz.*fMdm_z;
for i=1:nx
for j=1:ny
if (kdotM0(i,j) ~= 0)
fM(i,j)=- ((fv(i,j)*k(i,j))/(2*pi*cm)+(kdotfMdm(i,j)))/kdotM0(i,j);
else
kdotM0(i,j)=1;
end;
end;
end;
error2 = sqrt(sum(sum( (real(fM - fM_old)).^2)));
fM_old = fM;
error2
iter2=iter2+1;
iter2
if iter2 > 20 , break;
end
end
disp ('fm converged!');
fTp=2*pi*cm*(kz.*fM);
Tp=(real(ifft2(fTp)));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11. %load iranmagfull.mat
[XI,YI]=meshgrid(x1,y1);
n=1;
for i=1:ny;
for j=1:nx;
xx(n)=XI(j,i);
yy(n)=YI(j,i);
Tpp(n)=Tp(j,i);
n=n+1;
end
end
yy=yy';xx=xx';Tpp=Tpp';
output =[yy,xx ,(Tpp)];
save Tpfull.txt output -ascii;%save output in Tpout.txt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [zgrid,xgrid,ygrid] = gridfit(x,y,z,xnodes,ynodes,varargin)
% usage #1: zgrid = gridfit(x,y,z,xnodes,ynodes);
% usage #2: [zgrid,xgrid,ygrid] = gridfit(x,y,z,xnodes,ynodes);
% usage #3: zgrid = gridfit(x,y,z,xnodes,ynodes,prop,val,prop,val,...);
% set defaults
params.smoothness = 1;
params.interp = 'triangle';
params.regularizer = 'gradient';
params.solver = 'backslash';
params.maxiter = [];
params.extend = 'warning';
params.tilesize = inf;
params.overlap = 0.20;
params.mask = [];
params.autoscale = 'on';
params.xscale = 1;
params.yscale = 1;
% was the params struct supplied?
if ~isempty(varargin)
if isstruct(varargin{1})
% params is only supplied if its a call from tiled_gridfit
params = varargin{1};
if length(varargin)>1
% check for any overrides
params = parse_pv_pairs(params,varargin{2:end});
end
else
% check for any overrides of the defaults
params = parse_pv_pairs(params,varargin);
end
end
% check the parameters for acceptability
params = check_params(params);
% ensure all of x,y,z,xnodes,ynodes are column vectors,
% also drop any NaN data
11
12. x=x(:);
y=y(:);
z=z(:);
k = isnan(x) | isnan(y) | isnan(z);
if any(k)
x(k)=[];
y(k)=[];
z(k)=[];
end
xmin = min(x);
xmax = max(x);
ymin = min(y);
ymax = max(y);
% did they supply a scalar for the nodes?
if length(xnodes)==1
xnodes = linspace(xmin,xmax,xnodes)';
xnodes(end) = xmax; % make sure it hits the max
end
if length(ynodes)==1
ynodes = linspace(ymin,ymax,ynodes)';
ynodes(end) = ymax; % make sure it hits the max
end
xnodes=xnodes(:);
ynodes=ynodes(:);
dx = diff(xnodes);
dy = diff(ynodes);
nx = length(xnodes);
ny = length(ynodes);
ngrid = nx*ny;
% set the scaling if autoscale was on
if strcmpi(params.autoscale,'on')
params.xscale = mean(dx);
params.yscale = mean(dy);
params.autoscale = 'off';
end
% check to see if any tiling is necessary
if (params.tilesize < max(nx,ny))
% split it into smaller tiles. compute zgrid and ygrid
% at the very end if requested
zgrid = tiled_gridfit(x,y,z,xnodes,ynodes,params);
else
% its a single tile.
% mask must be either an empty array, or a boolean
% aray of the same size as the final grid.
nmask = size(params.mask);
if ~isempty(params.mask) && ((nmask(2)~=nx) || (nmask(1)~=ny))
if ((nmask(2)==ny) || (nmask(1)==nx))
error 'Mask array is probably transposed from proper orientation.'
else
12
13. error 'Mask array must be the same size as the final grid.'
end
end
if ~isempty(params.mask)
params.maskflag = 1;
else
params.maskflag = 0;
end
% default for maxiter?
if isempty(params.maxiter)
params.maxiter = min(10000,nx*ny);
end
% check lengths of the data
n = length(x);
if (length(y)~=n) || (length(z)~=n)
error 'Data vectors are incompatible in size.'
end
if n<3
error 'Insufficient data for surface estimation.'
end
% verify the nodes are distinct
if any(diff(xnodes)<=0) || any(diff(ynodes)<=0)
error 'xnodes and ynodes must be monotone increasing'
end
% do we need to tweak the first or last node in x or y?
if xmin<xnodes(1)
switch params.extend
case 'always'
xnodes(1) = xmin;
case 'warning'
warning('GRIDFIT:extend',['xnodes(1) was decreased by: ',num2str(xnodes(1)-xmin),', new node = ',num2str(xmin)])
xnodes(1) = xmin;
case 'never'
error(['Some x (',num2str(xmin),') falls below xnodes(1) by: ',num2str(xnodes(1)-xmin)])
end
end
if xmax>xnodes(end)
switch params.extend
case 'always'
xnodes(end) = xmax;
case 'warning'
warning('GRIDFIT:extend',['xnodes(end) was increased by: ',num2str(xmax-xnodes(end)),', new node = ',num2str(xmax)])
xnodes(end) = xmax;
case 'never'
error(['Some x (',num2str(xmax),') falls above xnodes(end) by: ',num2str(xmax-xnodes(end))])
end
end
13
14. if ymin<ynodes(1)
switch params.extend
case 'always'
ynodes(1) = ymin;
case 'warning'
warning('GRIDFIT:extend',['ynodes(1) was decreased by: ',num2str(ynodes(1)-ymin),', new node = ',num2str(ymin)])
ynodes(1) = ymin;
case 'never'
error(['Some y (',num2str(ymin),') falls below ynodes(1) by: ',num2str(ynodes(1)-ymin)])
end
end
if ymax>ynodes(end)
switch params.extend
case 'always'
ynodes(end) = ymax;
case 'warning'
warning('GRIDFIT:extend',['ynodes(end) was increased by: ',num2str(ymax-ynodes(end)),', new node = ',num2str(ymax)])
ynodes(end) = ymax;
case 'never'
error(['Some y (',num2str(ymax),') falls above ynodes(end) by: ',num2str(ymax-ynodes(end))])
end
end
% determine which cell in the array each point lies in
[junk,indx] = histc(x,xnodes); %#ok
[junk,indy] = histc(y,ynodes); %#ok
% any point falling at the last node is taken to be
% inside the last cell in x or y.
k=(indx==nx);
indx(k)=indx(k)-1;
k=(indy==ny);
indy(k)=indy(k)-1;
ind = indy + ny*(indx-1);
% Do we have a mask to apply?
if params.maskflag
% if we do, then we need to ensure that every
% cell with at least one data point also has at
% least all of its corners unmasked.
params.mask(ind) = 1;
params.mask(ind+1) = 1;
params.mask(ind+ny) = 1;
params.mask(ind+ny+1) = 1;
end
% interpolation equations for each point
tx = min(1,max(0,(x - xnodes(indx))./dx(indx)));
ty = min(1,max(0,(y - ynodes(indy))./dy(indy)));
% Future enhancement: add cubic interpolant
switch params.interp
case 'triangle'
14
15. % linear interpolation inside each triangle
k = (tx > ty);
L = ones(n,1);
L(k) = ny;
t1 = min(tx,ty);
t2 = max(tx,ty);
A = sparse(repmat((1:n)',1,3),[ind,ind+ny+1,ind+L], ...
[1-t2,t1,t2-t1],n,ngrid);
case 'nearest'
% nearest neighbor interpolation in a cell
k = round(1-ty) + round(1-tx)*ny;
A = sparse((1:n)',ind+k,ones(n,1),n,ngrid);
case 'bilinear'
% bilinear interpolation in a cell
A = sparse(repmat((1:n)',1,4),[ind,ind+1,ind+ny,ind+ny+1], ...
[(1-tx).*(1-ty), (1-tx).*ty, tx.*(1-ty), tx.*ty], ...
n,ngrid);
end
rhs = z;
% do we have relative smoothing parameters?
if numel(params.smoothness) == 1
% it was scalar, so treat both dimensions equally
smoothparam = params.smoothness;
xyRelativeStiffness = [1;1];
else
% It was a vector, so anisotropy reigns.
% I've already checked that the vector was of length 2
smoothparam = sqrt(prod(params.smoothness));
xyRelativeStiffness = params.smoothness(:)./smoothparam;
end
% Build regularizer. Add del^4 regularizer one day.
switch params.regularizer
case 'springs'
% zero "rest length" springs
[i,j] = meshgrid(1:nx,1:(ny-1));
ind = j(:) + ny*(i(:)-1);
m = nx*(ny-1);
stiffness = 1./(dy/params.yscale);
Areg = sparse(repmat((1:m)',1,2),[ind,ind+1], ...
xyRelativeStiffness(2)*stiffness(j(:))*[-1 1], ...
m,ngrid);
[i,j] = meshgrid(1:(nx-1),1:ny);
ind = j(:) + ny*(i(:)-1);
m = (nx-1)*ny;
stiffness = 1./(dx/params.xscale);
Areg = [Areg;sparse(repmat((1:m)',1,2),[ind,ind+ny], ...
xyRelativeStiffness(1)*stiffness(i(:))*[-1 1],m,ngrid)];
15
16. [i,j] = meshgrid(1:(nx-1),1:(ny-1));
ind = j(:) + ny*(i(:)-1);
m = (nx-1)*(ny-1);
stiffness = 1./sqrt((dx(i(:))/params.xscale/xyRelativeStiffness(1)).^2 + ...
(dy(j(:))/params.yscale/xyRelativeStiffness(2)).^2);
Areg = [Areg;sparse(repmat((1:m)',1,2),[ind,ind+ny+1], ...
stiffness*[-1 1],m,ngrid)];
Areg = [Areg;sparse(repmat((1:m)',1,2),[ind+1,ind+ny], ...
stiffness*[-1 1],m,ngrid)];
case {'diffusion' 'laplacian'}
% thermal diffusion using Laplacian (del^2)
[i,j] = meshgrid(1:nx,2:(ny-1));
ind = j(:) + ny*(i(:)-1);
dy1 = dy(j(:)-1)/params.yscale;
dy2 = dy(j(:))/params.yscale;
Areg = sparse(repmat(ind,1,3),[ind-1,ind,ind+1], ...
xyRelativeStiffness(2)*[-2./(dy1.*(dy1+dy2)), ...
2./(dy1.*dy2), -2./(dy2.*(dy1+dy2))],ngrid,ngrid);
[i,j] = meshgrid(2:(nx-1),1:ny);
ind = j(:) + ny*(i(:)-1);
dx1 = dx(i(:)-1)/params.xscale;
dx2 = dx(i(:))/params.xscale;
Areg = Areg + sparse(repmat(ind,1,3),[ind-ny,ind,ind+ny], ...
xyRelativeStiffness(1)*[-2./(dx1.*(dx1+dx2)), ...
2./(dx1.*dx2), -2./(dx2.*(dx1+dx2))],ngrid,ngrid);
case 'gradient'
% Subtly different from the Laplacian. A point for future
% enhancement is to do it better for the triangle interpolation
% case.
[i,j] = meshgrid(1:nx,2:(ny-1));
ind = j(:) + ny*(i(:)-1);
dy1 = dy(j(:)-1)/params.yscale;
dy2 = dy(j(:))/params.yscale;
Areg = sparse(repmat(ind,1,3),[ind-1,ind,ind+1], ...
xyRelativeStiffness(2)*[-2./(dy1.*(dy1+dy2)), ...
2./(dy1.*dy2), -2./(dy2.*(dy1+dy2))],ngrid,ngrid);
[i,j] = meshgrid(2:(nx-1),1:ny);
ind = j(:) + ny*(i(:)-1);
dx1 = dx(i(:)-1)/params.xscale;
dx2 = dx(i(:))/params.xscale;
Areg = [Areg;sparse(repmat(ind,1,3),[ind-ny,ind,ind+ny], ...
xyRelativeStiffness(1)*[-2./(dx1.*(dx1+dx2)), ...
2./(dx1.*dx2), -2./(dx2.*(dx1+dx2))],ngrid,ngrid)];
16
17. end
nreg = size(Areg,1);
% Append the regularizer to the interpolation equations,
% scaling the problem first. Use the 1-norm for speed.
NA = norm(A,1);
NR = norm(Areg,1);
A = [A;Areg*(smoothparam*NA/NR)];
rhs = [rhs;zeros(nreg,1)];
% do we have a mask to apply?
if params.maskflag
unmasked = find(params.mask);
end
% solve the full system, with regularizer attached
switch params.solver
case {'' 'backslash'}
if params.maskflag
% there is a mask to use
zgrid=nan(ny,nx);
zgrid(unmasked) = A(:,unmasked)rhs;
else
% no mask
zgrid = reshape(Arhs,ny,nx);
end
case 'normal'
% The normal equations, solved with . Can be faster
% for huge numbers of data points, but reasonably
% sized grids. The regularizer makes A well conditioned
% so the normal equations are not a terribly bad thing
% here.
if params.maskflag
% there is a mask to use
Aunmasked = A(:,unmasked);
zgrid=nan(ny,nx);
zgrid(unmasked) = (Aunmasked'*Aunmasked)(Aunmasked'*rhs);
else
zgrid = reshape((A'*A)(A'*rhs),ny,nx);
end
case 'symmlq'
% iterative solver - symmlq - requires a symmetric matrix,
% so use it to solve the normal equations. No preconditioner.
tol = abs(max(z)-min(z))*1.e-13;
if params.maskflag
% there is a mask to use
zgrid=nan(ny,nx);
[zgrid(unmasked),flag] = symmlq(A(:,unmasked)'*A(:,unmasked), ...
A(:,unmasked)'*rhs,tol,params.maxiter);
else
[zgrid,flag] = symmlq(A'*A,A'*rhs,tol,params.maxiter);
zgrid = reshape(zgrid,ny,nx);
end
% display a warning if convergence problems
17
18. switch flag
case 0
% no problems with convergence
case 1
% SYMMLQ iterated MAXIT times but did not converge.
warning('GRIDFIT:solver',['Symmlq performed ',num2str(params.maxiter), ...
' iterations but did not converge.'])
case 3
% SYMMLQ stagnated, successive iterates were the same
warning('GRIDFIT:solver','Symmlq stagnated without apparent convergence.')
otherwise
warning('GRIDFIT:solver',['One of the scalar quantities calculated in',...
' symmlq was too small or too large to continue computing.'])
end
case 'lsqr'
% iterative solver - lsqr. No preconditioner here.
tol = abs(max(z)-min(z))*1.e-13;
if params.maskflag
% there is a mask to use
zgrid=nan(ny,nx);
[zgrid(unmasked),flag] = lsqr(A(:,unmasked),rhs,tol,params.maxiter);
else
[zgrid,flag] = lsqr(A,rhs,tol,params.maxiter);
zgrid = reshape(zgrid,ny,nx);
end
% display a warning if convergence problems
switch flag
case 0
case 1
warning('GRIDFIT:solver',['Lsqr performed ', ...
num2str(params.maxiter),' iterations but did not converge.'])
case 3
% lsqr stagnated, successive iterates were the same
warning('GRIDFIT:solver','Lsqr stagnated without apparent convergence.')
case 4
warning('GRIDFIT:solver',['One of the scalar quantities calculated in',...
' LSQR was too small or too large to continue computing.'])
end
end % switch params.solver
end % if params.tilesize...
18
19. % only generate xgrid and ygrid if requested.
if nargout>1
[xgrid,ygrid]=meshgrid(xnodes,ynodes);
end
% subfunction - parse_pv_pairs
% ============================================
function params=parse_pv_pairs(params,pv_pairs)
% usage: params=parse_pv_pairs(default_params,pv_pairs)
npv = length(pv_pairs);
n = npv/2;
if n~=floor(n)
error 'Property/value pairs must come in PAIRS.'
end
if n<=0
% just return the defaults
return
end
if ~isstruct(params)
error 'No structure for defaults was supplied'
end
% there was at least one pv pair. process any supplied
propnames = fieldnames(params);
lpropnames = lower(propnames);
for i=1:n
p_i = lower(pv_pairs{2*i-1});
v_i = pv_pairs{2*i};
ind = strmatch(p_i,lpropnames,'exact');
if isempty(ind)
ind = find(strncmp(p_i,lpropnames,length(p_i)));
if isempty(ind)
error(['No matching property found for: ',pv_pairs{2*i-1}])
elseif length(ind)>1
error(['Ambiguous property name: ',pv_pairs{2*i-1}])
end
end
p_i = propnames{ind};
% override the corresponding default in params
params = setfield(params,p_i,v_i); %#ok
end
% ============================================
% subfunction - check_params
% ============================================
function params = check_params(params)
if isempty(params.smoothness)
params.smoothness = 1;
else
19
20. if (numel(params.smoothness)>2) || any(params.smoothness<=0)
error 'Smoothness must be scalar (or length 2 vector), real, finite, and positive.'
end
end
% regularizer - must be one of 4 options - the second and
% third are actually synonyms.
valid = {'springs', 'diffusion', 'laplacian', 'gradient'};
if isempty(params.regularizer)
params.regularizer = 'diffusion';
end
ind = find(strncmpi(params.regularizer,valid,length(params.regularizer)));
if (length(ind)==1)
params.regularizer = valid{ind};
else
error(['Invalid regularization method: ',params.regularizer])
end
% interp must be one of:
% 'bilinear', 'nearest', or 'triangle'
% but accept any shortening thereof.
valid = {'bilinear', 'nearest', 'triangle'};
if isempty(params.interp)
params.interp = 'triangle';
end
ind = find(strncmpi(params.interp,valid,length(params.interp)));
if (length(ind)==1)
params.interp = valid{ind};
else
error(['Invalid interpolation method: ',params.interp])
end
% solver must be one of:
% 'backslash', '', 'symmlq', 'lsqr', or 'normal'
% but accept any shortening thereof.
valid = {'backslash', '', 'symmlq', 'lsqr', 'normal'};
if isempty(params.solver)
params.solver = '';
end
ind = find(strncmpi(params.solver,valid,length(params.solver)));
if (length(ind)==1)
params.solver = valid{ind};
else
error(['Invalid solver option: ',params.solver])
end
% extend must be one of:
% 'never', 'warning', 'always'
% but accept any shortening thereof.
valid = {'never', 'warning', 'always'};
if isempty(params.extend)
params.extend = 'warning';
end
20
21. ind = find(strncmpi(params.extend,valid,length(params.extend)));
if (length(ind)==1)
params.extend = valid{ind};
else
error(['Invalid extend option: ',params.extend])
end
% tilesize == inf by default
if isempty(params.tilesize)
params.tilesize = inf;
elseif (length(params.tilesize)>1) || (params.tilesize<3)
error 'Tilesize must be scalar and > 0.'
end
% overlap == 0.20 by default
if isempty(params.overlap)
params.overlap = 0.20;
elseif (length(params.overlap)>1) || (params.overlap<0) || (params.overlap>0.5)
error 'Overlap must be scalar and 0 < overlap < 1.'
end
% ============================================
% subfunction - tiled_gridfit
% ============================================
function zgrid=tiled_gridfit(x,y,z,xnodes,ynodes,params)
% usage: [zgrid,xgrid,ygrid]=tiled_gridfit(x,y,z,xnodes,ynodes,params)
tilesize = params.tilesize;
overlap = max(2,floor(tilesize*params.overlap));
Tparams = params;
Tparams.tilesize = inf;
nx = length(xnodes);
ny = length(ynodes);
zgrid = zeros(ny,nx);
% linear ramp for the bilinear interpolation
rampfun = inline('(t-t(1))/(t(end)-t(1))','t');
% loop over each tile in the grid
h = waitbar(0,'Relax and have a cup of JAVA. Its my treat.');
warncount = 0;
xtind = 1:min(nx,tilesize);
while ~isempty(xtind) && (xtind(1)<=nx)
xinterp = ones(1,length(xtind));
if (xtind(1) ~= 1)
xinterp(1:overlap) = rampfun(xnodes(xtind(1:overlap)));
end
if (xtind(end) ~= nx)
xinterp((end-overlap+1):end) = 1-rampfun(xnodes(xtind((end- overlap+1):end)));
end
ytind = 1:min(ny,tilesize);
21
22. while ~isempty(ytind) && (ytind(1)<=ny)
% update the waitbar
waitbar((xtind(end)-tilesize)/nx + tilesize*ytind(end)/ny/nx)
yinterp = ones(length(ytind),1);
if (ytind(1) ~= 1)
yinterp(1:overlap) = rampfun(ynodes(ytind(1:overlap)));
end
if (ytind(end) ~= ny)
yinterp((end-overlap+1):end) = 1-rampfun(ynodes(ytind((end- overlap+1):end)));
end
% was a mask supplied?
if ~isempty(params.mask)
submask = params.mask(ytind,xtind);
Tparams.mask = submask;
end
% extract data that lies in this grid tile
k = (x>=xnodes(xtind(1))) & (x<=xnodes(xtind(end))) & ...
(y>=ynodes(ytind(1))) & (y<=ynodes(ytind(end)));
k = find(k);
if length(k)<4
if warncount == 0
warning('GRIDFIT:tiling','A tile was too underpopulated to model. Filled with NaNs.')
end
warncount = warncount + 1;
% fill this part of the grid with NaNs
zgrid(ytind,xtind) = NaN;
else
% build this tile
zgtile = gridfit(x(k),y(k),z(k),xnodes(xtind),ynodes(ytind),Tparams);
% bilinear interpolation (using an outer product)
interp_coef = yinterp*xinterp;
% accumulate the tile into the complete grid
zgrid(ytind,xtind) = zgrid(ytind,xtind) + zgtile.*interp_coef;
end
% step to the next tile in y
if ytind(end)<ny
ytind = ytind + tilesize - overlap;
% are we within overlap elements of the edge of the grid?
if (ytind(end)+max(3,overlap))>=ny
% extend this tile to the edge
ytind = ytind(1):ny;
end
22
23. else
ytind = ny+1;
end
end % while loop over y
% step to the next tile in x
if xtind(end)<nx
xtind = xtind + tilesize - overlap;
% are we within overlap elements of the edge of the grid?
if (xtind(end)+max(3,overlap))>=nx
% extend this tile to the edge
xtind = xtind(1):nx;
end
else
xtind = nx+1;
end
end % while loop over x
% close down the waitbar
close(h)
if warncount>0
warning('GRIDFIT:tiling',[num2str(warncount),' tiles were underpopulated & filled with NaNs'])
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function kx=kvalue(nn,dx)
% KVALUE compute wavenumber coordinate
% Usage:
% kx=kvalue(nn,dx);
%
nn2=nn/2;
n2plus=nn2+1;
dkx=2*pi/(nn*dx);
% make wave number array
kx=(-nn2:nn2-1).*dkx;
kx=fftshift(kx);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function gt=taper2d(g,npts,nr,nc,rdiff,cdiff)
% Merge edges to the value opposite using a cubic spline
gt=zeros(npts); gt(rdiff+1:rdiff+nr,cdiff+1:cdiff+nc)=g;
gp=g(:,1:3); [gpx1,junk]=gradient(gp); % sides
gp=g(:,nc-2:nc); [gpx2,junk]=gradient(gp);
x1=0; x2=(2*cdiff)+1;
x=[1 1 0 0;x1 x2 1 1; x1^2 x2^2 2*x1 2*x2; x1^3 x2^3 3*x1^2 3*x2^2];
for I=1:nr;
y=[g(I,nc) g(I,1) gpx2(I,3) gpx1(I,1)];
c=y/x;
for J=1:cdiff;
gt(I+rdiff,J)=c(1)+(J+cdiff)*c(2)+c(3)*(J+cdiff)^2+c(4)*(J+cdiff)^3;
gt(I+rdiff,J+nc+cdiff)=c(1)+J*c(2)+c(3)*J^2+c(4)*J^3;
end;
23
24. end;
gp=g(1:3,:); [junk,gpx1]=gradient(gp); % top and bottom
gp=g(nr-2:nr,:); [junk,gpx2]=gradient(gp);
x1=0; x2=(2*rdiff)+1;
x=[1 1 0 0;x1 x2 1 1; x1^2 x2^2 2*x1 2*x2; x1^3 x2^3 3*x1^2 3*x2^2];
for J=1:nc;
y=[g(nr,J) g(1,J) gpx2(3,J) gpx1(1,J)];
c=y/x;
for I=1:rdiff;
gt(I,J+cdiff)=c(1)+(I+rdiff)*c(2)+c(3)*(I+rdiff)^2+c(4)*(I+rdiff)^3;
gt(I+rdiff+nr,J+cdiff)=c(1)+I*c(2)+c(3)*I^2+c(4)*I^3;
end;
end;
for I=rdiff+nr+1:npts; % Corners
for J=cdiff+nc+1:npts;
if (I-nr-rdiff)>(J-nc-cdiff); gt(I,J)=gt(I,nc+cdiff); else gt(I,J)=gt(nr+rdiff,J); end;
end;
end;
for I=1:rdiff;
for J=1:cdiff;
if I>J; gt(I,J)=gt(rdiff+1,J); else gt(I,J)=gt(I,cdiff+1); end;
end;
end;
for I=1:rdiff; % bottom right
for J=cdiff+nc+1:npts;
if I>(npts-J); gt(I,J)=gt(rdiff+1,J); else gt(I,J)=gt(I,cdiff+nc); end;
end;
end;
for I=rdiff+nr+1:npts; % top left
for J=1:cdiff;
if (npts-I)>J; gt(I,J)=gt(rdiff+nr,J); else gt(I,J)=gt(I,cdiff+1); end;
end;
end;
24