Items tagged with import

Hello all, 

A question concerning NetCdf files was asked in 2012 and is still unanswered today.
Browsing the questions only returns this item, suggesting the NetCdf topic is not a concern in the Maple community.
Nevertheless, does it exist some capabilities in reading and writting NetCDF files ?
If not, are there some planned development on the subject ?

Let's hope now for not having to wait four years for an answer, all responses will be greatly appreciated, even negative.

years


PS : NetCdf capabilities already exist in Sage or Mathematica

Dear Maple users

I have done some experiments with the new Workbook feature in Maple 2016. It is a very welcome addition, indeed. Earlier I have created Maple files in which data from an external Excel file was imported and being used for certain calculations. In order to make recalculations work properly, one need to let the Excel file follow the Maple file. That's where a Workbook come in handy! I tried placing those two files in a Workbook. It didn't work completely as advertised, I think. I moved the Workbook to another location on the harddrive to make sure it wouldn't interfere with the original files outside the Workbook. Then I recalculated the Maple document inside the Workbook. The good thing: The data from the Excel file was still present. The bad thing: If I changed some data in the Excel file inside the Workbook, it didn't register in the Maple file when updating it!

Maybe I should explain that I did import data from the Excel file into Maple via the menu: Tools > Assistants > Import Data... The data was retrieved as a matrix within the Maple file and assigned to a variable and used for plots ...

Why doesn't the above procedure work properly? I hope one don't need to use the Workbook URI to reference files within the workbook. It is not that userfriendly!

 

Regards,

Erik

how to translate python code which use scipy, numpy to maple code

 

 

import numpy as np
from scipy.sparse.linalg import svds
from functools import partial


def emsvd(Y, k=None, tol=1E-3, maxiter=None):
    """
    Approximate SVD on data with missing values via expectation-maximization

    Inputs:
    -----------
    Y:          (nobs, ndim) data matrix, missing values denoted by NaN/Inf
    k:          number of singular values/vectors to find (default: k=ndim)
    tol:        convergence tolerance on change in trace norm
    maxiter:    maximum number of EM steps to perform (default: no limit)

    Returns:
    -----------
    Y_hat:      (nobs, ndim) reconstructed data matrix
    mu_hat:     (ndim,) estimated column means for reconstructed data
    U, s, Vt:   singular values and vectors (see np.linalg.svd and 
                scipy.sparse.linalg.svds for details)
    """

    if k is None:
        svdmethod = partial(np.linalg.svd, full_matrices=False)
    else:
        svdmethod = partial(svds, k=k)
    if maxiter is None:
        maxiter = np.inf

    # initialize the missing values to their respective column means
    mu_hat = np.nanmean(Y, axis=0, keepdims=1)
    valid = np.isfinite(Y)
    Y_hat = np.where(valid, Y, mu_hat)

    halt = False
    ii = 1
    v_prev = 0

    while not halt:

        # SVD on filled-in data
        U, s, Vt = svdmethod(Y_hat - mu_hat)

        # impute missing values
        Y_hat[~valid] = (U.dot(np.diag(s)).dot(Vt) + mu_hat)[~valid]

        # update bias parameter
        mu_hat = Y_hat.mean(axis=0, keepdims=1)

        # test convergence using relative change in trace norm
        v = s.sum()
        if ii >= maxiter or ((v - v_prev) / v_prev) < tol:
            halt = True
        ii += 1
        v_prev = v

    return Y_hat, mu_hat, U, s, Vt

Is it possible to share contents between two different Maple worksheets ? Suppose for example, I want to use certain expression number (10) of  Worksheet 1 in worksheet 2, can I call that expression (10) in worksheet 2 ? I am asking this question because copying expressions between different worksheets is not easy task, sometime we unable copy expressions when they are too large. In my case after carrying out very tedious and lengthy calculations Maple stopped responding, now I have an idea that if I import last output of present worksheet in new worksheet may be I could continue my calculations.

Regards

hi

if possible to convert matlab file in to maple fie program??convert_to_maple_program.txt

thanks

 

this is the matlab is it possible to rewrite it in simple maple code

J = rand()+1e-10;

function [M, num, E] = ising(N,J)

B = 0;

M = []; % The total magnetic field of the system

E = []; % The total energy of the system

randTol = 0.1; % The tolerance, dampens the spin flip process

% First we generate a random initial configuration

spin = (-1).^(round(rand(N)));

% Then we let the system evolve for a fixed number of steps

for i=1:1000,

% Calculating the total spin of neighbouring cells

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

% Calculate the change in energy of flipping a spin

DeltaE = 2 * (J*(spin .* neighbours) + B*spin);

% Calculate the transition probabilities

p_trans = exp(-DeltaE);

% Decide which transitions will occur

transitions = (rand(N) < p_trans ).*(rand(N) < randTol) * -2 + 1;

% Perform the transitions

spin = spin .* transitions;

% Sum up our variables of interest

M = sum(sum(spin));

E = -sum(sum(DeltaE))/2; % Divide by two because of double counting

% Display the current state of the system (optional)

image((spin+1)*128);

xlabel(sprintf('J = %0.2f, M = %0.2f, E = %0.2f', J, M/N^2, E/N^2));

set(gca,'YTickLabel',[],'XTickLabel',[]);

axis square; colormap bone; drawnow;

end

% Count the number of clusters of 'spin up' states

[L, num] = bwlabel(spin == 1, 4);

############################# 

Dear all,

I am looking at the help page for reading json files, but it is too advanced for me to understand...

Can anyone give an easy example where a json file is read into a variable and printing the data structure?

 

Hugs,
Louise =)

 

Hello all,

I have a hash structure with arrays in a YAML file that I would like to read in Maple.

Does there exist a module, so I can read it?

 

Hi guys,
I want to import symbolic matrix from matlab to Maple, How I can do that ? 


Hello,

Thanks to different posts of the subject "Exporting data from Excel to Maple", I could learn the method to do it and conduct it.

Now, I would like to store the data exported from Excel to Maple in the worksheet and make my worksheet independent from the excel sheet.

The idea is that I can send my worksheet to a collegue and he can use without the excel sheet.

May you advice me a strategy to store the imported data ?

The copy/ paste works but it doesn't look smart.

Thank you for your help.

 

Hello

Is there any option for impoting MATLAB's variables eith struct format (*.mat)?

Could you please to help me!

Thank you.

 

Hi everyone,

I am trying to copy a 178x2 matrix into maple. the data is in a .dat file in two columns. For example the first few lines:

+2.000000E-10 +1.636232E-05

+3.017707E-05 +4.531920E-05

+6.065973E-05 +7.586885E-05

+9.096636E-05 +1.059570E-04

+1.208671E-04 +1.357189E-04

I was having trouble importing an excel sheet

with(ExcelTools):
a:=Import("c:/inquire.xls","test1a.tabs","A2:B50")

  Error, (in ExcelTools:-Import) There was an error reading the Excel file

The excel sheet only had one tab visible named test1a.tabs

However it loaded fine without the range and sheetname specified
      a:=Import("c:/inquire.xls")
             

and it loaded fine using the sheet name as a number

     b:=Import("c:/inquire.xls",1,"A2:B50")

             

 

I was wondering if anyone else experienced this or if I was doing something wrong someone could point out.

 

I would like to import the code from Pg 90 on in the following document into Maple. Any suggestions for doing so with minimal editing required after pasting? http://mspace.lib.umanitoba.ca/xmlui/bitstream/handle/1993/14907/Huang_Liji.pdf?sequence=1&isAllowed=y

thanks,

1 2 3 Page 1 of 3