This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # add_depth.py (c) 2021-01-28 OKADA Teruhisa | |
| import xarray as xr | |
| def add_depth(ds): | |
| """ | |
| Add z_rho & depth_rho into xr.Dataset | |
| """ | |
| if not hasattr(ds, 'Vtransform'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| handles, labels = ax.get_legend_handles_labels() | |
| ax.legend(handles[::-1], labels[::-1], bbox_to_anchor=[1,1], loc=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from matplotlib import dates | |
| def set_xdate(ax): | |
| ax[-1].set_xlabel('') | |
| # major | |
| ax[-1].xaxis.set_major_locator(dates.MonthLocator()) | |
| ax[-1].xaxis.set_major_formatter('') | |
| # minor | |
| loc = dates.MonthLocator(bymonthday=16) | |
| fmt = dates.ConciseDateFormatter(loc, zero_formats=['','%b\n%Y','%b','%b-%d','%H:%M','%H:%M'], show_offset=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def interp(x_rho, y_rho, nc): | |
| """Interpolate multi-interval mesh into equal interval mesh for ROMS | |
| (c) 2021-11-14 OKADA Teruhisa | |
| Parameters: | |
| x_rho: array-like of x_rho-points for interpolated points | |
| y_rho: array-like of y_rho-points for interpolated points | |
| nc: xr.Dataset for ROMS with multi-interval mesh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class C: | |
| @property | |
| def x(self): | |
| return self.__x | |
| @x.setter | |
| def x(self, value): | |
| self.__x = value | |
| if __name__ == "__main__": | |
| c = C() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Person: | |
| def __init__(self, name, age): | |
| self.name = name | |
| self.age = age | |
| def __len__(self): | |
| return len(self.__dict__) | |
| def __repr__(self): | |
| return str(self.__dict__) | |
| def __str__(self): | |
| return str(self.__dict__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ディレクトリは755、ファイルは644 | |
| chmod -R a=rX,u+w . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [c]heck しながら置換 | |
| :%s/置換前文字列/置換後文字列/gc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hatched Rectangle | |
| import matplotlib.patches as patches | |
| p = patches.Rectangle((0,-17), 8, 17-df.depth.iloc[-1], linewidth=0, fill=None, hatch='/') | |
| ax.add_patch(p) |
NewerOlder