Group Abstract Group Abstract

Message Boards Message Boards

CloudDeploy issue with FormFunction and NSolve

I try to deploy some extreme value analysis in windspeed to the cloud for computing. In notebook works fine but after deployment the server answer is an error.

This is the code in notebook which works fine:

In[10]:= myMaxWindSpeed[lat_, lon_] := 
 UnitConvert[
  Quantity[Part[
      maxwind /. 
       NSolve[Probability[x >= maxwind, 
          x \[Distributed] 
           EstimatedDistribution[
            WeatherData[{lat, lon}, 
             "MaxWindSpeed", {{1990}, {2015}, "Year"}], 
            GumbelDistribution[\[Alpha], \[Beta]]]] == 0.02, maxwind, 
        Reals]][[1]], "Kilometers"/"Hours"]*1.66, "Meters"/"Seconds"]

In[19]:= myMaxWindSpeed[-20, 30]

Out[19]= Quantity[43.3222, ("Meters")/("Seconds")]

So, I can call the function passing two arguments. But when trying to deploy to the Wolfram Cloud the code and answer are the below:

In[20]:= CloudDeploy[
 FormFunction[{"lat" -> Restricted["Number", {-180, 180}], 
   "lon" -> Restricted["Number", {-180, 180}]}, 
  myMaxWindSpeed[#lat, #lon] &]]

Out[20]= CloudObject["https://www.wolframcloud.com/objects/182e0f97-\
b6ff-49bd-8e64-627a27540513"]

The answer is this:

If[Floor[0.461111 maxwind] == 0.461111 maxwind, Floor[0.461111 maxwind], N[0.461111 maxwind]] "Meters"/"Seconds"

Testing cloud deployment with similar functions I have the below one, which works fine. So, what can be the problem here? Why the similar function doesn't work?

In[21]:= testfunction[lati_, longi_] := 
 WeatherData[{lati, longi}, "WindSpeed"]

In[22]:= CloudDeploy[
 FormFunction[{"lati" -> Restricted["Number", {-180, 180}], 
   "longi" -> Restricted["Number", {-180, 180}]}, 
  testfunction[#lati, #longi] &]]

Out[22]= CloudObject["https://www.wolframcloud.com/objects/1ba5d447-\
ed36-42db-8d89-0300f10c452a"]

Server answer after fill out the form with some coordinates: 9.7 "Kilometers"/"Hours"

POSTED BY: Balazs Kisfali
8 Replies

Just pointing out a relevant post: Modeling wind speed distributions with machine learning

POSTED BY: Vitaliy Kaurov
POSTED BY: Balazs Kisfali

Exactly as desired, thank you @Christopher Haydock

Ps.: FormObject has a rich documentation, somehow I was focused on CloudObject and FormFunction

POSTED BY: Balazs Kisfali

Thank you Vitaly for your suggestion

POSTED BY: Balazs Kisfali

Thank you Christopher, I tried with your modified code and the deployed version has the same answer unfortunately. I have similar "symptoms" since my original code is running on my desktop Mathematica 10.2 (with OSx El Capitan) but not in the cloud. There should be something wrong around the deployment.

This was the server answer with your modified code in the browser (Safari or Chrome, the same):

If[Floor[0.461111 maxwind] == 0.461111 maxwind, Floor[0.461111 maxwind], N[0.461111 maxwind]] "Meters"/"Seconds"
POSTED BY: Balazs Kisfali
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard