awesomebytes / libermate

DEPRECATED use https://github.com/victorlei/smop instead LiberMate - A MATLAB to Python (SciPy/NumPy) Translator
GNU General Public License v3.0
175 stars 84 forks source link

.m script matlab file is not converting to .py successfully. #5

Closed sameerCoder closed 6 years ago

sameerCoder commented 6 years ago

My .m matlab script file is not able to convert successfully. My .m matlab script file is give below :-1:

%%% Plotting output obtained from East Coast UNSWAN operational model.
%% Plotting magnitude of Hs with peak wave direction
clear all;clc;
xyzfile = 'PUNSWANIObathy.xyz';
dx = 0.7 ; % Distance between two consecutive wave direction arrows
xmin = 76;           % Boundary coordinates of basemap
xmax = 90;
ymin = 4;
ymax = 24;
cmax = 7;
%% Writing .mat output on basemap
load('EC_20180321.mat');
% Creating date string from start and end dates
stdate = '21-03-2018 00:00:00';
enddate = '24-03-2018 00:00:00';
stdate_num = datenum(stdate,'dd-mm-yyyy HH:MM:SS');
enddate_num = datenum(enddate,'dd-mm-yyyy HH:MM:SS');
basename = 'fort';                              % basename of element file
param = 'Hsig'; % parameter name should be same as that in the .mat file
hr_step=datenum(0,0,0,3,0,0); % Time interval(in hours)
date_array=stdate_num:hr_step:enddate_num; 
x=datestr(date_array,'dd-mm-yyyy HH:MM:SS'); % display in date format
siz_x = size(x);
siz_x = siz_x(1,1);
%% Importing element information
elefile=[basename '.ele'];
fid = fopen(elefile);                    % load TRIANGLE element based connectivity file
[nelem] = fscanf(fid,'%i',[1 3]);        % get number of triangles
ncol = 4+nelem(3);                       % specify number of columns in elefile
tri = fscanf(fid,'%i',[ncol nelem(1)])'; % get connectivity table
fclose(fid);
for i = 1%:siz_x
    date = x(i,:);
    day = date(1:2);
    month = date(4:5);
    year = date(7:10);
    hr = date(12:13);
    min = date(15:16);
    sec  = date(18:19);
    varname = strcat(param,'_',year,month,day,'_',hr,min,sec);
    z = eval([varname]);
    openfig('basemapstates_25.fig');
    % Converting time from GMT to IST
    t = datenum(date,'dd-mm-yyyy HH:MM:SS');
    t = addtodate(t,330,'minute');
    date_IST = datestr(t,'dd-mmm-yyyy HH:MM:SS');
    date_IST1 = date_IST(1:11);
    time_IST = date_IST(13:17);
    ax1_a = gca ;
    xtik = xmin:1:xmax;
    ytik = ymin:1:ymax;
    set(ax1_a,'Position',[0.2 0.15 0.72 0.72],'Xtick',xtik,'Ytick',ytik,'TickDir','out','FontName','Calibri','FontWeight','bold','Fontsize',8,'YAxisLocation','left','XAxisLocation','bottom');
    degreetick 'x'
    degreetick 'y'
    ax1_b = copyobj(gca,gcf);
    set(ax1_b,'YAxisLocation','right','XAxisLocation','top');
    degreetick 'x'
    degreetick 'y'
    linkaxes([ax1_a,ax1_b]);

    ax1 = gca;
    xlim([76 90]);
    ylim([4 24]);
    ax2 = axes ;
    %% Setting axes properties
    set(ax2,'ActivePositionProperty','outerposition','BusyAction','queue','Clipping','on','Color','none','DataAspectRatio',[1 1 1],'DataAspectRatioMode','manual','FontAngle','normal','FontName','Helvetica','FontSize',10,'FontUnits','points','FontWeight','normal','HandleVisibility','on','HitTest','on','Interruptible','on','Layer','bottom','LineStyleOrder','-','LineWidth',0.5000,'NextPlot','add','OuterPosition',[0 0 1 1],'PlotBoxAspectRatio',[1 1.3437 1.2500],'PlotBoxAspectRatioMode','auto','Position',[0.1300 0.1100 0.7750 0.8150],'Projection','orthographic','PlotBoxAspectRatio',[1 1.3437 1.2500],'PlotBoxAspectRatioMode','auto','Position',[0.1300 0.1100 0.7750 0.8150],'Projection','orthographic','Selected','off','SelectionHighlight','on','SortMethod','depth','Tag','','TickDir','in','TickDirMode','auto','TickLength',[0.0100 0.0250],'UIContextMenu',[],'Units','normalized','UserData',[],'View',[0 90],'Visible','off','XAxisLocation','bottom','XColor',[0.1500 0.1500 0.1500],'XDir','normal','XGrid','on','XLimMode','manual','XMinorGrid','off','XScale','linear','XTick',[],'YAxisLocation','left','YColor',[0.1500 0.1500 0.1500],'YDir','normal','YGrid','on','YMinorGrid','off','YMinorTick','off','YScale','linear','YTick',[],'YTickLabelMode','auto','ZColor',[0.1500 0.1500 0.1500],'ZDir','normal','ZDir','normal','ZGrid','on','ZMinorGrid','off','ZMinorTick','off','ZScale','linear');
    trisurf(tri(:,2:4),Xp,Yp,z,'EdgeColor','none');
    caxis([0 cmax]);    
    shading interp;
    cmap1 = jet;
    cmap = [cmap1(10,:);cmap1(15,:);cmap1(27,:);cmap1(35,:);cmap1(39,:);cmap1(43,:);cmap1(47,:);cmap1(51,:);cmap1(55,:);cmap1(57,:);cmap1(59,:);cmap1(62,:);cmap1(63,:);cmap1(64,:)];
    %cmap = cmap(7:20,:)
    view(0,90); 
    daspect([1 1 1])
    colormap(cmap);
    linkaxes([ax1,ax2])
    % Setting colorbar properties
    hcb = colorbar;
    ctick_vect = 0:0.5:cmax;
    set(hcb,'location','southoutside','Xtick',ctick_vect,'FontName','Calibri','FontWeight','bold','Fontsize',8);
    cpos = get(hcb,'Position');
    cpos(4) = 0.3*cpos(4);
    cpos(2) = 0.75*cpos(2);
    cpos(3) = 1*cpos(3);
    cpos(1) = 1.13*cpos(1);
    set(hcb,'Position',cpos);  
    set(gcf,'units','centimeters','outerposition',[0 0 30 30]);
    hold on

    %% Plotting directions
    var_dirname = strcat('PkDir','_',year,month,day,'_',hr,min,sec);
    d = eval([var_dirname]);
    d1 = degunitcircle2degN(d);
    u = arrayfun(@cosd,d1);
    v = arrayfun(@sind,d1);
    w = zeros(size(u));
    % Making structured from unstructured dataset to get the uniform density
    % of arrows everywhere
    [X,Y,Z,U,V,W] = unstrc2strcbathy(Xp,Yp,z,u,v,dx,xyzfile);
    idx = ~isnan(U) & ~isnan(V);
    Z = cmax*ones(size(U));
    arr = quiver3(X(idx),Y(idx),Z(idx),U(idx),V(idx),W(idx),'color','k','MaxHeadSize',0.8,'AutoScale','on','AutoScaleFactor',0.45,'LineWidth',1.3);
    ax3 = gca;
    set(ax3,'Position',[0.2 0.15 0.72 0.72]);
    title2 = ['Experimental Forecast for',' ',time_IST,' ','IST',' ',date_IST1];    

    annotation(gcf,'textbox',[0.41 0.895 0.3 0.0565552686204641],...
    'String','Significant Wave Height (m)',...
    'HorizontalAlignment','center','FontWeight','bold','FontName','Calibri','FontSize',11,...
    'LineStyle','none');
    annotation(gcf,'textbox',[0.26 0.87 0.6 0.0565552686204641],...
    'String',title2,...
    'HorizontalAlignment','center','FontWeight','bold','FontName','Calibri','FontSize',10,...
    'LineStyle','none','color',[0 0.5 0]);
    % Create textbox
    annotation(gcf,'textbox',[0.31 0.029 0.5 0.0565552686204641],...
    'String','Colour scale indicates magnitude of Hs',...
    'HorizontalAlignment','center','FontWeight','bold','FontName','Calibri',...
    'FontSize',9,'LineStyle','none');
    annotation(gcf,'textbox',[0.31 0.013 0.5 0.0565552686204641],...
    'String','Direction of arrows represent peak wave direction',...
    'HorizontalAlignment','center','FontWeight','bold','FontName','Calibri',...
    'FontSize',9,'LineStyle','none');
    num = num2str(i);
    image_name = strcat(param,'-',day,'-',month,'-',year,'--',hr,min);
    drawnow
    export_fig(image_name,'-jpg','-r200');
    hold off
    close all
end

can you able to convert this .m file to .py file . kindly reply or tell me how to convert this .m script file to .py ,. thanks

awesomebytes commented 6 years ago

As you can read in the README:

Check notes_on_using_libermate.txt if you use it and it doesn't work properly (it's normal!) I give many hints there on how to correct problems I had while translating You may want to try the new: https://github.com/victorlei/smop It's a work in progress, which means, someone is working on it! This one is just as it is.

Also, I personally doubt very much you'll get the plotting working out of the box with any translator.

sameerCoder commented 6 years ago

Hi, So can you tell me how to do plotting work ?

On 11 May 2018 at 13:06, Sam Pfeiffer notifications@github.com wrote:

As you can read in the README https://github.com/awesomebytes/libermate/blob/master/README.md:

Check notes_on_using_libermate.txt https://github.com/awesomebytes/libermate/blob/master/notes_on_using_libermate.txt if you use it and it doesn't work properly (it's normal!) I give many hints there on how to correct problems I had while translating You may want to try the new: https://github.com/victorlei/smop It's a work in progress, which means, someone is working on it! This one is just as it is.

Also, I personally doubt very much you'll get the plotting working out of the box with any translator.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awesomebytes/libermate/issues/5#issuecomment-388286182, or mute the thread https://github.com/notifications/unsubscribe-auth/AlXlpwXoEd3NW_HH_2Gg6zOyrl_0fKIxks5txT-VgaJpZM4T7BkT .

awesomebytes commented 6 years ago

Once again, try the other project, but I doubt it will work either. If it doesn't, you need to rewrite that logic with matplotlib yourself.

sameerCoder commented 6 years ago

Hi, By using matplotlib i can plot the image ? can i can use .mat (MATLAB data file ) as a source file in matplotlib source code ? *.mat file i.e mat extension file can be used in matplotlib without any problem ? Do you know any one who is good in Matplotlib ?

Thanks

On 11 May 2018 at 15:21, Sam Pfeiffer notifications@github.com wrote:

Once again, try the other project, but I doubt it will work either. If it doesn't you need to rewrite that logic with matplotlib yourself.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awesomebytes/libermate/issues/5#issuecomment-388317650, or mute the thread https://github.com/notifications/unsubscribe-auth/AlXlpyH7KoffzDlWXF6j71Novvk13A7Dks5txV8pgaJpZM4T7BkT .

awesomebytes commented 6 years ago

@sameerCoder you'll need to learn how to use matplotlib: https://matplotlib.org/

They have nice documentation and examples. The code looks very very similar to the MATLAB version of it, they even say in their website:

For simple plotting the pyplot module provides a MATLAB-like interface, particularly when combined with IPython. For the power user, you have full control of line styles, font properties, axes properties, etc, via an object oriented interface or via a set of functions familiar to MATLAB users.

In short: you will need to do it yourself by hand. You may use this library for a first guess and try to work out from there.

awesomebytes commented 6 years ago

Are you even trying?

I ran libermate on your code and I got a translation after fixing some obvious errors, its a matter of trial and error man...


import numpy as np
import scipy
import matcompat
import scipy.io as sio
from datetime import date

# if available import pylab (from matlibplot)
try:
    import matplotlib.pylab as plt
except ImportError:
    pass

#%%% Plotting output obtained from East Coast UNSWAN operational model.
#%% Plotting magnitude of Hs with peak wave direction

xyzfile = 'PUNSWANIObathy.xyz'
dx = 0.7
#% Distance between two consecutive wave direction arrows
xmin = 76.
#% Boundary coordinates of basemap
xmax = 90.
ymin = 4.
ymax = 24.
cmax = 7.
#%% Writing .mat output on basemap
sio.loadmat('EC_20180321.mat')
#% Creating date string from start and end dates
stdate = '21-03-2018 00:00:00'
enddate = '24-03-2018 00:00:00'
stdate_num = datenum(stdate, 'dd-mm-yyyy HH:MM:SS')
enddate_num = datenum(enddate, 'dd-mm-yyyy HH:MM:SS')
basename = 'fort'
#% basename of element file
param = 'Hsig'
#% parameter name should be same as that in the .mat file
hr_step = datenum(0., 0., 0., 3., 0., 0.)
#% Time interval(in hours)
date_array = np.arange(stdate_num, (enddate_num)+(hr_step), hr_step)
x = datestr(date_array, 'dd-mm-yyyy HH:MM:SS')
#% display in date format
siz_x = matcompat.size(x)
siz_x = siz_x[0,0]
#%% Importing element information
elefile = np.array(np.hstack((basename)))
fid = fopen(elefile)
#% load TRIANGLE element based connectivity file
[nelem] = fscanf(fid, '%i', np.array(np.hstack((1., 3.))))
#% get number of triangles
ncol = 4.+nelem[2]
#% specify number of columns in elefile
tri = fscanf(fid, '%i', np.array(np.hstack((ncol, nelem[0])))).conj().T
#% get connectivity table
fclose(fid)
for i in np.arange(1., (siz_x)+1):
    date = x[int(i)-1,:]
    day = date[0:2.]
    month = date[3:5.]
    year = date[6:10.]
    hr = date[11:13.]
    min = date[14:16.]
    sec = date[17:19.]
    varname = strcat(param, '_', year, month, day, '_', hr, min, sec)
    z = eval(np.array(np.hstack((varname))))
    openfig('basemapstates_25.fig')
    #% Converting time from GMT to IST
    t = datenum(date, 'dd-mm-yyyy HH:MM:SS')
    t = addtodate(t, 330., 'minute')
    date_IST = datestr(t, 'dd-mmm-yyyy HH:MM:SS')
    date_IST1 = date_IST[0:11.]
    time_IST = date_IST[12:17.]
    ax1_a = plt.gca
    xtik = np.arange(xmin, (xmax)+(1.), 1.)
    ytik = np.arange(ymin, (ymax)+(1.), 1.)
    set(ax1_a, 'Position', np.array(np.hstack((0.2, 0.15, 0.72, 0.72))), 'Xtick', xtik, 'Ytick', ytik, 'TickDir', 'out', 'FontName', 'Calibri', 'FontWeight', 'bold', 'Fontsize', 8., 'YAxisLocation', 'left', 'XAxisLocation', 'bottom')
    ax1_b = copyobj(plt.gca, plt.gcf)
    set(ax1_b, 'YAxisLocation', 'right', 'XAxisLocation', 'top')
    linkaxes(np.array(np.hstack((ax1_a, ax1_b))))
    ax1 = plt.gca
    plt.xlim(np.array(np.hstack((76., 90.))))
    plt.ylim(np.array(np.hstack((4., 24.))))
    ax2 = plt.axes
    #%% Setting axes properties
    set(ax2, 'ActivePositionProperty', 'outerposition', 'BusyAction', 'queue', 'Clipping', 'on', 'Color', 'none', 'DataAspectRatio', np.array(np.hstack((1., 1., 1.))), 'DataAspectRatioMode', 'manual', 'FontAngle', 'normal', 'FontName', 'Helvetica', 'FontSize', 10., 'FontUnits', 'points', 'FontWeight', 'normal', 'HandleVisibility', 'on', 'HitTest', 'on', 'Interruptible', 'on', 'Layer', 'bottom', 'LineStyleOrder', '-', 'LineWidth', 0.5000, 'NextPlot', 'add', 'OuterPosition', np.array(np.hstack((0., 0., 1., 1.))), 'PlotBoxAspectRatio', np.array(np.hstack((1., 1.3437, 1.2500))), 'PlotBoxAspectRatioMode', 'auto', 'Position', np.array(np.hstack((0.1300, 0.1100, 0.7750, 0.8150))), 'Projection', 'orthographic', 'PlotBoxAspectRatio', np.array(np.hstack((1., 1.3437, 1.2500))), 'PlotBoxAspectRatioMode', 'auto', 'Position', np.array(np.hstack((0.1300, 0.1100, 0.7750, 0.8150))), 'Projection', 'orthographic', 'Selected', 'off', 'SelectionHighlight', 'on', 'SortMethod', 'depth', 'Tag', '', 'TickDir', 'in', 'TickDirMode', 'auto', 'TickLength', np.array(np.hstack((0.0100, 0.0250))), 'UIContextMenu', np.array([]), 'Units', 'normalized', 'UserData', np.array([]), 'View', np.array(np.hstack((0., 90.))), 'Visible', 'off', 'XAxisLocation', 'bottom', 'XColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'XDir', 'normal', 'XGrid', 'on', 'XLimMode', 'manual', 'XMinorGrid', 'off', 'XScale', 'linear', 'XTick', np.array([]), 'YAxisLocation', 'left', 'YColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'YDir', 'normal', 'YGrid', 'on', 'YMinorGrid', 'off', 'YMinorTick', 'off', 'YScale', 'linear', 'YTick', np.array([]), 'YTickLabelMode', 'auto', 'ZColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'ZDir', 'normal', 'ZDir', 'normal', 'ZGrid', 'on', 'ZMinorGrid', 'off', 'ZMinorTick', 'off', 'ZScale', 'linear')
    trisurf(tri[:,1:4.], Xp, Yp, z, 'EdgeColor', 'none')
    caxis(np.array(np.hstack((0., cmax))))
    shading(interp)
    cmap1 = plt.jet
    cmap = np.array(np.vstack((np.hstack((cmap1[9,:])), np.hstack((cmap1[14,:])), np.hstack((cmap1[26,:])), np.hstack((cmap1[30,:])), np.hstack((cmap1[34,:])), np.hstack((cmap1[38,:])), np.hstack((cmap1[42,:])), np.hstack((cmap1[46,:])), np.hstack((cmap1[50,:])), np.hstack((cmap1[54,:])), np.hstack((cmap1[56,:])), np.hstack((cmap1[58,:])), np.hstack((cmap1[61,:])), np.hstack((cmap1[63,:])))))
    #%cmap = cmap(7:20,:)
    view(0., 90.)
    daspect(np.array(np.hstack((1., 1., 1.))))
    colormap(cmap)
    linkaxes(np.array(np.hstack((ax1, ax2))))
    #% Setting colorbar properties
    hcb = plt.colorbar
    ctick_vect = np.arange(0., (cmax)+(0.5), 0.5)
    set(hcb, 'location', 'southoutside', 'Xtick', ctick_vect, 'FontName', 'Calibri', 'FontWeight', 'bold', 'Fontsize', 8.)
    cpos = plt.get(hcb, 'Position')
    cpos[3] = np.dot(0.3, cpos[3])
    cpos[1] = np.dot(0.75, cpos[1])
    cpos[2] = 1.*cpos[2]
    cpos[0] = np.dot(1.13, cpos[0])
    set(hcb, 'Position', cpos)
    set(plt.gcf, 'units', 'centimeters', 'outerposition', np.array(np.hstack((0., 0., 30., 30.))))
    plt.hold(on)
    #%% Plotting directions
    var_dirname = strcat('PkDir', '_', year, month, day, '_', hr, min, sec)
    d = eval(np.array(np.hstack((var_dirname))))
    d1 = degunitcircle2degN(d)
    u = arrayfun(cosd, d1)
    v = arrayfun(sind, d1)
    w = np.zeros(matcompat.size(u))
    #% Making structured from unstructured dataset to get the uniform density
    #% of arrows everywhere
    [X, Y, Z, U, V, W] = unstrc2strcbathy(Xp, Yp, z, u, v, dx, xyzfile)
    idx = np.logical_and(not np.isnan(U), not np.isnan(V))
    Z = np.dot(cmax, np.ones(matcompat.size(U)))
    arr = quiver3(X[int(idx)-1], Y[int(idx)-1], Z[int(idx)-1], U[int(idx)-1], V[int(idx)-1], W[int(idx)-1], 'color', 'k', 'MaxHeadSize', 0.8, 'AutoScale', 'on', 'AutoScaleFactor', 0.45, 'LineWidth', 1.3)
    ax3 = plt.gca
    set(ax3, 'Position', np.array(np.hstack((0.2, 0.15, 0.72, 0.72))))
    title2 = np.array(np.hstack(('Experimental Forecast for', ' ', time_IST, ' ', 'IST', ' ', date_IST1)))
    annotation(plt.gcf, 'textbox', np.array(np.hstack((0.41, 0.895, 0.3, 0.0565552686204641))), 'String', 'Significant Wave Height (m)', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 11., 'LineStyle', 'none')
    annotation(plt.gcf, 'textbox', np.array(np.hstack((0.26, 0.87, 0.6, 0.0565552686204641))), 'String', title2, 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 10., 'LineStyle', 'none', 'color', np.array(np.hstack((0., 0.5, 0.))))
    #% Create textbox
    annotation(plt.gcf, 'textbox', np.array(np.hstack((0.31, 0.029, 0.5, 0.0565552686204641))), 'String', 'Colour scale indicates magnitude of Hs', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 9., 'LineStyle', 'none')
    annotation(plt.gcf, 'textbox', np.array(np.hstack((0.31, 0.013, 0.5, 0.0565552686204641))), 'String', 'Direction of arrows represent peak wave direction', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 9., 'LineStyle', 'none')
    num = num2str(i)
    image_name = strcat(param, '-', day, '-', month, '-', year, '--', hr, min)
    drawnow
    export_fig(image_name, '-jpg', '-r200')
    plt.hold(off)
    plt.close(all)

That's what I got. I have no more time to dedicate to this.

sameerCoder commented 6 years ago

Hi, Thanks man , can i know how you got the solution of fixing some obvious errors , where did you find the solution of these errors ?

On 11 May 2018 at 17:14, Sam Pfeiffer notifications@github.com wrote:

Are you even trying?

I ran libermate on your code and I got a translation after fixing some obvious errors, its a matter of trial and error man...

import numpy as npimport scipyimport matcompatimport scipy.io as siofrom datetime import date

if available import pylab (from matlibplot)try:

import matplotlib.pylab as pltexcept ImportError:
pass

%%% Plotting output obtained from East Coast UNSWAN operational model.#%% Plotting magnitude of Hs with peak wave direction

xyzfile = 'PUNSWANIObathy.xyz' dx = 0.7#% Distance between two consecutive wave direction arrows xmin = 76.#% Boundary coordinates of basemap xmax = 90. ymin = 4. ymax = 24. cmax = 7.#%% Writing .mat output on basemap sio.loadmat('EC_20180321.mat')#% Creating date string from start and end dates stdate = '21-03-2018 00:00:00' enddate = '24-03-2018 00:00:00' stdate_num = datenum(stdate, 'dd-mm-yyyy HH:MM:SS') enddate_num = datenum(enddate, 'dd-mm-yyyy HH:MM:SS') basename = 'fort'#% basename of element file param = 'Hsig'#% parameter name should be same as that in the .mat file hr_step = datenum(0., 0., 0., 3., 0., 0.)#% Time interval(in hours) date_array = np.arange(stdate_num, (enddate_num)+(hr_step), hr_step) x = datestr(date_array, 'dd-mm-yyyy HH:MM:SS')#% display in date format siz_x = matcompat.size(x) siz_x = siz_x[0,0]#%% Importing element information elefile = np.array(np.hstack((basename))) fid = fopen(elefile)#% load TRIANGLE element based connectivity file [nelem] = fscanf(fid, '%i', np.array(np.hstack((1., 3.))))#% get number of triangles ncol = 4.+nelem[2]#% specify number of columns in elefile tri = fscanf(fid, '%i', np.array(np.hstack((ncol, nelem[0])))).conj().T#% get connectivity table fclose(fid)for i in np.arange(1., (sizx)+1): date = x[int(i)-1,:] day = date[0:2.] month = date[3:5.] year = date[6:10.] hr = date[11:13.] min = date[14:16.] sec = date[17:19.] varname = strcat(param, '', year, month, day, '_', hr, min, sec) z = eval(np.array(np.hstack((varname)))) openfig('basemapstates_25.fig')

% Converting time from GMT to IST

t = datenum(date, 'dd-mm-yyyy HH:MM:SS')
t = addtodate(t, 330., 'minute')
date_IST = datestr(t, 'dd-mmm-yyyy HH:MM:SS')
date_IST1 = date_IST[0:11.]
time_IST = date_IST[12:17.]
ax1_a = plt.gca
xtik = np.arange(xmin, (xmax)+(1.), 1.)
ytik = np.arange(ymin, (ymax)+(1.), 1.)
set(ax1_a, 'Position', np.array(np.hstack((0.2, 0.15, 0.72, 0.72))), 'Xtick', xtik, 'Ytick', ytik, 'TickDir', 'out', 'FontName', 'Calibri', 'FontWeight', 'bold', 'Fontsize', 8., 'YAxisLocation', 'left', 'XAxisLocation', 'bottom')
ax1_b = copyobj(plt.gca, plt.gcf)
set(ax1_b, 'YAxisLocation', 'right', 'XAxisLocation', 'top')
linkaxes(np.array(np.hstack((ax1_a, ax1_b))))
ax1 = plt.gca
plt.xlim(np.array(np.hstack((76., 90.))))
plt.ylim(np.array(np.hstack((4., 24.))))
ax2 = plt.axes
#%% Setting axes properties
set(ax2, 'ActivePositionProperty', 'outerposition', 'BusyAction', 'queue', 'Clipping', 'on', 'Color', 'none', 'DataAspectRatio', np.array(np.hstack((1., 1., 1.))), 'DataAspectRatioMode', 'manual', 'FontAngle', 'normal', 'FontName', 'Helvetica', 'FontSize', 10., 'FontUnits', 'points', 'FontWeight', 'normal', 'HandleVisibility', 'on', 'HitTest', 'on', 'Interruptible', 'on', 'Layer', 'bottom', 'LineStyleOrder', '-', 'LineWidth', 0.5000, 'NextPlot', 'add', 'OuterPosition', np.array(np.hstack((0., 0., 1., 1.))), 'PlotBoxAspectRatio', np.array(np.hstack((1., 1.3437, 1.2500))), 'PlotBoxAspectRatioMode', 'auto', 'Position', np.array(np.hstack((0.1300, 0.1100, 0.7750, 0.8150))), 'Projection', 'orthographic', 'PlotBoxAspectRatio', np.array(np.hstack((1., 1.3437, 1.2500))), 'PlotBoxAspectRatioMode', 'auto', 'Position', np.array(np.hstack((0.1300, 0.1100, 0.7750, 0.8150))), 'Projection', 'orthographic', 'Selected', 'off', 'SelectionHighlight', 'on', 'SortMethod', 'depth', 'Tag', '', 'TickDir', 'in', 'TickDirMode', 'auto', 'TickLength', np.array(np.hstack((0.0100, 0.0250))), 'UIContextMenu', np.array([]), 'Units', 'normalized', 'UserData', np.array([]), 'View', np.array(np.hstack((0., 90.))), 'Visible', 'off', 'XAxisLocation', 'bottom', 'XColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'XDir', 'normal', 'XGrid', 'on', 'XLimMode', 'manual', 'XMinorGrid', 'off', 'XScale', 'linear', 'XTick', np.array([]), 'YAxisLocation', 'left', 'YColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'YDir', 'normal', 'YGrid', 'on', 'YMinorGrid', 'off', 'YMinorTick', 'off', 'YScale', 'linear', 'YTick', np.array([]), 'YTickLabelMode', 'auto', 'ZColor', np.array(np.hstack((0.1500, 0.1500, 0.1500))), 'ZDir', 'normal', 'ZDir', 'normal', 'ZGrid', 'on', 'ZMinorGrid', 'off', 'ZMinorTick', 'off', 'ZScale', 'linear')
trisurf(tri[:,1:4.], Xp, Yp, z, 'EdgeColor', 'none')
caxis(np.array(np.hstack((0., cmax))))
shading(interp)
cmap1 = plt.jet
cmap = np.array(np.vstack((np.hstack((cmap1[9,:])), np.hstack((cmap1[14,:])), np.hstack((cmap1[26,:])), np.hstack((cmap1[30,:])), np.hstack((cmap1[34,:])), np.hstack((cmap1[38,:])), np.hstack((cmap1[42,:])), np.hstack((cmap1[46,:])), np.hstack((cmap1[50,:])), np.hstack((cmap1[54,:])), np.hstack((cmap1[56,:])), np.hstack((cmap1[58,:])), np.hstack((cmap1[61,:])), np.hstack((cmap1[63,:])))))
#%cmap = cmap(7:20,:)
view(0., 90.)
daspect(np.array(np.hstack((1., 1., 1.))))
colormap(cmap)
linkaxes(np.array(np.hstack((ax1, ax2))))
#% Setting colorbar properties
hcb = plt.colorbar
ctick_vect = np.arange(0., (cmax)+(0.5), 0.5)
set(hcb, 'location', 'southoutside', 'Xtick', ctick_vect, 'FontName', 'Calibri', 'FontWeight', 'bold', 'Fontsize', 8.)
cpos = plt.get(hcb, 'Position')
cpos[3] = np.dot(0.3, cpos[3])
cpos[1] = np.dot(0.75, cpos[1])
cpos[2] = 1.*cpos[2]
cpos[0] = np.dot(1.13, cpos[0])
set(hcb, 'Position', cpos)
set(plt.gcf, 'units', 'centimeters', 'outerposition', np.array(np.hstack((0., 0., 30., 30.))))
plt.hold(on)
#%% Plotting directions
var_dirname = strcat('PkDir', '_', year, month, day, '_', hr, min, sec)
d = eval(np.array(np.hstack((var_dirname))))
d1 = degunitcircle2degN(d)
u = arrayfun(cosd, d1)
v = arrayfun(sind, d1)
w = np.zeros(matcompat.size(u))
#% Making structured from unstructured dataset to get the uniform density
#% of arrows everywhere
[X, Y, Z, U, V, W] = unstrc2strcbathy(Xp, Yp, z, u, v, dx, xyzfile)
idx = np.logical_and(not np.isnan(U), not np.isnan(V))
Z = np.dot(cmax, np.ones(matcompat.size(U)))
arr = quiver3(X[int(idx)-1], Y[int(idx)-1], Z[int(idx)-1], U[int(idx)-1], V[int(idx)-1], W[int(idx)-1], 'color', 'k', 'MaxHeadSize', 0.8, 'AutoScale', 'on', 'AutoScaleFactor', 0.45, 'LineWidth', 1.3)
ax3 = plt.gca
set(ax3, 'Position', np.array(np.hstack((0.2, 0.15, 0.72, 0.72))))
title2 = np.array(np.hstack(('Experimental Forecast for', ' ', time_IST, ' ', 'IST', ' ', date_IST1)))
annotation(plt.gcf, 'textbox', np.array(np.hstack((0.41, 0.895, 0.3, 0.0565552686204641))), 'String', 'Significant Wave Height (m)', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 11., 'LineStyle', 'none')
annotation(plt.gcf, 'textbox', np.array(np.hstack((0.26, 0.87, 0.6, 0.0565552686204641))), 'String', title2, 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 10., 'LineStyle', 'none', 'color', np.array(np.hstack((0., 0.5, 0.))))
#% Create textbox
annotation(plt.gcf, 'textbox', np.array(np.hstack((0.31, 0.029, 0.5, 0.0565552686204641))), 'String', 'Colour scale indicates magnitude of Hs', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 9., 'LineStyle', 'none')
annotation(plt.gcf, 'textbox', np.array(np.hstack((0.31, 0.013, 0.5, 0.0565552686204641))), 'String', 'Direction of arrows represent peak wave direction', 'HorizontalAlignment', 'center', 'FontWeight', 'bold', 'FontName', 'Calibri', 'FontSize', 9., 'LineStyle', 'none')
num = num2str(i)
image_name = strcat(param, '-', day, '-', month, '-', year, '--', hr, min)
drawnow
export_fig(image_name, '-jpg', '-r200')
plt.hold(off)
plt.close(all)

That's what I got. I have no more time to dedicate to this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awesomebytes/libermate/issues/5#issuecomment-388340621, or mute the thread https://github.com/notifications/unsubscribe-auth/AlXlp0jWkGfNZj5DA0g44U7ExoAVVOGrks5txXm7gaJpZM4T7BkT .

awesomebytes commented 6 years ago

I just read the error, went to the line of code of the error and fixed it with the most logical way of fixing it...

awesomebytes commented 6 years ago

I have no more time to dedicate to this. I'm sorry. Good luck. Closing the issue.

sameerCoder commented 6 years ago

Hi, you close the issue no problem ,

On 11 May 2018 at 18:05, Sam Pfeiffer notifications@github.com wrote:

I have no more time to dedicate to this. I'm sorry. Good luck. Closing the issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awesomebytes/libermate/issues/5#issuecomment-388351022, or mute the thread https://github.com/notifications/unsubscribe-auth/AlXlp7nhnw1KmIBd7vOghLjFc62J-vhAks5txYWlgaJpZM4T7BkT .

awesomebytes commented 6 years ago

I literally solved the errors by reading them, analyzing them, and trying to fix them. I didn't search anything. I just applied logic. Error on line X. Check what's in line X. Something looks weird? Fix it.

For example you have a line like:

for i = 1%:siz_x

And it stops there. Well. That code is clearly wrong in your MATLAB code. Anything after % is a comment. So it must be for i = 1:siz_x. Then from the already translated code MATLAB uses a function called datenum. There is no translation in Python. So you need to find how to do the same in Python. There is nowhere to look, really, you need to think what's going on and keep trying.