Re: Problem with Min Max between two functions
- To: mathgroup at smc.vnet.net
- Subject: [mg112043] Re: Problem with Min Max between two functions
- From: maria giovanna dainotti <mariagiovannadainotti at yahoo.it>
- Date: Thu, 26 Aug 2010 06:49:09 -0400 (EDT)
Dear J. Batista,
I used the following equations
R1==1.029
R2==3.892
R3==8
e1==250
e2==11.8
e3==80.5
i==p/12
spherenear[x_,y_]:==((R3^2-x^2-y^2)^(1/2))
spherefar[x_,y_]:==-((R3^2-x^2-y^2)^(1/2))
jetnear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]
jetfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]
jetbrightness[x_,y_]:==Boole[-R1=EF=82=A3x=EF=82=A3R1]*(jetnear[x,y] - jetfar[x,y])*e1
emptynear[x_,y_]:==Min[Re[spherenear[x,y]],Re[(R2^2-x^2)^(1/2)+y*Tan[i]]]
emptyfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]
emptybrightness[x_,y_]:==Boole[-R1<x<R1]*(emptynear[x,y] -jetnear[x,y] +
jetfar[x,y]- emptyfar[x,y])*e2 +(Boole[-R2
<x<-R1]+Boole[R2>x>R1])*(emptynear[x,y] -jetnear[x,y] + jetfar[x,y]-
emptyfar[x,y])*e2
spherebrightness[x_,y_]:==Boole[-R2<x<R2]*(spherenear[x,y] -emptynear[x,y] +
emptyfar[x,y]- spherefar[x,y])*e3 +(Boole[x<-R2]+Boole[R2<x])*(spherenear[x,y] -
spherefar[x,y])*e3
=E3=80=80
f[x_,y_]:==((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]+jetfar[x,y]-emptyfar[x,y]))*Boole[-R1<x<R1]+((emptynear[x,y]-emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])*e3*(Boole[x<-R2]+Boole[x>R2])
=E3=80=80
1.029
3.892
8
250
11.8
80.5p=C2
originalPlot==ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours=EF=82=AE50,ColorFunction=EF=82=AE(Hue[#]&)]/12
originalColorData====ImageData[originalPlot];
targetPixels====Position[originalColorData,originalColorData[[180,180]]];newColorData====ReplacePart[originalColorData,targetPixels
->
Image[newColorData]
But I got the following error message:
Part::partd: Part specification
\[NoBreak]originalColorData=EF=81=90180,180\[RightDoubleBracket]\[NoBreak] is longer
than depth of object. =EF=82=87
=C2
Image::imgarray: The specified argument \[NoBreak]originalColorData\[NoBreak]
should be an array of rank 2 or 3 with machine-size numbers. =EF=82=87
I will be very grateful if you could help me.
Thanks a lot
Best regards
Maria
=C2 {1.,1.,1.}];
________________________________
Da: J. Batista <jbatista800 at gmail.com>
A: mathgroup at smc.vnet.net
Inviato: Lun 2 agosto 2010, 13:02:00
Oggetto: [mg111445] Re: Problem with Min Max between two functions
Maria/All, I just learned from a colleague that all equations on my message
have double equal signs.=C2 Please note that is probably due to a transm=
ission
error.=C2 All equations should only have a single equal sign.=C2 I'm
retransmitting my original message.
Regards,
J. Batista
On Sun, Aug 1, 2010 at 3:10 AM, J. Batista <jbatista800 at gmail.com> wrote:
> Dean Maria, here is a possible solution to your question.=C2 The white
> contour areas can be removed by approaching the output of ContourPlot as =
an
> image, treating the task as one of image processing (as suggested previou=
sly
> by Daniel Lichtblau).=C2 First, equate the original ContourPlot output=
with a
> variable name, for example originalPlot ==== Out[1]=C2 (where Out[1] i=
s the
> ContourPlot output cell).=C2 Alternatively, you can simply select the
> ContourPlot, copy and then paste into the first line of the code sequence
> below in place of the variable originalPlot.=C2 I will now display the=
four
> lines of the code sequence and then explain them afterwards.
>
> originalColorData ==== ImageData[originalPlot];
>
> targetPixels ==== Position[originalColorData, originalColorData[[180, 180=
]]];
>
> newColorData ==== ReplacePart[originalColorData, targetPixels -> {1., 1.,
> 1.}];
>
> Image[newColorData]
>
>
> The first code line accomplishes the task of collecting and reading the
> ContourPlot into computer memory as image data, in this case a vector of =
RGB
> color values.=C2 Note that I place a semicolon at the end of this and =
other
> lines of code in order to suppress the visual output of the code sequence=
's
> result.=C2 This is because the vector is lengthy and will clog the not=
ebook
> unnecessarily.
> The second code line establishes the pattern by which the portions of the
> plot that you wish to alter are identified as a subset of the entire
> original data set.=C2 The pattern is established by entering the pixel
> coordinate of a representative target pixel that you wish to alter, in th=
is
> case [[180, 180]] being one of the pixels in the white contour areas.=C2=
You
> can determine an appropriate pixel coordinate by right-clicking in the
> original ContourPlot output, selecting Get Indices, and then guiding your
> cursor to a desired location within the plot.
> The third code line replaces the pixel locations flagged by the previous
> pattern search with new pixel data, in this case new RGB color values tha=
t
> you select.=C2 I have used the example of {1., 1., 1.} to illustrate c=
hanging
> from the semi-white color of the original plot to a true white that match=
es
> the plot background.=C2 Be sure to use decimal points as above when ex=
pressing
> color values for your pixels, as something like {1, 1, 1} will not
> be understood correctly for this purpose.=C2 If you want to change the
> semi-white color of your original plot to black, use {0., 0., 0.}.
> The fourth and final line re-establishes the newly altered set of pixel
> data as an image object, and displays the altered image.
>
> Hope this helps.
> Best Regards,
> J. Batista
>
>=C2 On Mon, Jul 26, 2010 at 6:37 AM, maria giovanna dainotti <
> mariagiovannadainotti at yahoo.it> wrote:
>
>> Dear Mathgroup,
>> I have the following function
>> R1====1.029
>> R2====3.892
>> R3====8
>> e1====250
>> e2====11.8
>> e3====80.5
>> i====pi/12
>> spherenear[x_,y_]:====((R3^2-x^2-y^2)^(1/2))
>> spherefar[x_,y_]:====-((R3^2-x^2-y^2)^(1/2))
>> emptynear[x_,y_]:====Min[Re[spherenear[x,y]],Re[(R2^2-x^2)^(1/2)+y*Tan[i=
]]==
]
>> emptyfar[x_,y_]:====Max[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i=
]]
>> jetnear[x_,y_]:====Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]=
]
>> jetfar[x_,y_]:====Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]
>>
>> f[x_,y_]:====((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynea=
r[==
x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]+jetfar[x=
==
,y]-emptyfar[x,y]))*Boole[-R1====EF====82====A3x====EF====82====A3R1]+((emp=
tynear[x,y]-==
emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefa=
==
r[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])=
==
*e3*(Boole[x<-R2]+Boole[x>R2])
>>
>>
>> ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours====EF====82====AE{0,100,20=
0,300,==
400,500,600,700,800,900}]
>>
>> From the picture you can see there is a white contours that results a bi=
==
t
>> odd, I
>> think th at it comes out from the introduction of the Min and Max.
>> I would like to remove this white contour. Could you help me?
>> Thanks a lot for your attention
>> Cheers
>> Maria
>>
>>
>
--0-882231370-1282758216=:97664
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Sun-Content-Length: 10136
<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></he=
ad><body><div style="font-family:arial, helvetica, sans-serif;font-size:1=
4pt"><DIV>Dear J. Batista,</DIV>=0A<DIV>I used the following equations</DIV=
>=0A<DIV>=0A<P>R1=1.029</P>=0A<P>R2=3.892</P>=0A<P>R3=8</P>=0A<P>e1=
=250</P>=0A<P>e2=11.8</P>=0A<P>e3=80.5</P>=0A<P>i=<FONT face=Math=
ematica1Mono>p</FONT>/12</P>=0A<P>spherenear[x_,y_]:=((R3^2-x^2-y^2)^(1/2=
))</P>=0A<P>spherefar[x_,y_]:=-((R3^2-x^2-y^2)^(1/2))</P>=0A<P>jetnear[x_=
,y_]:=Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]</P>=0A<P>jet=
far[x_,y_]:=Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]]</P>=0A=
<P>jetbrightness[x_,y_]:=Boole[-R1<FONT face=Mathematica1Mono>=EF=82=A3=
</FONT>x<FONT face=Mathematica1Mono>=EF=82=A3</FONT>R1]*(jetnear[x,y] - j=
etfar[x,y])*e1</P>=0A<P>emptynear[x_,y_]:=Min[Re[spherenear[x,y]],Re[(R2^=
2-x^2)^(1/2)+y*Tan[i]]]</P>=0A<P>emptyfar[x_,y_]:=Max[Re[spherefar[x,y]],=
Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]</P>=0A<P>emptybrightness[x_,y_]:=Boole[-R=
1<FONT face=Mathematica1Mono><</FONT>x<FONT face=Mathematica1Mono>&l=
t;</FONT>R1]*(emptynear[x,y] -jetnear[x,y] + jetfar[x,y]- emptyfar[x,y])*e2=
+(Boole[-R2 <x<-R1]+Boole[R2>x>R1])*(emptynear[x,y] -jetnear[x=
,y] + jetfar[x,y]- emptyfar[x,y])*e2</P>=0A<P>spherebrightness[x_,y_]:=Bo=
ole[-R2<FONT face=Mathematica1Mono><</FONT>x<FONT face=Mathematica1M=
ono><</FONT>R2]*(spherenear[x,y] -emptynear[x,y] + emptyfar[x,y]- sphere=
far[x,y])*e3 +(Boole[x<-R2]+Boole[R2<x])*(spherenear[x,y] - spherefar=
[x,y])*e3</P>=0A<P>=E3=80=80</P>=0A<P>f[x_,y_]:=((jetnear[x,y]-jetfar[x,y=
])*e1+e3*(spherenear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(=
emptynear[x,y]-jetnear[x,y]+jetfar[x,y]-emptyfar[x,y]))*Boole[-R1<FONT face=
=Mathematica1Mono><</FONT>x<FONT face=Mathematica1Mono><</FONT>R1=
]+((emptynear[x,y]-emptyfar[x,y])*e2+e3*(spherenear[x,y]-emptynear[x,y]+emp=
tyfar[x,y]-spherefar[x,y]))*(Boole[-R2<x<-R1]+Boole[R2>x>R1])+(=
spherenear[x,y]-spherefar[x,y])*e3*(Boole[x<-R2]+Boole[x>R2])</P>=0A<=
P>=E3=80=80</P>=0A<P>1.029</P>=0A<P>3.892</P>=0A<P>8</P>=0A<P>250</P>=0A<P>=
11.8</P>=0A<P>80.5</P><FONT face=Mathematica1Mono>=0A<P>p</FONT><FONT fac=
e="Times New Roman">/12</FONT></P> <BR><B><FONT face=Courier>=0A<P=
>originalPlot=ContourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours</FONT><FONT f=
ace=Mathematica1Mono>=EF=82=AE</FONT><FONT face=Courier>50,ColorFunctio=
n</FONT><FONT face=Mathematica1Mono>=EF=82=AE</FONT><FONT face=Courier>=
(Hue[#]&)]</P></B></FONT></DIV>=0A<DIV style="FONT-FAMILY: arial, hel=
vetica, sans-serif; FONT-SIZE: 14pt"><B><FONT face=Courier>=0A<P align==
left>originalColorData==ImageData[originalPlot];</P>=0A<P align=left>=
targetPixels==Position[originalColorData,originalColorData[[180,180]]];=
newColorData==ReplacePart[originalColorData,targetPixels</P>=0A<P align=
=left>-></FONT><FONT face=Courier>{1.,1.,1.}];</P>=0A<P>Image[newCol=
orData]</P>=0A<P>But I got the following error message: </P>=0A<P>Part::par=
td: Part specification \[NoBreak]originalColorData<FONT face=Mathematica2=
>=EF=81=90</FONT>180,180\[RightDoubleBracket]\[NoBreak] is longer than dept=
h of object. <A href="http://reference.wolfram.com/mathematica/ref/Part.h=
tml"><FONT face=Mathematica1>=EF=82=87</FONT></A></P>=0A<P> </P>=0A<=
P>Image::imgarray: The specified argument \[NoBreak]originalColorData\[NoBr=
eak] should be an array of rank 2 or 3 with machine-size numbers. <A href=
="http://reference.wolfram.com/mathematica/ref/Image.html"><FONT face=M=
athematica1>=EF=82=87</FONT></A></P>=0A<P>I will be very grateful if you co=
uld help me.</P>=0A<P>Thanks a lot</P>=0A<P>Best regards</P>=0A<P>Maria</P>=
=0A<P> </P></B></FONT>=0A<DIV style="FONT-FAMILY: arial, helvetica, =
sans-serif; FONT-SIZE: 13px"><FONT size=2 face=Tahoma>=0A<HR SIZE=1>=
=0A<B><SPAN style="FONT-WEIGHT: bold">Da:</SPAN></B> J. Batista <jbati=
sta800 at gmail.com><BR><B><SPAN style="FONT-WEIGHT: bold">A:</SPAN></B> =
mathgroup at smc.vnet.net<BR><B><SPAN style="FONT-WEIGHT: bold">Inviato:</SP=
AN></B> Lun 2 agosto 2010, 13:02:00<BR><B><SPAN style="FONT-WEIGHT: bold"=
>Oggetto:</SPAN></B> [mg111445] Re: Problem with Min Max between two functi=
ons<BR></FONT><BR>Maria/All, I just learned from a colleague that all equat=
ions on my message<BR>have double equal signs. Please note that is pr=
obably due to a transmission<BR>error. All equations should only have=
a single equal sign. I'm<BR>retransmitting my original message.<BR>R=
egards,<BR>J. Batista<BR>On Sun, Aug 1, 2010 at 3:10 AM, J. Batista <<A =
href="mailto:jbatista800 at gmail.com" ymailto="mailto:jbatista800 at gmail.c=
om">jbatista800 at gmail.com</A>> wrote:<BR><BR>> Dean Maria, here is a =
possible solution to your question. The white<BR>> contour areas c=
an be
removed by approaching the output of ContourPlot as an<BR>> image, trea=
ting the task as one of image processing (as suggested previously<BR>> b=
y Daniel Lichtblau). First, equate the original ContourPlot output wi=
th a<BR>> variable name, for example originalPlot == Out[1] (w=
here Out[1] is the<BR>> ContourPlot output cell). Alternatively, y=
ou can simply select the<BR>> ContourPlot, copy and then paste into the =
first line of the code sequence<BR>> below in place of the variable orig=
inalPlot. I will now display the four<BR>> lines of the code seque=
nce and then explain them afterwards.<BR>><BR>> originalColorData ==
= ImageData[originalPlot];<BR>><BR>> targetPixels == Position[o=
riginalColorData, originalColorData[[180, 180]]];<BR>><BR>> newColorD=
ata == ReplacePart[originalColorData, targetPixels -> {1., 1.,<BR>&g=
t; 1.}];<BR>><BR>> Image[newColorData]<BR>><BR>><BR>> The fi=
rst code
line accomplishes the task of collecting and reading the<BR>> ContourPl=
ot into computer memory as image data, in this case a vector of RGB<BR>>=
color values. Note that I place a semicolon at the end of this and o=
ther<BR>> lines of code in order to suppress the visual output of the co=
de sequence's<BR>> result. This is because the vector is lengthy a=
nd will clog the notebook<BR>> unnecessarily.<BR>> The second code li=
ne establishes the pattern by which the portions of the<BR>> plot that y=
ou wish to alter are identified as a subset of the entire<BR>> original =
data set. The pattern is established by entering the pixel<BR>> co=
ordinate of a representative target pixel that you wish to alter, in this<B=
R>> case [[180, 180]] being one of the pixels in the white contour areas=
. You<BR>> can determine an appropriate pixel coordinate by right-=
clicking in the<BR>> original ContourPlot output, selecting Get
Indices, and then guiding your<BR>> cursor to a desired location within=
the plot.<BR>> The third code line replaces the pixel locations flagged=
by the previous<BR>> pattern search with new pixel data, in this case n=
ew RGB color values that<BR>> you select. I have used the example =
of {1., 1., 1.} to illustrate changing<BR>> from the semi-white color of=
the original plot to a true white that matches<BR>> the plot background=
. Be sure to use decimal points as above when expressing<BR>> colo=
r values for your pixels, as something like {1, 1, 1} will not<BR>> be u=
nderstood correctly for this purpose. If you want to change the<BR>&g=
t; semi-white color of your original plot to black, use {0., 0., 0.}.<BR>&g=
t; The fourth and final line re-establishes the newly altered set of pixel<=
BR>> data as an image object, and displays the altered image.<BR>><BR=
>> Hope this helps.<BR>> Best Regards,<BR>> J.
Batista<BR>><BR>> On Mon, Jul 26, 2010 at 6:37 AM, maria giova=
nna dainotti <<BR>> <A href="mailto:mariagiovannadainotti at yahoo.it"=
ymailto="mailto:mariagiovannadainotti at yahoo.it">mariagiovannadainotti@ya=
hoo.it</A>> wrote:<BR>><BR>>> Dear Mathgroup,<BR>>> I hav=
e the following function<BR>>> R1==1.029<BR>>> R2==3.89=
2<BR>>> R3==8<BR>>> e1==250<BR>>> e2==11.8<BR=
>>> e3==80.5<BR>>> i==pi/12<BR>>> spherenear[x_,y=
_]:==((R3^2-x^2-y^2)^(1/2))<BR>>> spherefar[x_,y_]:==-((R3^2-=
x^2-y^2)^(1/2))<BR>>> emptynear[x_,y_]:==Min[Re[spherenear[x,y]],=
Re[(R2^2-x^2)^(1/2)+y*Tan[i]]=<BR>]<BR>>> emptyfar[x_,y_]:==Max=
[Re[spherefar[x,y]],Re[-(R2^2-x^2)^(1/2)]+y*Tan[i]]<BR>>> jetnear[x_,=
y_]:==Min[Re[spherenear[x,y]],Re[(R1^2-x^2)^(1/2)+y*Tan[i]]]<BR>>>=
; jetfar[x_,y_]:==Max[Re[spherefar[x,y]],Re[-(R1^2-x^2)^(1/2)]+y*Tan[i]=
]<BR>>><BR>>>
f[x_,y_]:==((jetnear[x,y]-jetfar[x,y])*e1+e3*(spherenear[x,y]-emptynea=
r[=<BR>x,y]+emptyfar[x,y]-spherefar[x,y])+e2*(emptynear[x,y]-jetnear[x,y]=
+jetfar[x=<BR>,y]-emptyfar[x,y]))*Boole[-R1==EF==82==A3x==
=EF==82==A3R1]+((emptynear[x,y]-=<BR>emptyfar[x,y])*e2+e3*(sphe=
renear[x,y]-emptynear[x,y]+emptyfar[x,y]-spherefa=<BR>r[x,y]))*(Boole[-R2=
<x<-R1]+Boole[R2>x>R1])+(spherenear[x,y]-spherefar[x,y])=<BR>=
*e3*(Boole[x<-R2]+Boole[x>R2])<BR>>><BR>>><BR>>> Co=
ntourPlot[f[x,y],{x,-8,8},{y,-8,8},Contours==EF==82==AE{0,100,2=
00,300,=<BR>400,500,600,700,800,900}]<BR>>><BR>>> From the pi=
cture you can see there is a white contours that results a bi=<BR>t<BR>&g=
t;> odd, I<BR>>> think th at it comes out from the introduction of=
the Min and Max.<BR>>> I would like to remove this white contour. Co=
uld you help me?<BR>>> Thanks a lot for your attention<BR>>> Ch=
eers<BR>>>
Maria<BR>>><BR>>><BR>><BR><BR><BR></DIV></DIV></div><br>=0A=
=0A=0A=0A </body></html>
--0-882231370-1282758216=:97664--